implementation
{$R *.dfm}
{
======================================================================
例子函數:
function GetWinDir: string; //C:\WINDOWS
var
dir: array [0..MAX_PATH] of Char;
begin
GetWindowsDirectory(dir, MAX_PATH); //假設特徵碼爲:GetWindowsDirectory
Result := StrPas(dir);
end;
快捷鍵: CTRL + 鼠標左鍵 代碼的轉跳
========================================================================
}
function GetWinDir: string; //C:\WINDOWS
var
dir: array [0..MAX_PATH] of Char;
TempGetWindowsDirectory : function (lpBuffer: PChar; uSize: UINT): UINT; stdcall;
begin
TempGetWindowsDirectory := GetProcAddress(LoadLibrary('kernel32'),'GetWindowsDirectoryA');
TempGetWindowsDirectory(dir, MAX_PATH); //假設特徵碼爲:GetWindowsDirectory
Result := StrPas(dir);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(GetWinDir);
end;
end.