关于路径的问题!请斑竹速回答~(100分)

  • 主题发起人 主题发起人 sese
  • 开始时间 开始时间
S

sese

Unregistered / Unconfirmed
GUEST, unregistred user!
ShellExecute(handle,ExtractFilePath(Application.Exename)+'/htcp.chm','-s','',SW_MAXIMIZE)   为什么出错?相对路径不可以用在这里吗?请斑竹速回答~
 
ShellExecute('Open', ExtractFilePath(Application.Exename)+'/htcp.chm','-s','', SW_MAXIMIZE)  
 
应该用ExtractFileDir,最后才不会有两个“//”出现。<br>ShellExecute('Open', ExtractFileDir(Application.Exename)+'/htcp.chm','-s','', SW_MAXIMIZE) &nbsp; <br>或者这样应该也可以:<br>ShellExecute('Open', ExtractFilePath(Application.Exename)+'htcp.chm','-s','', SW_MAXIMIZE) &nbsp; <br>
 
建议用showmessage显示一下得出的路径后面是否已经包含了'/'
 
关于ShellExecute函数:<br>&nbsp; &nbsp; 在ShellAPI单元中,ShellExecute函数的定义为:<br><br>function ShellExecute(hWnd: HWND; Operation, FileName, Parameters,<br>&nbsp; Directory: PChar; ShowCmd: Integer): HINST; stdcall;<br><br>作用:打开或打印一个指定的文件;<br>参数说明:<br>&nbsp; &nbsp; hWnd hwnd, &nbsp; &nbsp; &nbsp; &nbsp;//指向父窗口的句柄;<br>&nbsp; &nbsp; Operation: PChar, //指向一个null结尾的串以指明要执行的操作;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 可以是"open","print","explore",NULL;<br>&nbsp; &nbsp; FileName: PChar, &nbsp; &nbsp;//指向文件名或文件夹名串;<br>&nbsp; &nbsp; Parameters: PChar, //指向一个null结尾的串以指明可执行文件的参数;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 如果FileName参数为文档,此参数应为NULL;<br>&nbsp; &nbsp; Directory: PChar, //指向一个null结尾的串以指明默认目录;<br>&nbsp; &nbsp; ShowCmd: Integer &nbsp; &nbsp;//文件在打开时是否显示;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 如果FileName参数为文档,此参数应为0;<br><br>&nbsp; &nbsp; ExtractFilePath函数的返值已经包含了'/',因此题目中ShellExecute函数<br>的正确写法应是:<br><br>ShellExecute(handle,'open',ExtractFilePath(Application.Exename)+'htcp.chm',<br>&nbsp; '-s','',SW_MAXIMIZE);<br>
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
775
import
I
后退
顶部