From: rpnoble <rp...@ib...> - 2008-06-13 23:30:10
|
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-tp17833771p17833771.html Sent from the perl-win32-gui-users mailing list archive at Nabble.com. |
From: Brian M. <bmi...@hu...> - 2008-06-14 01:47:25
|
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 -- bmi...@hu... 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 |
From: rpnoble <rp...@ib...> - 2008-06-14 13:39:20
|
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 -- bmi...@hu... > 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 > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > > -- View this message in context: http://www.nabble.com/detecting-a-second-version-of-my-app-tp17833771p17839562.html Sent from the perl-win32-gui-users mailing list archive at Nabble.com. |
From: Ilya B. <Ily...@so...> - 2008-06-14 12:05:44
|
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: per...@li... [mailto:per...@li...] On Behalf Of rpnoble Sent: Saturday, June 14, 2008 3:30 AM To: per...@li... 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 Per...@li... 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. ========================================================= |
From: rpnoble <rp...@ib...> - 2008-06-14 13:37:47
|
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: per...@li... > [mailto:per...@li...] On Behalf Of > rpnoble > Sent: Saturday, June 14, 2008 3:30 AM > To: per...@li... > 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 > Per...@li... > 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 > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > > -- View this message in context: http://www.nabble.com/detecting-a-second-version-of-my-app-tp17833771p17839551.html Sent from the perl-win32-gui-users mailing list archive at Nabble.com. |
From: Brian M. <bmi...@hu...> - 2008-06-15 14:12:28
|
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 -- bmi...@hu... 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 |