function ShowMessage(const Msg: string): Integer;
begin
Result:=MessageBox(0, PChar(Msg), 'ShowMessage', MB_OKCANCEL or MB_ICONINFORMATION);
end;
type
TShowMessage = function(const Msg: string): Integer;
var
p: Cardinal;
f: TShowMessage;
begin
p:=Cardinal(@ShowMessage); (* получим адрес функции ShowMessage *)
Caption:=IntToStr(p); (* дабы убедиться что это обычное целое число *)
@f:=Pointer(p); (* дабавим маны *)
f('Ok'); (* собственно вызываем функцию с параметром *)
end;
вариант 2
Код:
type
TF = function (hWnd: HWND; lpText, lpCaption: PWideChar; uType: UINT): Integer; stdcall;
var
h: HMODULE;
f: TF;
begin
h:=LoadLibrary('user32.dll');
@f:=GetProcAddress(h, 'MessageBoxW');
f(Handle, 'Ok', 'MessageBoxW', MB_OK or MB_ICONQUESTION);
end;
__________________
Пишу программы за еду.
__________________