procedure TForm.GetAppDir(var AppDir: string); var hModule:THandle; buf:array [0..MAX_PATH-1] of char; begin hModule:=GetModuleHandle(nil); GetModuleFileName(hmodule,buf,sizeof(buf)); AppDir:=buf; end;
function TForm1.PathExeDir: string; var FileName:string; begin FileName:=application.GetNamePath; Result := ExtractFilePath(ParamStr(0)) + FileName; end; procedure TForm1.Button2Click(Sender: TObject); begin edit1.Text:= PathExeDir; end;
var
hModule:THandle;
buf:array [0..MAX_PATH-1] of char;
begin
hModule:=GetModuleHandle(nil);
GetModuleFileName(hmodule,buf,sizeof(buf));
AppDir:=buf;
end;
var FileName:string;
begin
FileName:=application.GetNamePath;
Result := ExtractFilePath(ParamStr(0)) + FileName;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:= PathExeDir;
end;
ExtractFilePath(ParamStr(0))————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
path,bpath:string;
begin
getdir(0,bpath);
path:=bpath+'\HELP.hlp';
getdir(0,bpath);bpath变量中存的就是路径!