如何把路径变成dos风格的?(100分)

  • 主题发起人 主题发起人 darzui
  • 开始时间 开始时间
D

darzui

Unregistered / Unconfirmed
GUEST, unregistred user!
如:c:/program files 变成c:/progra~1
 
API 函数GetShortPathName:
The GetShortPathName function obtains the short path form of a specified input path.

DWORD GetShortPathName(

LPCTSTR lpszLongPath, // points to a null-terminated path string
LPTSTR lpszShortPath, // points to a buffer to receive the null-terminated short form of the path
DWORD cchBuffer // specifies the size of the buffer pointed to by lpszShortPath
);


Parameters

lpszLongPath

Points to a null-terminated path string. The function obtains the short form of this path.

lpszShortPath

Points to a buffer to receive the null-terminated short form of the path specified by lpszLongPath.

cchBuffer

Specifies the size, in characters, of the buffer pointed to by lpszShortPath.



 
delphi自带函数ExtractShortPathName
 
首部 function ExtractShortPathName(const FileName: string): string; $[SysUtils.pas
功能 返回参数的DOS路径
说明 ExtractShortPathName('C:/Program Files/Borland')='C:/PROGRA~1/BORLAND'
参考 function Windows.GetShortPathName
例子 Edit1.Text := ExtractShortPathName(Edit2.Text);
 
多人接受答案了。
 
后退
顶部