使用函数启动的程序:ShellExecute(Handle,'…
1个回答
展开全部
不好意思,你给的答案是错的,因为有区别,所以你的答案就是错的。 解释: function runThisFile(fileName:widestring):Boolean; var vShellLink: IShellLink; vPersistFile: IPersistFile; vUnKnown: IUnKnown; vWin32FindData: TWin32FindData; vBuffer: array[0..MAX_PATH] of Char; vFileName: String; vFileExt : array[0..255] of Char; begin if length(fileName)<=0 then begin result:=false; exit; end; StrPCopy(vFileExt,ExtractFileExt(fileName)); if length(vFileExt)<=0 then begin result:=false; exit; end; if lowercase(vFileExt) = '.lnk' then begin try vUnKnown := CreateComObject(CLSID_ShellLink); vShellLink := vUnKnown as IShellLink; vPersistFile := vUnKnown as IPersistFile; vPersistFile.Load(PWChar(fileName), 0); vShellLink.GetPath(vBuffer, SizeOf(vBuffer), vWin32FindData, 0); if length(vBuffer)>0 then vFileName := vBuffer; ShowMessage(vBuffer); except end; end else begin vFileName := fileName; end; //vFileName即是真實文件地址 end; 或者可以這樣: ShellExecute(GetDesktopWindow,'Open',文件地址,nil,nil,SW_SHOWNORMAL); 或:Uses shellapi,shlobj,activex,comobj 出现错误提示,错误提示是:BEGIN expected but END found
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询