According to MSDN,

MB_SERVICE_NOTIFICATION

Windows 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;

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Win32::GUI MessageBox by BrowserUk
in thread Win32::GUI MessageBox by coldmiser

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.