有時(shí),我們?cè)诰帉慞B應(yīng)用程序時(shí),想獲得當(dāng)前應(yīng)用程序的路徑,我們可以借助API函數(shù)來實(shí)現(xiàn),下面是具體的實(shí)現(xiàn)源代碼。
//如何獲得當(dāng)前應(yīng)用程序的路徑
FUNCTION unit getmodulefilenamea(ulong hmodule,ref string lpfilename,ulong nsize)library "kernel32.dll"
string ls_buffer=space(255)
int i
if getmodulefilenamea(handle(getapplication()),ls_buffer,255)=0 then
setnull(ls_buffer)
else
do while pos(ls_buffer,"/",i+1)>0
i=pos(ls_buffer,"/",i+1)
loop
ls_buffer=left(ls_buffer,i)
if right(ls_buffer,1)<>"/" then ls_buffer=ls_buffer+"/"
end if
return ls_buffer
新聞熱點(diǎn)
疑難解答
圖片精選