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 |