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;
}
...全文
2116 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
范泛 2016-04-19
  • 打赏
  • 举报
回复
ok,结贴了,其实很简单,就是把if (!ProcessShellCommand(cmdInfo)) 注释掉就可以了,这只是个查看校验命令行的信息,注释调窗口依然能打开。不影响程序运行状态。
范泛 2016-04-19
  • 打赏
  • 举报
回复
报错信息是: C:\Users\user\Desktop\Admin,888888 was not found. Admin和888888是我传入的参数,在InitInstance()分别解析出来然后登录,但在 CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); if (!ProcessShellCommand(cmdInfo)) return FALSE; 中报了这个错,求大神解释。。。

703

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder ActiveX/COM/DCOM
社区管理员
  • ActiveX/COM/DCOM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧