detecting a second version of my app

View: New views
6 Messages — Rating Filter:   Alert me  

detecting a second version of my app

by rpnoble :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

How can i detect a 2nd launch of my application, popup an error message and then exit?

Re: detecting a second version of my app

by Brian Millham-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

rpnoble wrote:
> How can i detect a 2nd launch of my application, popup an error message and
> then exit?
>  
Look at the Win32::Mutex module. You register your app when it starts,
and check if it's already running.

If you need, I can give you some sample code.

--
Brian, Tommy, Helen and Paka -- bmillham@...
This message traveled at least 44,000 miles to reach you!



---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 080613-1, 06/13/2008
Tested on: 6/13/2008 9:46:47 PM
avast! is copyright (c) 2000-2008 ALWIL Software.
http://www.avast.com




-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@...
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Re: detecting a second version of my app

by Ilya BANDORIN :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If your running application has at least one window which is defined on
startup and never gets destroyed, you can do a simple check. The example
below assumes that your window has title "BLAH-BLAH-BLAH":

my $CheckAlreadyRun = Win32::GUI::FindWindow('', 'BLAH-BLAH-BLAH');
if ($CheckAlreadyRun) {
        Win32::GUI::Show($CheckAlreadyRun);
        Win32::GUI::SetForegroundWindow($CheckAlreadyRun);
        exit;
}

In my example it just shows the window which is already exists. But you
can do and error popup or whatever.



Regards,
_____
Ilya Bandorin

-----Original Message-----
From: perl-win32-gui-users-bounces@...
[mailto:perl-win32-gui-users-bounces@...] On Behalf Of
rpnoble
Sent: Saturday, June 14, 2008 3:30 AM
To: perl-win32-gui-users@...
Subject: [perl-win32-gui-users] detecting a second version of my app


How can i detect a 2nd launch of my application, popup an error message
and
then exit?
--
View this message in context:
http://www.nabble.com/detecting-a-second-version-of-my-app-tp17833771p17
833771.html
Sent from the perl-win32-gui-users mailing list archive at Nabble.com.


------------------------------------------------------------------------
-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@...
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

=========================================================

Ce message et toutes les pieces jointes (ci-apres le "message")
sont confidentiels et susceptibles de contenir des informations
couvertes par le secret professionnel. Ce message est etabli
a l'intention exclusive de ses destinataires. Toute utilisation
ou diffusion non autorisee interdite.
Tout message eletronique est susceptible d'alteration. La SOCIETE GENERALE
et ses filiales declinent toute responsabilite au titre de ce message
s'il a ete altere, deforme falsifie.

=========================================================

This message and any attachments (the "message") are confidential,
intended solely for the addressees, and may contain legally privilegedxi
information. Any unauthorised use or dissemination is prohibited.
E-mails are susceptible to alteration. Neither SOCIETE GENERALE nor any
of its subsidiaries or affiliates shall be liable for the message
if altered, changed or falsified.

=========================================================

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@...
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Re: detecting a second version of my app

by rpnoble :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Ilya;

I did not even think of that. I give it a try later today.

Ilya BANDORIN wrote:
If your running application has at least one window which is defined on
startup and never gets destroyed, you can do a simple check. The example
below assumes that your window has title "BLAH-BLAH-BLAH":

my $CheckAlreadyRun = Win32::GUI::FindWindow('', 'BLAH-BLAH-BLAH');
if ($CheckAlreadyRun) {
        Win32::GUI::Show($CheckAlreadyRun);
        Win32::GUI::SetForegroundWindow($CheckAlreadyRun);
        exit;
}

In my example it just shows the window which is already exists. But you
can do and error popup or whatever.



Regards,
_____
Ilya Bandorin

-----Original Message-----
From: perl-win32-gui-users-bounces@lists.sourceforge.net
[mailto:perl-win32-gui-users-bounces@lists.sourceforge.net] On Behalf Of
rpnoble
Sent: Saturday, June 14, 2008 3:30 AM
To: perl-win32-gui-users@lists.sourceforge.net
Subject: [perl-win32-gui-users] detecting a second version of my app


How can i detect a 2nd launch of my application, popup an error message
and
then exit?
--
View this message in context:
http://www.nabble.com/detecting-a-second-version-of-my-app-tp17833771p17
833771.html
Sent from the perl-win32-gui-users mailing list archive at Nabble.com.


------------------------------------------------------------------------
-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

=========================================================

Ce message et toutes les pieces jointes (ci-apres le "message")
sont confidentiels et susceptibles de contenir des informations
couvertes par le secret professionnel. Ce message est etabli
a l'intention exclusive de ses destinataires. Toute utilisation
ou diffusion non autorisee interdite.
Tout message eletronique est susceptible d'alteration. La SOCIETE GENERALE
et ses filiales declinent toute responsabilite au titre de ce message
s'il a ete altere, deforme falsifie.

=========================================================

This message and any attachments (the "message") are confidential,
intended solely for the addressees, and may contain legally privilegedxi
information. Any unauthorised use or dissemination is prohibited.
E-mails are susceptible to alteration. Neither SOCIETE GENERALE nor any
of its subsidiaries or affiliates shall be liable for the message
if altered, changed or falsified.

=========================================================

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Re: detecting a second version of my app

by rpnoble :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the reply Brian. I think I'll try Ilya's method first.

Brian Millham-2 wrote:
rpnoble wrote:
> How can i detect a 2nd launch of my application, popup an error message and
> then exit?
>  
Look at the Win32::Mutex module. You register your app when it starts,
and check if it's already running.

If you need, I can give you some sample code.

--
Brian, Tommy, Helen and Paka -- bmillham@hughes.net
This message traveled at least 44,000 miles to reach you!



---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 080613-1, 06/13/2008
Tested on: 6/13/2008 9:46:47 PM
avast! is copyright (c) 2000-2008 ALWIL Software.
http://www.avast.com




-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Re: detecting a second version of my app

by Brian Millham-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

rpnoble wrote:
> How can i detect a 2nd launch of my application, popup an error message and
> then exit?
>  
Here's a sample of how to use a mutex. A mutex is better than Ilyn's
example if your wondows title may change (if you change the title to
show the currently open document, status, etc.)

use strict;
use warnings;

use Win32::Mutex;

# Create or open the mutex
my $mutex = Win32::Mutex->new(1, "Mutex Test");

# Die if the mutex exists (183 == ERROR_ALREADY_EXISTS)
die "App is already running" if $^E == 183;

# Do something here
print "Sleeping...\n";
sleep(30);

# We're done, release the mutex
$mutex->release;

--
Brian, Tommy, Helen and Paka -- bmillham@...
This message traveled at least 44,000 miles to reach you!



---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 080615-0, 06/15/2008
Tested on: 6/15/2008 10:10:48 AM
avast! is copyright (c) 2000-2008 ALWIL Software.
http://www.avast.com




-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@...
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/
LightInTheBox - Buy quality products at wholesale price