Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Alias (5735)

Alias
  (email not shown publicly)
http://ali.as/

Journal of Alias (5735)

Friday June 05, 2009
10:40 AM

Padre Single Instance now correctly foregrounds on Win32

[ #39081 ]

Of course, I'm not at all proud of what I had to do to get there, but after around 20 minutes per line of code trawling through MSDN, I finally managed to find a combination that works.

The single instance server now immediately sends the PID on connect (leading space padded to specifically 10 bytes) and the the client does the following.

my $pid  = '';
my $read = $socket->sysread( $pid, 10 );
if ( defined $read and $read = 10 ) {
    # Got the single instance PID
    $pid =~ s/\s+\s//;
    if ( Padre::Util::WIN32 ) {
        require Win32::API;
        Win32::API->new(
            'User32.dll',
            'AllowSetForegroundWindow',
            'N', 'L',
        )->Call($pid);
    }
}

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.