I am developing an application in windows using vs2005 c++ and want to associate a file extension to the application which I can do in the registry settings. However, when I click on the file I want to associate it with a running instance of my application and not launch a new one. How can I achieve this behavior.
(1) The relationship of one file to another based on the data it contains. (2) An established relationship between a file and the application used to open it. There are default file associations pre-configured in every operating system for all the common file types.
Answer. Both the Windows and Mac OS X operating systems use file associations to define what default program is used to open each file type. For example, in Windows, plain text (. ... Therefore, if you double-click a plain text file in Windows, it will open in Notepad, while in Mac OS X, it will open in TextEdit.
Open the Start menu, type “Control Panel” and then click on it. Now, navigate to Programs. Next, click on Associate a file type or protocol with a specific program. Now, scroll down and select Choose default apps by file type at the bottom of the page.
You can associate your Google Play Store Android app with a website property in Search Console. If an app is associated with a website, Google will automatically try to index and crawl your app by inferring the app structure from the website structure. Request association using Play Console.
I can't give you an implementation off the top of my head but look into something called "interprocess communication" (typically using COM if you're on windows). What you can do is, when your program starts, check for other copies of itself, if it finds one then it tells that one what file you wanted open, then shuts itself down.
I found an implementation for you:
http://www.flounder.com/nomultiples.htm
This used to be done with a parameter in winmain but from msdn
A handle to the previous instance of the application. This parameter is always NULL. If you need to detect whether another instance already exists, create a uniquely named mutex using the CreateMutex function. CreateMutex will succeed even if the mutex already exists, but the function will return ERROR_ALREADY_EXISTS. This indicates that another instance of your application exists, because it created the mutex first. However, a malicious user can create this mutex before you do and prevent your application from starting. To prevent this situation, create a randomly named mutex and store the name so that it can only be obtained by an authorized user. Alternatively, you can use a file for this purpose. To limit your application to one instance per user, create a locked file in the user's profile directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With