Registriert seit: 13. Apr 2010
7 Beiträge
|
Re: MessageBox mit timeout in einer Windows Notify DLL
13. Apr 2010, 11:12
So hab jetzt beide Methoden so hinbekommen das der Compiler durchläuft, wenn ich die DLLs der Methoden nun einbinde in den Logon process dann bekomme ich eine MSG BOX mit "Test1" oder "Test2" und danach muss die dll irgendeinen Fehler machen weil die RDP verbindung abreist.
Wenn ich die DLLs lokal bei mir unter Windows 7 starte mit: "rundll32 Project2.dll,ServerWallLogon" oder "rundll32 Project1.dll,ServerWallLogon" dann bekomme ich die Info Meldung "Test1" oder "Test2" und dann die Windows Meldung "Windows-Hostprozess (Rundll32) funktioniert nicht mehr".
Hier nochmal der letzte Code beider Methoden:
Methode1 (Projekt1)
Delphi-Quellcode:
library Project1;
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls,
Registry,
ShellApi,
Unit2 in 'Unit2.pas';
{$R *.res}
type
PFNMSGECALLBACK = function (bVerbose: BOOL; lpMessage: PWideChar):
DWORD; stdcall;
{$EXTERNALSYM PFNMSGECALLBACK}
TFnMsgeCallback = PFNMSGECALLBACK;
PWLX_NOTIFICATION_INFO = ^WLX_NOTIFICATION_INFO;
{$EXTERNALSYM PWLX_NOTIFICATION_INFO}
_WLX_NOTIFICATION_INFO = record
Size: ULONG;
Flags: ULONG;
UserName: PWideChar;
Domain: PWideChar;
WindowStation: PWideChar;
hToken: THandle;
hDesktop: HDESK;
pStatusCallback: PFNMSGECALLBACK;
end;
{$EXTERNALSYM _WLX_NOTIFICATION_INFO}
WLX_NOTIFICATION_INFO = _WLX_NOTIFICATION_INFO;
{$EXTERNALSYM WLX_NOTIFICATION_INFO}
TWlxNotificationInfo = WLX_NOTIFICATION_INFO;
PWlxNotificationInfo = PWLX_NOTIFICATION_INFO;
var MessageForm:TForm2;
procedure ServerWallLogon(pInfo: PWLX_NOTIFICATION_INFO); stdcall;
begin
ShowMessage('test1');
MessageForm:=TForm2.Create(nil);
Messageform.Label1.Caption:='Meine Meldung';
Messageform.Show;
end;
exports
ServerWallLogon;
begin
end.
Unit2 der Methode 1
Delphi-Quellcode:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm2 = class(TForm)
Label1: TLabel;
Timer1: TTimer;
Button1: TButton; //enabled auf false
procedure Timer1Timer(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
//{$R *.dfm}
procedure TForm2.Timer1Timer(Sender: TObject);
begin
close;
end;
procedure TForm2.FormShow(Sender: TObject);
begin
timer1.Enabled:=true;
end;
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
close;
end;
end.
Methode2 (Projekt2)
Delphi-Quellcode:
library Project2;
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls,
Registry,
ShellApi,
MpuWinNT in 'MpuWinNT.pas';
{$R *.res}
type
PFNMSGECALLBACK = function (bVerbose: BOOL; lpMessage: PWideChar):
DWORD; stdcall;
{$EXTERNALSYM PFNMSGECALLBACK}
TFnMsgeCallback = PFNMSGECALLBACK;
PWLX_NOTIFICATION_INFO = ^WLX_NOTIFICATION_INFO;
{$EXTERNALSYM PWLX_NOTIFICATION_INFO}
_WLX_NOTIFICATION_INFO = record
Size: ULONG;
Flags: ULONG;
UserName: PWideChar;
Domain: PWideChar;
WindowStation: PWideChar;
hToken: THandle;
hDesktop: HDESK;
pStatusCallback: PFNMSGECALLBACK;
end;
{$EXTERNALSYM _WLX_NOTIFICATION_INFO}
WLX_NOTIFICATION_INFO = _WLX_NOTIFICATION_INFO;
{$EXTERNALSYM WLX_NOTIFICATION_INFO}
TWlxNotificationInfo = WLX_NOTIFICATION_INFO;
PWlxNotificationInfo = PWLX_NOTIFICATION_INFO;
function MessageBoxTimeOut(hWnd: HWND; lpText: PChar; lpCaption: PChar; uType: UINT;
wLanguageId: WORD; dwMilliseconds: DWORD): Integer; stdcall;
external user32 name 'MessageBoxTimeoutA'
function MessageBoxTimeOutA(hWnd: HWND; lpText: PChar; lpCaption: PChar; uType: UINT;
wLanguageId: WORD; dwMilliseconds: DWORD): Integer; stdcall;
external user32 name 'MessageBoxTimeoutA'
function MessageBoxTimeOutW(hWnd: HWND; lpText: PWideChar; lpCaption: PWideChar; uType: UINT;
wLanguageId: WORD; dwMilliseconds: DWORD): Integer; stdcall;
external user32 name 'MessageBoxTimeoutW'
var
ret : DWORD;
s : string;
const
MB_TIMEDOUT = 32000;
procedure ServerWallLogon(pInfo: PWLX_NOTIFICATION_INFO); stdcall;
begin
ShowMessage('test2');
ret := MessageBoxTimeOut(NULL, 'Diese MessageBox schließt sich in 3 Sekunden', 'MessageBoxTimeOut', MB_OKCANCEL or MB_ICONINFORMATION, 0, 3000);
case ret of
IDOK: s := 'OK';
IDCANCEL: s := 'Cancel';
MB_TIMEDOUT: s := 'TimedOut';
end;
ShowMessage(s);
end;
exports
ServerWallLogon;
begin
end.
|