Once you manage to associate a specific file name extension with your application, a double-click on a file with such an extension will automatically call your application with the file name as a command line parameter. So, what you need to do is read the command line arguments.
Here is an example from
http://msdn.microsoft.com/en-US/library/hwbccf8z%28v=VS.80%29.aspx[
^]. I simplified it a bit for your purpose:
#include <afx.h>
#include <afxwin.h>
#include <iostream>
using namespace std;
CWinApp theApp;
int main(int argc, char *argv[])
{
if (!AfxWinInit(GetModuleHandle(NULL), NULL, GetCommandLine(), 0))
{
cout << "panic: MFC couldn't initialize!" << endl;
return 1;
}
if (argc != 2)
{
cout << "usage: " << argv[0];
cout << " <source>" << endl;
cout << endl;
return 1;
}
CString result;
CFile sourceFile;
CFileException ex;
if (!sourceFile.Open(argv[1],
CFile::modeRead | CFile::shareDenyWrite, &ex))
{
TCHAR szError[1024];
ex.GetErrorMessage(szError, 1024);
cout << "Couldn't open source file: ";
cout << szError;
return 1;
}
else
{
BYTE buffer[4096];
DWORD dwRead;
do
{
dwRead = sourceFile.Read(buffer, 4096);
result += buffer;
}
while (dwRead > 0);
sourceFile.Close();
cout << result << endl;
}
return 0;
}</source>