08-01-2011، 07:40 PM
یک تابع برای گرفتن دایرکتوری سیستم عامل:
کد:
procedure TForm1.Button5Click(Sender: TObject);
function GetSystemDirectory : String;
var
pcSystemDirectory : PChar;
dwSDSize : DWORD;
begin
dwSDSize := MAX_PATH + 1;
GetMem( pcSystemDirectory, dwSDSize );
try
if Windows.GetSystemDirectory( pcSystemDirectory, dwSDSize ) <> 0 then
Result := pcSystemDirectory;
finally
FreeMem( pcSystemDirectory );
end;
end;
begin
Label1.Caption:=GetSystemDirectory;
end;