函數常規動態調用

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.
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章