#include <shlobj.h>Key Reference Classes Ishelllink:ishelllink The Main method:1, getarguments: Obtaining parameter information2, GetDescription: Obtaining Descriptive information3, GetHotKey: Get shortcut keys4, Geticonlocation: Get shortcut icon5, Getidlist: Gets the shortcut to the target object of item identifier list (each object in the Windows shell, such as files, directories, and printers, has a unique item Identifiler list)6, GetPath: The full path to the destination file or directory where the shortcut is obtained7, Getshowcmd: How to get shortcuts running, such as regular windows, maximizing8, Getworkingdirectory: Get working directory9, Resolve: Attempts to obtain a target object according to a certain search rule, even if the target object has been deleted or moved, renaming the parsing process:1, initializing COM interfaces2, creating a IShellLink object3, getting the IPersistFile object interface from the IShellLink object4, manipulating IShellLink objects5, releasing the IPersistFile object interface6, releasing the IShellLink object7, releasing the COM interface//parameter 1:lnk file path, Parameter 2: Return to the destination pathBOOLGetshellpath (Char *src,char *Shellpath) { BOOLblret=false; :: CoInitialize (NULL); //Initializing COM interfacesIShellLink *PSL =NULL; //Create a COM interface, IShellLink object creationHRESULT hr = CoCreateInstance (Clsid_shelllink, Null,clsctx_inproc_server,iid_ishelllink, (LPVOID *) &PSL); if(SUCCEEDED (HR)) {IPersistFile*PPF; HR=psl->queryinterface (Iid_ipersistfile, (lpvoid*) &PPF); if(SUCCEEDED (HR)) {WCHAR Wsz[max_path]= {0}; MultiByteToWideChar (CP_ACP,0, SRC,-1, Wsz, MAX_PATH);//turn down wide byteHr=ppf->load (Wsz, Stgm_read);//Loading Files if(SUCCEEDED (HR)) {win32_find_data wfd; PSL->getpath (Shellpath,max_path, (win32_find_data*) &wfd,slgp_shortpath);//Get target pathblret=true; } PPF-Release (); } PSL->release ();//Releasing Objects}:: CoUninitialize (); //Releasing COM interfaces returnBlret;}
VC How to get destination file path from shortcut