MFC如何使用ShellExecute函数传值?在线等
voidCLOGINDlg::OnLogin(){UpdateData(TRUE);//获取控件的数据传给成员变量。if(m_uname.IsEmpty()){Messa...
void CLOGINDlg::OnLogin()
{
UpdateData(TRUE); //获取控件的数据传给成员变量。
if(m_uname.IsEmpty())
{
MessageBox("用户名不能为空!");
return;
}else{
m_uname.TrimLeft();
m_uname.TrimRight();
}
if(m_upwd.IsEmpty())
{
MessageBox("密码不能为空!");
return;
}else{
m_upwd.TrimLeft();
m_upwd.TrimRight();
}
CString t_uid;
DBConnect();
try
{
DBRecordsetSqlExc("Select uid from jtcw_users where username = '"+m_uname+"' and password ='"+m_upwd+"'");
while(!m_pRecordset->adoEOF)
{
var = m_pRecordset->GetCollect("uid");
if(var.vt != VT_NULL)t_uid = (LPCSTR)_bstr_t(var);
m_pRecordset->MoveNext();
}
}catch(_com_error &e){
CString errorMessage;
errorMessage.Format("系统异常错误信息:%s",e.ErrorMessage());
AfxMessageBox(errorMessage);
}
if(t_uid.IsEmpty())
{
MessageBox("帐号或者密码错误,重新登录!");
m_upwd = "";
UpdateData(FALSE);
return ;
}else{
try{
ShellExecute(NULL, "open", "JTCW.exe",m_uname+" "+m_upwd+" "+t_uid, NULL, SW_SHOWNORMAL);AfxGetMainWnd()->SendMessage(WM_CLOSE);
}catch(_com_error &e)
{
AfxMessageBox("主程序不存在:"+e.Description());
}
}
DBUConnect();
}
如何使用ShellExecute函数实现将参数传递给JTCW.EXE 展开
{
UpdateData(TRUE); //获取控件的数据传给成员变量。
if(m_uname.IsEmpty())
{
MessageBox("用户名不能为空!");
return;
}else{
m_uname.TrimLeft();
m_uname.TrimRight();
}
if(m_upwd.IsEmpty())
{
MessageBox("密码不能为空!");
return;
}else{
m_upwd.TrimLeft();
m_upwd.TrimRight();
}
CString t_uid;
DBConnect();
try
{
DBRecordsetSqlExc("Select uid from jtcw_users where username = '"+m_uname+"' and password ='"+m_upwd+"'");
while(!m_pRecordset->adoEOF)
{
var = m_pRecordset->GetCollect("uid");
if(var.vt != VT_NULL)t_uid = (LPCSTR)_bstr_t(var);
m_pRecordset->MoveNext();
}
}catch(_com_error &e){
CString errorMessage;
errorMessage.Format("系统异常错误信息:%s",e.ErrorMessage());
AfxMessageBox(errorMessage);
}
if(t_uid.IsEmpty())
{
MessageBox("帐号或者密码错误,重新登录!");
m_upwd = "";
UpdateData(FALSE);
return ;
}else{
try{
ShellExecute(NULL, "open", "JTCW.exe",m_uname+" "+m_upwd+" "+t_uid, NULL, SW_SHOWNORMAL);AfxGetMainWnd()->SendMessage(WM_CLOSE);
}catch(_com_error &e)
{
AfxMessageBox("主程序不存在:"+e.Description());
}
}
DBUConnect();
}
如何使用ShellExecute函数实现将参数传递给JTCW.EXE 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询