.lnk是什么文件?
windows的很多lnk文件(也就是快捷方式)都是带有参数的,但是自己并不真正了解,不知道有谁知道?自己通过实践摸索出一些,希望能给大家带来帮助:/play—在打开连接后自动运行媒体文件"%1"—打开连接后自动出现文件选取框选择文件/Play"%L"—打开winamp后自动出现List选择框选择文件播放列表______________________________________如何通过lnk文件获取该文件的执行路径和程序functionLinkFileInfo(constln):boolean; :=false;getmem(buf,MAX_PATH);tryifSU...全部
windows的很多lnk文件(也就是快捷方式)都是带有参数的,但是自己并不真正了解,不知道有谁知道?自己通过实践摸索出一些,希望能给大家带来帮助:/play—在打开连接后自动运行媒体文件"%1"—打开连接后自动出现文件选取框选择文件/Play"%L"—打开winamp后自动出现List选择框选择文件播放列表______________________________________如何通过lnk文件获取该文件的执行路径和程序functionLinkFileInfo(constln):boolean; :=false;getmem(buf,MAX_PATH);tryifSUCCEEDED(CoInitialize(nil))thenif(succeeded(cocreateinstance(clsid_shelllink,nil,clsctx_inproc_server,IID_IShellLinkA,psl)))thenbeginhr:=psl。
QueryInterface(iPersistFile,ppf);ifsucceeded(hr)thenbeginlpw:=stringtowidechar(lnkfilename,buf,MAX_PATH);hr:=ppf。
Load(lpw,STGM_READ);ifsucceeded(hr)thenbeginhr:=psl。Resolve(0,SLR_NO_UI);ifsucceeded(hr)thenbeginifbSetthenbeginpsl。
SetArguments(info。Arguments);psl。SetDescription(info。Description);psl。SetHotkey(info。HotKey);psl。
SetIconLocation(info。IconLocation,info。IconIndex);psl。SetIDList(info。ItemIDList);psl。SetPath(info。
FileName);psl。SetShowCmd(info。ShowState);psl。SetRelativePath(info。RelativePath,0);psl。SetWorkingDirectory(info。
WorkDirectory);ifsucceeded(psl。Resolve(0,SLR_UPDATE))thenresult:=true;endelsebeginpsl。GetPath(info。
FileName,MAX_PATH,wfd,SLGP_SHORTPATH);psl。GetIconLocation(info。IconLocation,MAX_PATH,info。IconIndex);psl。
GetWorkingDirectory(info。WorkDirectory,MAX_PATH);psl。GetDescription(info。Description,CCH_MAXNAME);psl。
GetArguments(info。Arguments,MAX_PATH);psl。GetHotkey(info。HotKey);psl。GetIDList(info。ItemIDList);psl。
GetShowCmd(info。ShowState);result:=true;end;end;end;end;end;finallyfreemem(buf);end;end;//*******************调用*****************showmessage(\'FileName:\'+info。
filename+#13+\'Description:\'+info。Description+#13+\'IconFilename:\'+info。IconLocation+\',\'+inttostr(info。
IconIndex)+#13+\'WordDir:\'+info。WorkDirectory+#13+\'Arguments:\'+info。Arguments+#13+\'ShorCuts:\'+shortcuttotext(s));info。
WorkDirectory:=\'D:\\Borland\\Delphi5\\projects\';linkfileinfo(opendialog1。filename,info,true);end;end;==============================================functionGetLinkFileName(sLin :string):boolean; :IPersistFile;hres, :TWin32FindData;pT :PWideChar;beginResult:=false;ifSUCCEEDED(CoInitialize(nil))thenbeginCoCreateInstance(CLSID_ShellLink,nil,CLSCTX_INPROC_SERVER,IID_IShellLinkA,psl);if(SUCCEEDED(hres))thenbeginhres:=psl。
QueryInterface(IID_IPersistFile,ppf);if(SUCCEEDED(hres))thenbeginnLen:=MultiByteToWideChar(CP_ACP,0,PChar(sLinkFileName),-1,pwLinkFileName,0);GetMem(pwLinkFileName,nLen);ZeroMemory(pwLinkFileName,nLen);MultiByteToWideChar(CP_ACP,0,PChar(sLinkFileName),-1,pwLinkFileName,nLen);ppf。
Load(pwLinkFileName,STGM_READ);GetMem(pTargetFile,MAX_PATH);ZeroMemory(pTargetFile,MAX_PATH);hres:=psl。
GetPath(pTargetFile,MAX_PATH,pfd,SLGP_UNCPRIORITY);if(SUCCEEDED(hres))thenbeginsTargetFileName:=StrPas(pTargetFile);Result:=true;end;FreeMem(pTargetFile);FreeMem(pwLinkFileName);end;end;end;end;。
收起