代码
uses
Shlobj;
const
CSIDL_COMMON_APPDATA = $0023; // DELPHI7中Shlobj单元未定义,DELPHI2007包含了定义
// 不知传递路径的参数值,可以查询 http://baike.baidu.com/view/3143145.htm
var
Str: string;
MChar: array[0..250] of char;
begin
SHGetSpecialFolderPath(0, MChar, CSIDL_COMMON_APPDATA, False);
ShowMessage(MChar);
end;
Shlobj;
const
CSIDL_COMMON_APPDATA = $0023; // DELPHI7中Shlobj单元未定义,DELPHI2007包含了定义
// 不知传递路径的参数值,可以查询 http://baike.baidu.com/view/3143145.htm
var
Str: string;
MChar: array[0..250] of char;
begin
SHGetSpecialFolderPath(0, MChar, CSIDL_COMMON_APPDATA, False);
ShowMessage(MChar);
end;
获取当前用户路径
function GetCurrentUsrDeskPath: string;
begin
SetLength(Result, MAX_PATH);
ExpandEnvironmentStrings(PAnsiChar('%UserProfile%'), PAnsiChar(Result), MAX_PATH);
end;
begin
SetLength(Result, MAX_PATH);
ExpandEnvironmentStrings(PAnsiChar('%UserProfile%'), PAnsiChar(Result), MAX_PATH);
end;