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;
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;