Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem passing value using COM

Status
Not open for further replies.

binhttruong

Programmer
Joined
Nov 7, 2002
Messages
1
Location
US
I have a COM object called CATLAdmin and one of method is ShowLoginDlg. When this metod is called, it displays a logon dialog to allow the user to enter there user id and password. After the user click on the OK button the user id is saved to the variable lpvUserID (see code below) so it could be passed back to the main application, but the lpvUserID value was empty when it exited the ShowLoginDlg funtion.

STDMETHODIMP CATLAdmin::ShowLoginDlg(LPVARIANT lpvUserID,LPVARIANT lpvResult)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())

//Initialize return value.
lpvAdmin->vt = VT_BOOL;
lpvUserID->vt = VT_BSTR;

//Instantiate and show login window.
CDlgLogin dlgLogin();
if (dlgLogin.DoModal() == IDOK)
{
// At this point there is a valid User ID
// saved to lpvUserID
lpvUserID->bstrVal = _bstr_t((dlgLogin.m_pUserData)->m_strUserID);

//Set a successful return value.
lpvResult->boolVal = TRUE;
}
else
{
lpvResult->boolVal = FALSE;
}

return (S_OK);
}


inline _variant_t IATLAdmin::ShowLoginDlg (VARIANT * lpvUserID)
{
VARIANT _result;
VariantInit(&_result);

//When viewed in debug mode for the lpvUserID is empty!! What happened to the value????
HRESULT _hr = raw_ShowWndLoginEx(lpvUserID, &_result);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _variant_t(_result, false);
}


Thank you for any suggestions that would help me.
BT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top