Click here to Skip to main content
15,885,278 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhtml string in .lnk file Pin
limelect23-May-11 20:47
limelect23-May-11 20:47 
AnswerRe: html string in .lnk file Pin
ShilpiP23-May-11 22:50
ShilpiP23-May-11 22:50 
GeneralRe: html string in .lnk file Pin
limelect24-May-11 20:44
limelect24-May-11 20:44 
GeneralRe: html string in .lnk file Pin
ShilpiP24-May-11 21:09
ShilpiP24-May-11 21:09 
GeneralRe: html string in .lnk file Pin
limelect24-May-11 21:18
limelect24-May-11 21:18 
GeneralRe: html string in .lnk file Pin
ShilpiP24-May-11 21:26
ShilpiP24-May-11 21:26 
GeneralRe: html string in .lnk file Pin
limelect24-May-11 21:45
limelect24-May-11 21:45 
GeneralRe: html string in .lnk file Pin
ShilpiP24-May-11 22:36
ShilpiP24-May-11 22:36 
Is your Target name is the folder where your .lnk file is placed ??
It should be the full path of .lnk file
Example : "c:\\abc\\file.lnk".

The example given in this link is same that I will give you.
How to create and resolve a shortcut[^]

I had created a sample project and it is working fine:
HRESULT CMy1Dlg::ResolveIt(HWND hwnd, LPCSTR lpszLinkFile, LPWSTR lpszPath, int iPathBufferSize) 
{ 
    HRESULT hres; 
    IShellLink* psl; 
    WCHAR szGotPath[MAX_PATH]; 
    WCHAR szDescription[MAX_PATH]; 
    WIN32_FIND_DATA wfd; 
 
  
    // Get a pointer to the IShellLink interface. It is assumed that CoInitialize
    // has already been called. 
    hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); 
    if (SUCCEEDED(hres)) 
    { 
        IPersistFile* ppf; 
 
        // Get a pointer to the IPersistFile interface. 
        hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf); 
		
        if (SUCCEEDED(hres)) 
        { 
            WCHAR wsz[MAX_PATH]; 
 
            // Ensure that the string is Unicode. 
            MultiByteToWideChar(CP_ACP, 0, lpszLinkFile, -1, wsz, MAX_PATH); 
 
            // Add code here to check return value from MultiByteWideChar 
            // for success.
 
            // Load the shortcut. 
            hres = ppf->Load(wsz, STGM_READ); 
            
            if (SUCCEEDED(hres)) 
            { 
                // Resolve the link. 
                hres = psl->Resolve(hwnd, 0); 

                if (SUCCEEDED(hres)) 
                { 
                    // Get the path to the link target. 
                    hres = psl->GetPath(szGotPath, MAX_PATH, (WIN32_FIND_DATA*)&wfd, SLGP_SHORTPATH); 

                    if (SUCCEEDED(hres)) 
                    { 
                        // Get the description of the target. 
                        hres = psl->GetDescription(szDescription, MAX_PATH); 

                        if (SUCCEEDED(hres)) 
                        {
                            hres = StringCbCopy(lpszPath, iPathBufferSize, szGotPath);
                            if (SUCCEEDED(hres))
                            {
                                // Handle success
                            }
                            else
							{
                                // Handle the error
							}
                        }
                    }
                } 
            } 

            // Release the pointer to the IPersistFile interface. 
            ppf->Release(); 
        } 

        // Release the pointer to the IShellLink interface. 
        psl->Release(); 
    } 
    return hres; 
}


ResolveIt(this->m_hWnd,"d:\\Documents and Settings\\s.p\\Desktop\\2.lnk",_T("d:\\Documents and Settings\\s.p\\Desktop\\2.lnk"),1024);

"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)

"Your thoughts are the architects of your destiny."

GeneralRe: html string in .lnk file Pin
limelect25-May-11 0:44
limelect25-May-11 0:44 
GeneralRe: html string in .lnk file Pin
ShilpiP25-May-11 1:23
ShilpiP25-May-11 1:23 
GeneralRe: html string in .lnk file Pin
limelect25-May-11 2:36
limelect25-May-11 2:36 
GeneralRe: html string in .lnk file Pin
ShilpiP25-May-11 3:04
ShilpiP25-May-11 3:04 
GeneralRe: html string in .lnk file Pin
limelect25-May-11 3:23
limelect25-May-11 3:23 
GeneralRe: html string in .lnk file Pin
limelect25-May-11 5:12
limelect25-May-11 5:12 
GeneralRe: html string in .lnk file Pin
ShilpiP25-May-11 19:38
ShilpiP25-May-11 19:38 
GeneralRe: html string in .lnk file Pin
limelect25-May-11 19:47
limelect25-May-11 19:47 
GeneralRe: html string in .lnk file Pin
ShilpiP25-May-11 20:12
ShilpiP25-May-11 20:12 
GeneralRe: html string in .lnk file Pin
limelect25-May-11 20:20
limelect25-May-11 20:20 
GeneralRe: html string in .lnk file Pin
ShilpiP25-May-11 20:41
ShilpiP25-May-11 20:41 
GeneralRe: html string in .lnk file Pin
limelect25-May-11 21:41
limelect25-May-11 21:41 
GeneralRe: html string in .lnk file Pin
ShilpiP25-May-11 22:24
ShilpiP25-May-11 22:24 
AnswerRe: html string in .lnk file Pin
Richard MacCutchan23-May-11 23:12
mveRichard MacCutchan23-May-11 23:12 
GeneralRe: html string in .lnk file Pin
limelect24-May-11 20:40
limelect24-May-11 20:40 
GeneralRe: html string in .lnk file Pin
Richard MacCutchan24-May-11 23:21
mveRichard MacCutchan24-May-11 23:21 
GeneralRe: html string in .lnk file Pin
limelect25-May-11 0:19
limelect25-May-11 0:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.