function GetExePath: string; begin Result := ExtractFilePath(ParamStr(0)); end; function GetTempFileName: string; var vPath: string; begin SetLength(Result, 255); GetTempFileName(PChar(GetExePath), PChar('~'), 0, PChar(result)); vPath := GetExePath + 'temp'; if not SysUtils.DirectoryExists(vPath) then SysUtils.ForceDirectories(vPath); result := PChar(Result); //去掉多余的空字符 Result := vPath + ExtractFileName(Result); end;
http://blog.csdn.net/shuaihj/article/details/7108792