Associating an extension to a MFC application - advanced
-
I want to associate an extension to my MFC application - I know I can call RegisterShellFileType which will do some of that. My problem is that for a given extension, I do not want to start a new instance of my application... I'd like the current instance (ideally all instances but let's not get there right away) to be notified that they need to read the file. If you're wondering why I want this : let me explain. I have this SDI application that creates documents (for lack of a better word). I want the users to be able to download some plugins (with the remarkable extension) from the wwww- and when they open the file from their browser, I want those plugins to be installed... I hope I am making sense! Thanks in advance!
-
I want to associate an extension to my MFC application - I know I can call RegisterShellFileType which will do some of that. My problem is that for a given extension, I do not want to start a new instance of my application... I'd like the current instance (ideally all instances but let's not get there right away) to be notified that they need to read the file. If you're wondering why I want this : let me explain. I have this SDI application that creates documents (for lack of a better word). I want the users to be able to download some plugins (with the remarkable extension) from the wwww- and when they open the file from their browser, I want those plugins to be installed... I hope I am making sense! Thanks in advance!
-
You would need to configure this into the browser so it recognises the file type and passes that file to the relevant application.
-
I want to associate an extension to my MFC application - I know I can call RegisterShellFileType which will do some of that. My problem is that for a given extension, I do not want to start a new instance of my application... I'd like the current instance (ideally all instances but let's not get there right away) to be notified that they need to read the file. If you're wondering why I want this : let me explain. I have this SDI application that creates documents (for lack of a better word). I want the users to be able to download some plugins (with the remarkable extension) from the wwww- and when they open the file from their browser, I want those plugins to be installed... I hope I am making sense! Thanks in advance!
As I see it, you have two issues... 1/ You want a website, with files of some custome format (call it fwibble.badjerry). In the same way as a (eg) pdf, the browser will run an external application - badjerry.exe, or acrobatreader.exe. 2/ You only ever want one of these programs running, even if they click on multiple files. I hope that's a reasonable summary. 1/ Is a non issue - use RegisterShellFileType as normal. Whether the file comes from a website, via a temp directory, or it comes from the users My Dcuments directory is irrelevant. 2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was: Limiting an application to a single Instance - the MFC way[^]. I did find a bug with huge impact but a simple fix - look at my comment at the end of the article. Other than that, it was a joy to use. Just a daft error. Enjoy, Iain.
I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]
-
As I see it, you have two issues... 1/ You want a website, with files of some custome format (call it fwibble.badjerry). In the same way as a (eg) pdf, the browser will run an external application - badjerry.exe, or acrobatreader.exe. 2/ You only ever want one of these programs running, even if they click on multiple files. I hope that's a reasonable summary. 1/ Is a non issue - use RegisterShellFileType as normal. Whether the file comes from a website, via a temp directory, or it comes from the users My Dcuments directory is irrelevant. 2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was: Limiting an application to a single Instance - the MFC way[^]. I did find a bug with huge impact but a simple fix - look at my comment at the end of the article. Other than that, it was a joy to use. Just a daft error. Enjoy, Iain.
I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]
It's not exactly what I want : the badjerry.exe is not single instance - it can open many .pdf or .doc files but if it tries to open a .badjerry the exisiting instance should be used. But you gave me an idea of how I could implement this - I could associate the .badjerry extension to another single instance program which will then relay the information to the other instances... or start one if there isn't... it's a bit long-winded but... hey... Thanks for your help!
-
It's not exactly what I want : the badjerry.exe is not single instance - it can open many .pdf or .doc files but if it tries to open a .badjerry the exisiting instance should be used. But you gave me an idea of how I could implement this - I could associate the .badjerry extension to another single instance program which will then relay the information to the other instances... or start one if there isn't... it's a bit long-winded but... hey... Thanks for your help!
OK, I'm confused. Unless badjerry.exe is a browser in its own right, it as no business opening pdf files... (I assume it's not a pdf viewer). And if it only handles .badjerry's, then the article I gave you a link to handles that - if a 2nd instance opens, it communicated with the first, to get the first one to open the desired file, then close the 2nd one. Iain.
I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]
-
As I see it, you have two issues... 1/ You want a website, with files of some custome format (call it fwibble.badjerry). In the same way as a (eg) pdf, the browser will run an external application - badjerry.exe, or acrobatreader.exe. 2/ You only ever want one of these programs running, even if they click on multiple files. I hope that's a reasonable summary. 1/ Is a non issue - use RegisterShellFileType as normal. Whether the file comes from a website, via a temp directory, or it comes from the users My Dcuments directory is irrelevant. 2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was: Limiting an application to a single Instance - the MFC way[^]. I did find a bug with huge impact but a simple fix - look at my comment at the end of the article. Other than that, it was a joy to use. Just a daft error. Enjoy, Iain.
I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]
Iain Clarke, Warrior Programmer wrote:
2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was: Limiting an application to a single Instance - the MFC way[^].
The procedure from that article seems awfully complicated. I always use this code in InitInstance (if it's a MFC app, otherwise WinMain):
CreateMutex(NULL, TRUE, _T("Unique_String_Identifying_The_Application"));
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
//already running, get out
return FALSE;
} -
Iain Clarke, Warrior Programmer wrote:
2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was: Limiting an application to a single Instance - the MFC way[^].
The procedure from that article seems awfully complicated. I always use this code in InitInstance (if it's a MFC app, otherwise WinMain):
CreateMutex(NULL, TRUE, _T("Unique_String_Identifying_The_Application"));
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
//already running, get out
return FALSE;
}That's what I used to do to... But that does nothing about running the previous (only) instance, let alone get the 1st instance to open any document that the 2nd instance had been... instantiated... to do. Iain.
I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]
-
That's what I used to do to... But that does nothing about running the previous (only) instance, let alone get the 1st instance to open any document that the 2nd instance had been... instantiated... to do. Iain.
I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]
It was slightly off topic, I guess. I'm still not quite sure what exactly the OP wants...
-
I respectfully disagree - it should be an Explorer settings - the browser simply asking if you want to save or open the file...
BadJerry wrote:
I respectfully disagree - it should be an Explorer settings - the browser simply asking if you want to save or open the file...
Sorry, but your original question was not clear. You mention associating a file type with your application, then talk about downloading files and sending them to your application. Could you clarify exactly how you expect this process to operate, including the interaction (or interdependency) between your application and the browser?