Opening a file with my program
-
I have made a program that reads its own kind of file, which is written in plain text. When I run the program and select to open the file, it reads it perfectly, but how do I make it that when I double click on a file of this type it opens with my program? I have edited the registry and set it as default, but when I double click the file it runs the program with nothing there, the file hasn't loaded. Is there some code I should put into the program to allow it to open the file?
If you're reading this, you're reading my signature - actually, no joke
-
I have made a program that reads its own kind of file, which is written in plain text. When I run the program and select to open the file, it reads it perfectly, but how do I make it that when I double click on a file of this type it opens with my program? I have edited the registry and set it as default, but when I double click the file it runs the program with nothing there, the file hasn't loaded. Is there some code I should put into the program to allow it to open the file?
If you're reading this, you're reading my signature - actually, no joke
You have to get the filename from the command line. If you are using MFC look at the
CCommandLineInfoClass
(CCommandLineInfoClass (MFC)[^]) and theParseCommandLine
method ofCWinApp
(CWinApp::ParseCommandLine (MFC)[^]) -
I have made a program that reads its own kind of file, which is written in plain text. When I run the program and select to open the file, it reads it perfectly, but how do I make it that when I double click on a file of this type it opens with my program? I have edited the registry and set it as default, but when I double click the file it runs the program with nothing there, the file hasn't loaded. Is there some code I should put into the program to allow it to open the file?
If you're reading this, you're reading my signature - actually, no joke
-
I have made a program that reads its own kind of file, which is written in plain text. When I run the program and select to open the file, it reads it perfectly, but how do I make it that when I double click on a file of this type it opens with my program? I have edited the registry and set it as default, but when I double click the file it runs the program with nothing there, the file hasn't loaded. Is there some code I should put into the program to allow it to open the file?
If you're reading this, you're reading my signature - actually, no joke
-
__argc is an integer variable holding the count of commandline arguments. __argv is pointer to two dimensional character array of comand line strings. first argument __argv[0] second argument __argv[1] last argument __argv[__argc-1] alternatively you can use GetCommandLine API also If your registry settings for file association are correct, you will be getting the file path as a commandline argument to your application.
modified on Friday, July 30, 2010 9:24 AM
-
I have made a program that reads its own kind of file, which is written in plain text. When I run the program and select to open the file, it reads it perfectly, but how do I make it that when I double click on a file of this type it opens with my program? I have edited the registry and set it as default, but when I double click the file it runs the program with nothing there, the file hasn't loaded. Is there some code I should put into the program to allow it to open the file?
If you're reading this, you're reading my signature - actually, no joke
Assuming this is a Windows program then the command line parameters are passed in the third parameter of the
WinMain()
function. This is a simple text string which you need to parse for the specific details your program needs.It's time for a new signature.
-
I have made a program that reads its own kind of file, which is written in plain text. When I run the program and select to open the file, it reads it perfectly, but how do I make it that when I double click on a file of this type it opens with my program? I have edited the registry and set it as default, but when I double click the file it runs the program with nothing there, the file hasn't loaded. Is there some code I should put into the program to allow it to open the file?
If you're reading this, you're reading my signature - actually, no joke
mmagill0 wrote:
I have edited the registry and set it as default, but when I double click the file it runs the program with nothing there...
Did you put %1 in your registry string?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius