in reply to Win32::GUI MessageBox
According to MSDN,
MB_SERVICE_NOTIFICATIONWindows NT/2000/XP: The caller is a service notifying the user of an event. The function displays a message box on the current active desktop, even if there is no user logged on to the computer.
If this flag is set, the hWnd parameter must be NULL. This is so that the message box can appear on a desktop other than the desktop corresponding to the hWnd.
As Win32::GUI doesn't allow the perl programmer access to that parameter, the only way to achieve your aim using it, would be to modify the package. Since there is no mention of "MessageBox" in any of the packages Perl sources, this would have to be a patch to the XS code.
However, you can get at the MessageBox() api through Win32::API(::Prototype), and passing MB_SERVICE_NOTIFICATION to that causes the messagebox to appear when logged (which your example doesn't), provided you pass 0 as the first parameter. The following code has been tested and works when the screensaver is in operation. I haven't tried it when logged out, but see no reason it wouldn't work.
#! perl -slw use strict; use Win32::API::Prototype; ApiLink( 'User32', q[ int MessageBox( HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, U +INT uType ) ] ) or die $^E; MessageBox( 0, 'Some Text', 'A title', 0x200000|0x001000|0x000030 ) or die $^E;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Win32::GUI MessageBox
by coldmiser (Hermit) on Oct 18, 2006 at 13:53 UTC | |
by BrowserUk (Patriarch) on Oct 18, 2006 at 15:12 UTC | |
by coldmiser (Hermit) on Oct 18, 2006 at 19:09 UTC |