要求是動態呼叫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;
}
uj5u.com熱心網友回復:
報錯資訊是: C:\Users\user\Desktop\Admin,888888 was not found.Admin和888888是我傳入的引數,在InitInstance()分別決議出來然后登錄,但在
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (!ProcessShellCommand(cmdInfo))
return FALSE;
中報了這個錯,求大神解釋。。。
uj5u.com熱心網友回復:
ok,結貼了,其實很簡單,就是把if (!ProcessShellCommand(cmdInfo)) 注釋掉就可以了,這只是個查看校驗命令列的資訊,注釋調視窗依然能打開。不影響程式運行狀態。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/80113.html
上一篇:捕獲滑鼠訊息的問題
