// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
int argc=0;
LPWSTR *argv=::CommandLineToArgvW(::GetCommandLineW(),&argc);
for(int i=0;i<argc;i++)
{
CString msg=argv[i];
MessageBox(msg,"Information");
}
return TRUE; // return TRUE unless you set the focus to a control
}
编译之后,由命令行进入debug目录,敲
TestCmdLine aa bb cc dd
试试?
to: zkxz()
你确信GetCommandLine()会返回字符串“d:\program files\aa>aa bb cc dd ee”,我debug后得到的怎么是得到当前进程的路径,而不是我在cmd中输入的路径啊,是不是因为这个函数得到的是当前进程的路径,而我debug程序,所以他得到的是我debug程序的路径,不知道我说明白没有。
to: carbon107(<软件开发思想.h>) and DeautyFan(痴情浪子):
你们说的方法我不太清楚什么意思,GetCommandLine()函数好像得到的不是输入的命令的字符串,而是得到正在运行的这个进程的路径,比如说我运行的是d:/program files/aa/aa.exe,得到的就是d:/program files/aa/aa.exe,怎么和在cmd中输入的字符比较啊??