i know this has been done, ive seen examples i just cant seem to figure it out, how if at all can i create an object outside the form, say on the desktop? any help is appreciated, thanks. Oh i use Borland if that helps any...
I have written an application using Visual Studio 6 C++, targeted for Windows XP and 2000. How do I detect/prevent multiple instances of my program?. I only want a single instance running and every time I click the shortcut, I get another instance launched (Duh!).
CreateMutex(NULL, TRUE, _T("Unique_String_Identifying_The_Application"));
if (GetLastError() == ERROR_ALREADY_EXISTS)
//Do whatever you have to do if one instance is already running and exitreturn;
You can place this code in InitInstance() for example.
I find that some of his articles fail to address features of modern operating systems such as Vista and even some features of XP. If the goal of the original poster is to limit his application to an absolute single instance then the above code is perfectly sufficient by simply declaring the Mutex as global.
By adding a prefix of "Global\\" to the Mutex there is absolutely no way another instance of the application will be created. In addition, if you look at the bottom of the article by Dr. Newcomer he presents large functions to limit the application to session and global both of which can be achieved by simply prefixing the Mutex with "Global\\" , "Local\\" or "Session\\".
Conversely, if the goal of the original poster is to have maximum flexibility then perhaps the code Dr. Newcomer has presented would be better. Although I would personally modify it to use the kernel object namespaces.
Outdated would have been a better way to describe the techniques presented in the article by Dr. Newcomer. I don't think kernel object namespaces were documented when the article was written. I am a big fan of Joseph Newcomer and have absolutely enjoyed reading his essays over the years. His website is an absolute treasure trove of Win32 information.
This has been done many times before.
Basically, in your WinMain() or _tmain() try to open a mutex with OpenMutex(), if it fails then create it (CreateMutex).
If OpenMutex() succeeds then it means your application is already running. You can do a search here on CP, you will find several examples in MFC, C++ and .NET.
I want to program an ActiveX control in web page such that user can access (save and open) the local PC files and connect to the internet via http, is it possible ? Are there any limitation for an ActiveX Control in Web page similar to java applet ?