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.
转载于:https://blog.51cto.com/zxw713/815591