VC How to get destination file path from shortcut

Source: Internet
Author: User

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.