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);
}
}
Ummmm... (Score:1)
Pretty please tell me you /really/ used '==' and not '=' in that 'if' statement.
Re: (Score:1)
Unfortunately, not.
http://padre.perlide.org/changeset?new=5092%40trunk&old=5091%40trunk [perlide.org]
But it's only on svn at the moment, not released, so it should be easy for a committer to add the character.
The new Strawberry Perl for Windows has been released! Check http://strawberryperl.com for it.
Re: (Score:2)
Re: (Score:1)
I gotta say, one of my favourite things about the Padre development team is that I can add a bug to Padre before I go to bed and there's a good chance that by the time I wake up, it's gone. :)
Re: (Score:1)
oopsi