function GetApplicationDir: string; var hModule:THandle; buf:array [0..MAX_PATH] of char; hlpd:string; begin hModule:=GetModuleHandle(nil); GetModuleFileName(hmodule,buf,sizeof(buf)); hlpd:=string(PChar(ExtractFileDir(buf))); if hlpd[Length(hlpd)]='\' then Result:=hlpd else Result:=hlpd+'\'; end;
var sPath : string; begin sPath := ExtractFilePath(application.Exename); showmessage(sPath); //你会看到spath中存放的是你程序所在目录的路径 end;
result := strTmp;
setcurrentdir()
ExtractFilePath(paramstr(0))
var
hModule:THandle;
buf:array [0..MAX_PATH] of char;
hlpd:string;
begin
hModule:=GetModuleHandle(nil);
GetModuleFileName(hmodule,buf,sizeof(buf));
hlpd:=string(PChar(ExtractFileDir(buf)));
if hlpd[Length(hlpd)]='\' then
Result:=hlpd
else
Result:=hlpd+'\';
end;
sPath : string;
begin
sPath := ExtractFilePath(application.Exename);
showmessage(sPath); //你会看到spath中存放的是你程序所在目录的路径
end;