<h4>紧急提问:有没有哪个API函数可以返回当前程序可执行文件所在目录的全路径?</h4>(200分)

Searchpath
 
GetCurrentDirectory函数返回当前进程当前所在的目录 <br>DWORD GetCurrentDirectory(<br><br>&nbsp; &nbsp; DWORD nBufferLength, // 目录缓存大小(字符数) <br>&nbsp; &nbsp; LPTSTR lpBuffer // 当前目录地址缓存 <br>&nbsp; &nbsp;); <br>&nbsp;<br><br>参数<br>nBufferLength<br>指定当前目录缓存的长度(字符数)。<br><br>lpBuffer<br>当前目录字符串缓存指针。此字符串指出当前目录的绝对路径。 <br><br>返回值<br>函数操作成功,返回值为写入缓存的字符数目,不包括表示结束的空字符。<br>
 
当前所在的目录 不一定是 程序可执行文件所在目录,比如在桌面快捷方式的情况下。
 
ExtractFilePath(Application.ExeName)返回当前程序可执行文件所在目录的全路径<br>
 
非要用 API 吗?那么请看看“GetFullPathName()”的帮助!<br><br>Delphi自己有这样的函数“extractfilepath()”,看看帮助!<br><br>提示:先用“application.exename”(好像是这个属性,请大家指正)<br>&nbsp; &nbsp; &nbsp; 得到当前程序可执行文件的文件名!
 
ExtractFilePath(Application.ExeName)
 
GetCurrentDir();
 
ExtractFilePath(Application.ExeName)<br>
 
ExtractFilePath(ParamStr(0))
 
非要用API?ParamStr(0)不好吗?前面套个ExtractFileDir或ExtractFilePath很好用。
 
要是在VC里就用api:<br>DWORD SearchPath(<br>&nbsp; &nbsp; LPCTSTR &nbsp;lpszPath, // address of search path <br>&nbsp; &nbsp; LPCTSTR &nbsp;lpszFile, // address of filename <br>&nbsp; &nbsp; LPCTSTR &nbsp;lpszExtension, // address of extension <br>&nbsp; &nbsp; DWORD &nbsp;cchReturnBuffer, // size, in characters, of buffer <br>&nbsp; &nbsp; LPTSTR &nbsp;lpszReturnBuffer, // address of buffer for found filename <br>&nbsp; &nbsp; LPTSTR &nbsp;*plpszFilePart // address of pointer to file component <br>&nbsp; &nbsp;); <br>其实在 pascal里,ExtractFilePath最合适<br>
 
这么多手。我抻一下吧。
 
来晚了!<br>ExtractFilePath(Application.ExeName)
 
同意 wind2000
 
我也来晚了<br>ExtractFilePath(Application.ExeName);//得到应用程序的路径<br>
 
ExtractFilePath(Application.ExeName);
 
这样也可以:extractfilepath(paramstr(0)); // :p<br>
 
这样也可以:extractfilepath(paramstr(0)); // :p<br>
 
ExtractFilePath(Application.ExeName);<br>即可
 
顶部