ShellExecute传入参数并调用exe,但在InitInstance中报错了
范泛 2016-04-19 04:57:16 要求是动态调用ocx接口,使用ShellExecute()方法将传入用户名密码传入,在InitInstance()中接收,完成登录并初始化窗口。代码如下:
InitInstance()
{
LPWSTR *szArglist = NULL;
int nArgs = 0,uintPort;
CString strUser, strPwd, strAddress;
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
//获取用户名密码等信息
if( NULL != szArglist && nArgs >=2)
{
isLoginDialog = false;
int intArgs = nArgs;
CString strPara = szArglist[1];
char sentence[128];
strcpy( sentence, strPara.GetBuffer(strPara.GetLength()));
char *PtrUser = strtok(sentence,",");
char *PtrPwd = strtok(NULL,",");
strUser.Format("%s",PtrUser);
strPwd.Format("%s",PtrPwd);
char szProfile[128];
memset(szProfile,0,sizeof(szProfile));
GetPrivateProfileString("Server", "Address", "127.0.0.1", szProfile, 20, INI_FILE);
strAddress = szProfile;
uintPort = GetPrivateProfileInt("Server", "Port", 30000, INI_FILE);
}
//在此登录
logon(APPSYSMANAGER, -1, NULL, "操作员名称", strAddress, uintPort, strUser, strPwd);
//接下来就报错了,求解为什么…………………………………………………………………………
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it.
m_pMainWnd->CenterWindow();
m_pMainWnd->ShowWindow(SW_MAXIMIZE);
m_pMainWnd->SetWindowText("管理子系统");
m_pMainWnd->UpdateWindow();
return TRUE;
}