same as the ordinary SDI application Project-->settings... select Debug tab on the right tab view See the "Program arguments:" edit box? set your init parameters here good luck!
Oh, You also need handle the command line info in CXXApp's InitInstance function see CCommandLineInfo in MSDN for detail note: Derive a new class from CCommandLineInfo to handle other flags and parameter values. Override ParseParam to handle the new flags.
在CWinApp的InitInstance中m_lpCmdLine变量存储了命令行参数,调试时直接看m_lpCmdLine的值下面是MSDN对m_lpCmdLine的解释 Points to a null-terminated string that specifies the command line for the application. Use m_lpCmdLine to access any command-line arguments the user entered when the application was started. m_lpCmdLine is a public variable of type LPTSTR.
} //InitInstance****** // Parse command line for standard shell commands, DDE, file open CMyCmdLineInfo cmdInfo; ParseCommandLine(cmdInfo); TRACE("\n%s\n",cmdInfo.m_MyParam); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; //****** Please set "Program arguments:" /sss or sss It may not a complete answer,but you can get the parameter now. Good luck!
} //InitInstance // Parse command line for standard shell commands, DDE, file open CMyCmdLineInfo cmdInfo; ParseCommandLine(cmdInfo); TRACE("\n%s\n",cmdInfo.m_MyParam); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; //********* Please set "Program arguments:" as /sss or sss It is not a complete answer,but you can get the parameter now. good luck!
Project-->settings...
select Debug tab on the right tab view
See the "Program arguments:" edit box?
set your init parameters here
good luck!
CWinApp的m_lpCmdLine中存储了命令行参数
in CXXApp's InitInstance function
see CCommandLineInfo in MSDN for detail
note:
Derive a new class from CCommandLineInfo to handle other flags and parameter values. Override ParseParam to handle the new flags.
Points to a null-terminated string that specifies the command line for the application. Use m_lpCmdLine to access any command-line arguments the user entered when the application was started. m_lpCmdLine is a public variable of type LPTSTR.
//
//////////////////////////////////////////////////////////////////////#if !defined(AFX_MYCMDLINEINFO_H__C9926400_10EF_48B1_B60B_C72D9CA1CEE6__INCLUDED_)
#define AFX_MYCMDLINEINFO_H__C9926400_10EF_48B1_B60B_C72D9CA1CEE6__INCLUDED_#include <afxwin.h>#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000class CMyCmdLineInfo : public CCommandLineInfo
{
public:
CString m_MyParam;
void ParseParam( LPCTSTR lpszParam, BOOL bFlag, BOOL bLast );
CMyCmdLineInfo();
virtual ~CMyCmdLineInfo();};#endif // !defined(AFX_MYCMDLINEINFO_H__C9926400_10EF_48B1_B60B_C72D9CA1CEE6__INCLUDED_)
// MyCmdLineInfo.cpp: implementation of the CMyCmdLineInfo class.
//
//////////////////////////////////////////////////////////////////////#include "stdafx.h"
#include "TestSDI.h"
#include "MyCmdLineInfo.h"#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////CMyCmdLineInfo::CMyCmdLineInfo()
{}CMyCmdLineInfo::~CMyCmdLineInfo()
{}void CMyCmdLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
{
TRACE("\n%s\n",lpszParam);
if(strcmp(lpszParam,"sss")==0)
{
m_MyParam="myParam";
}
else
CCommandLineInfo::ParseParam(lpszParam,bFlag,bLast);
}
//InitInstance******
// Parse command line for standard shell commands, DDE, file open
CMyCmdLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
TRACE("\n%s\n",cmdInfo.m_MyParam); // Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
//******
Please set "Program arguments:" /sss or sss
It may not a complete answer,but you can get the parameter now.
Good luck!
//
//////////////////////////////////////////////////////////////////////#if !defined(AFX_MYCMDLINEINFO_H__C9926400_10EF_48B1_B60B_C72D9CA1CEE6__INCLUDED_)
#define AFX_MYCMDLINEINFO_H__C9926400_10EF_48B1_B60B_C72D9CA1CEE6__INCLUDED_#include <afxwin.h>#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000class CMyCmdLineInfo : public CCommandLineInfo
{
public:
CString m_MyParam;
void ParseParam( LPCTSTR lpszParam, BOOL bFlag, BOOL bLast );
CMyCmdLineInfo();
virtual ~CMyCmdLineInfo();};#endif // !defined(AFX_MYCMDLINEINFO_H__C9926400_10EF_48B1_B60B_C72D9CA1CEE6__INCLUDED_)
// MyCmdLineInfo.cpp: implementation of the CMyCmdLineInfo class.
//
//////////////////////////////////////////////////////////////////////#include "stdafx.h"
#include "TestSDI.h"
#include "MyCmdLineInfo.h"#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////CMyCmdLineInfo::CMyCmdLineInfo()
{}CMyCmdLineInfo::~CMyCmdLineInfo()
{}void CMyCmdLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
{
TRACE("\n%s\n",lpszParam);
if(strcmp(lpszParam,"sss")==0)
{
m_MyParam="myParam";
}
else
CCommandLineInfo::ParseParam(lpszParam,bFlag,bLast);
}
//InitInstance
// Parse command line for standard shell commands, DDE, file open
CMyCmdLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
TRACE("\n%s\n",cmdInfo.m_MyParam); // Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
//*********
Please set "Program arguments:" as /sss or sss
It is not a complete answer,but you can get the parameter now.
good luck!