GetFullPathName这个函数可以满足需要。MSDN中也要对此的说明,MSDN中说明如下:Multithreaded applications and shared library code should not use theGetFullPathName function and should avoid using relative path names.(多线程应用和共享库不能够使用GetFullPathName函数,GetFullPathName函数可以使用一个相对路径名称。)。 GetFullPathName 函数声明如下:
GetFullPathName(
__in LPCSTR lpFileName,
__in DWORD nBufferLength,
__out_ecount_part_opt(nBufferLength, return + 1) LPSTR lpBuffer,
__deref_opt_out LPSTR *lpFilePart
);
lpFileName为文件名称,可以是一个相对路径 + 文件名称;nBufferLength,是用来存储获得的全路径的缓冲区大小;lpBuffer是缓冲区保存全路径,lpFilePart如果提供的是目录,则此参数输出为空。