If you want to open a specific file upon starting your application, you can modify the
CCommandLineInfo
after parsing. This method can be also used to avoid starting with a new document.
An example to optional load a file at program start or just start without any document might look like this:
CMyApp::OnInitInstance()
{
...
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
{
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
if (GetProfileInt(_T("Config"), _T("OpenAtStart")))
{
cmdInfo.m_strFileName = GetProfileString(
_T("Config"), _T("InitialFile"));
if (!cmdInfo.m_strFileName.IsEmpty())
cmdInfo.m_nShellCommand = CCommandLineInfo::FileOpen;
}
}
ProcessShellCommand(cmdInfo);
...
}