Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A New Twist On Is App Running
Message
From
31/05/2007 06:12:35
 
 
To
31/05/2007 05:13:19
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00409058
Message ID:
01229522
Views:
19
Oh, I think I understand. The program needs to keep the handle open during the lifetime of the program and only release it on exit. This is what I have misunderstood. Let me try that and get back to you. Thanks again.



>>>Just a reminder, I'm running Windows Vista Business for this test.
>
>I don't have it, so I can't test this on that platform. But I don't think that is the problem, I think this should still work.
>
>>>In respect of a code sample, I am using the
>>>exact code as per Ed's original post below. No change.
>
>Eds code has a =CloseHandle(nEH) at the end and no wait mechanism in it to keep the code running (it closes the event and exits immediately) so, if you are really running it EXACTLY as he posted it then your results are correct because the first program has already terminated and the event has been closed, before the second copy was ever run.
>
>The fact that both instances returned the same handle tends to indicate that the handle was released by the first app. If it wasn't released then it wouldn't be available for the second app to use. They should both return different handles when this is working.
>
>My code was an adjustment to Eds code that I made solely for testing from the command window. It will print "Error I was allowed to Execute" to the screen if Eds code fails.
>
>If you have done something to pause the first program so that it stays running while you execute the second copy and you still get the second app being allowed to run.
>
>Try:
>
>nEH = CreateEvent(0,0,1, 'Global\' + PROGRAM(0) + '.EVENT')
>
>Maybe the changed the default for that in Windows Vista?
>
>John
>
>>Hi John.
>>
>>Thanks for the reply. If I use:
>>
>>
>>nEH = CreateEvent(0,0,1, CHRTRAN(_VFP.ServerName + '.EVENT',"\","_"))
>>
>>
>>I get a non-zero handle number and geterror() = 0. When I load the second instance of the app I get the same handle number and geterror() still returns 0. Hence both apps load.
>>
>>In respect of a code sample, I am using the exact code as per Ed's original post below. No change. If I use PROGRAM(0) same thing. For both instances that I load of the exe I get the same PROGRAM(0) (my start program), I get the same handle for both, and no error. Therefore the line:
>>
>>
>>
>>IF GetLastError() = 183 OR lnEH = 0
>>
>>
>>does not result in .T. There is no error and I get a non-zero handle.
>>
>>Just a reminder, I'm running Windows Vista Business for this test.
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Previous
Reply
Map
View

Click here to load this message in the networking platform