Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Sfpiano

IPersistFile->Load()

This topic is 5365 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

IShellLink* dsktopLnk;
	char pszLoc[MAX_PATH];
	WIN32_FIND_DATA pfd;
	HRESULT hResult;
	hWnd = ::GetDesktopWindow();

	CoInitialize(NULL);

	// Get a pointer to the IShellLink interface. 
    hResult = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, 
                            IID_IShellLink, (LPVOID*)&dsktopLnk);

	if(SUCCEEDED(hResult)){
		IPersistFile* ipf;
		// Get a pointer to the IPersistFile interface. 
        hResult = dsktopLnk->QueryInterface(IID_IPersistFile, (void**)&ipf); 

		if(SUCCEEDED(hResult)){

			WCHAR wsz[MAX_PATH]; 
			char lpszLinkFile[MAX_PATH];
			lstrcpy(lpszLinkFile, "C:\\Documents and Settings\\All Users\\Desktop");
            // Ensure that the string is Unicode. 
            MultiByteToWideChar(CP_ACP, 0, lpszLinkFile, -1, wsz, MAX_PATH); 
            // Load the shortcut. 
///////HERE///////////
            hResult = ipf->Load(wsz, STGM_WRITE);
///////END HERE///////
			if(SUCCEEDED(hResult)){
				hResult = dsktopLnk->Resolve(hWnd, 0);
				if(SUCCEEDED(hResult)){
					dsktopLnk->GetPath(pszLoc, MAX_PATH, (WIN32_FIND_DATA*)&pfd, NULL);

					MessageBox(NULL, pszLoc, "SDFL", NULL);
				}
			}
		}
		ipf->Release();
	}
	dsktopLnk->Release();	
	CoUninitialize();
 
Everything works fine until the Load() call. The really odd thing is is doesn''t return S_OK, E_FAIL, or E_OUTOFMEMORY, it returns -2147024891. //------------------------------------------------------------------------------------------------------ The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you''re the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!