Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)aaa
published in(发表于) 2014/7/19 0:13:13
delphi获取Windows目录

delphi获取Windows目录|GetSystemDirectory函数

获取Windows 目录

要获取Windows 目录的位置可以调用Win32 的GetWindowsDirectory() 。该函数类似于GetSystemDirectory(),其返回值的含义也与GetSystemDirectory()相同。该函数的用法如下:

procedure TForm1.Button1Click(Sender: TObject);

var

MyWinPath:String;

begin

SetLength(MyWinPath,144);

if GetWindowsDirectory(PChar(MyWinPath),144)<>0 then

begin

SetLength(MyWinPath,Length(PChar(MyWinPath)));

Edit1.Text:=MyWinPath;

end

else

RaiseLastWin32Error;

end;

如果函数调用成功,GetWindowsDirectory()返回目录路径的长度(整数值),否则返回0,表明有错误产生。这时可以调用RaiseLastWin32Error()来分析产生错误的原因。




If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759