Go homepage(回首页) Upload pictures (上传图片) Write articles (发文字帖)
The author:(作者)aaapublished in(发表于) 2014/7/19 0:13:13 delphi获取Windows目录
获取Windows 目录要获取Windows 目录的位置可以调用Win32 的GetWindowsDirectory() 。该函数类似于GetSystemDirectory(),其返回值的含义也与GetSystemDirectory()相同。该函数的用法如下:procedure TForm1.Button1Click(Sender: TObject);varMyWinPath:String;beginSetLength(MyWinPath,144);if GetWindowsDirectory(PChar(MyWinPath),144)<>0 thenbeginSetLength(MyWinPath,Length(PChar(MyWinPath)));Edit1.Text:=MyWinPath;endelseRaiseLastWin32Error;end;如果函数调用成功,GetWindowsDirectory()返回目录路径的长度(整数值),否则返回0,表明有错误产生。这时可以调用RaiseLastWin32Error()来分析产生错误的原因。
赞