相对路径转化为绝对路径

请先添加 ComObj, ComConst引用,以下是实现代码。

function PathCombine(lpszDest: PChar; const lpszDir, lpszFile: PChar):PChar; stdcall; external 'shlwapi.dll' name 'PathCombineA';
function PathCombineA(lpszDest: PAnsiChar; const lpszDir, lpszFile:PAnsiChar): PAnsiChar; stdcall; external 'shlwapi.dll';
function PathCombineW(lpszDest: PWideChar; const lpszDir, lpszFile:PWideChar): PWideChar; stdcall; external 'shlwapi.dll';

 

function GetAbsolutePath (BasePath, RelativePath:string):string;
var
  Dest:array [0..MAX_PATH] of char;
begin
  FillChar(Dest,MAX_PATH+1,0);
  PathCombine(Dest,PChar(BasePath), PChar(RelativePath));
  Result:=string(Dest);
end;

你可能感兴趣的:(相对路径)