在windows下是C:\Documents and Settings\Administrator\
怎么得到对应的C:\Docume~1\ADMINI~1\?
用什么方法或者什么函数能做到?

解决方案 »

  1.   

    用Windows API函数,
    C 原型为DWORD GetShortPathName(
      LPCTSTR lpszLongPath,
      LPTSTR lpszShortPath,
      DWORD cchBuffer
    );
    ---------
    在Delphi中这样写var
     szSDir: array [0..1024] of char;
      ii: Integer;
    str2 : string;
    begin
      ii := SizeOf(szSDir);
      GetShortPathName(PChar(LongDirName), szSDir, ii);
      str2 := StrPas(szSDir);
    str2即为所要的DOS目录
    还有,记得Uses Windows 单元