On 10/31/07, Ken Dibble <[EMAIL PROTECTED]> wrote: > > > > 1. My application creates a semaphore .txt file in either the \WINNT > > > folder > > > or \Windows folder, depending on which the OS uses. > > > >Oooh, that's bad :-) This will never have worked properly on any > >version of Windows NT... Also this won't work with terminal services > >as you can have multiple users connected at the same time. > > I'm not sure what you mean. It works fine on Win 2000 and XP. Win 2000 has > the \WINNT folder just like Win NT. XP uses the NT kernel. File is created > where I expect it to be; an attempt to run a second instance encounters the > file and shuts itself down as expected; file is deleted properly as long as > the application shuts down in a reasonably orderly way.
Joe user doesn't have read/write access to the Windows folder on Windows NT. IIRC you need to be a Power User or similar. As others have pointed out Windows is not necessarily installed on C:\ nor does it even need to be called WINNT or WINDOWS. Pre XP Boot.ini controlled the Windows folder but I think this changed with Vista. > I don't let people install this on the server and run it from there, if > that's what you're getting at, nor is it intended to run as a Terminal > Server application. > > >There are Windows API functions to create semaphores. I have some > >sample code at work that I'll post tomorrow. If it's any consolation > >we used to write a semaphore file to the root of C: :-) > > Yeah, changing the code to just write it to C:\ is probably the way to go, > actually. I just wanted to be able to write it to some standard location > that would be known to exist and which a second attempted instance could > check without knowing anything about the first instance. Access to the root folder of any (fixed?) drive won't work on Vista I'm afraid, which is the reason we moved to using Windows Mutexes. Basically you need to call CreateMutex(). If it returns ERROR_ALREADY_EXISTS then the app is already running. If your task shuts down the mutex is automatically deleted by Windows. There's some sample code here: http://fox.wikis.com/wc.dll?Wiki~ControllingTheNumberOfApplicationInstances~VFP It should work with Windows 98 but you probably want to check! -- Paul _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED] ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

