Помогите азобраться, не выводится переменная в DLL Вот исходник DLLки которая не работает:
library hookDLL; uses Windows, Messages,Sysutils,Dialogs; var S:string; SysHookMsg: HHOOK = 0 ; H : THandle; procedure fff; begin ShowMessage(S); //Должно выводить чем стало 'S' в процедуре SendString end; procedure SendString(P:pchar); stdcall; export; begin S:=StrPas(P); end; function hook( Code: Integer; WParam: wParam; Msg: PCWPStruct): longint; stdcall; var h:hwnd; WindowName:array[0..MAX_PATH-1] of char; begin h:=0; result := CallNextHookEx( h, Code, WParam, Longint( Msg )); case Msg^.message of WM_PAINT: begin GetWindowText(Msg^.hwnd,@WindowName,MAX_PATH); if WindowName='искомое окно' then fff; end; end; End; procedure SetKeyHook; stdcall; export; begin if h=0 then H:= SetWindowsHookEx(WH_CALLWNDPROC, @hook, hInstance, 0); end; procedure DelKeyHook; stdcall; export; begin if SysHookMsg <> 0 then UnhookWindowsHookEx(SysHookMsg); end; exports SetKeyHook, DelKeyHook,SendString; Begin // S:='Загрузли Dll' end.
procedure TForm1.FormDestroy(Sender: TObject); begin DelKeyHook; end;
procedure TForm1.Button1Click(Sender: TObject); var S:string; begin S:='Эта строка должна появится когда откроется искомое окно'; SendString(pchar(S)); end;