Here is how the container does it. Hope this helps....
This code Copyright(C) Jriver, Inc. All rights reserved.
TelnetPro.exe code:
void CAquarius::Connect(BSTR* Host, const VARIANT& Profile)
{
static BYTE parms[] = VTS_PBSTR VTS_VARIANT;
InvokeHelper(0x53, DISPATCH_METHOD, VT_EMPTY, NULL, parms, Host, &Profile);
}
void CAquarius::GetProfile2(const VARIANT& l_Profile)
{
static BYTE parms[] = VTS_VARIANT;
InvokeHelper(0x54, DISPATCH_METHOD, VT_EMPTY, NULL, parms, &l_Profile);
}
void CAquarius::SetProfile2(const VARIANT& l_Profile)
{
static BYTE parms[] = VTS_VARIANT;
InvokeHelper(0x55, DISPATCH_METHOD, VT_EMPTY, NULL, parms, &l_Profile);
}
----------------------------------
OCX Code:
/////////////////////////////////////////////////////////////////////////////
//
// Function: SetProfile/GetProfile
//
// Purpose: These are the methods to get and set the profile property.
//
// Comments: I couldn't figure out how to pass any type I wanted, so I
// chose LPCTSTR, cast a pointer to a ProfileData object to
// LPCTSTR before calling and it should work fine.
//
/////////////////////////////////////////////////////////////////////////////
void CAquariusCtrl::SetProfile(const VARIANT FAR& Profile)
{
void *pArrayData;
PassProfile TempPassProfile;
SafeArrayAccessData(Profile.parray, &pArrayData);
CopyMemory(&TempPassProfile, pArrayData, sizeof(PassProfile));
SafeArrayUnaccessData(Profile.parray);
// TODO: Write code to check the profile for reasonable values.
int iPassProfileReturn = IsPassProfileValid(&TempPassProfile);
if (0 == iPassProfileReturn)
{
ProfileData OldProfile = *m_Profile;
m_Profile->SetPassProfile(&TempPassProfile);
// Check for actions that need to be taken based on differences
// in new and old profiles.
ActOnNewProfile(&OldProfile, m_Profile);
} //
else
{
DejaTrace(sevError,traceProfile,"Pass Profile is invalid, bad field =%d.\n", iPassProfileReturn);
} // else
} // CAquariusCtrl::SetProfile
void CAquariusCtrl::GetProfile(const VARIANT FAR& l_Profile)
{
void *pArrayData;
PassProfile TempPassProfile;
SafeArrayAccessData(l_Profile.parray, &pArrayData);
TempPassProfile = m_Profile->GetPassProfile();
CopyMemory(pArrayData, &TempPassProfile, sizeof(PassProfile));
SafeArrayUnaccessData(l_Profile.parray);
} // CAquariusCtrl::GetProfile
///////////////////////////////
void CAquariusCtrl::Connect(BSTR FAR* Host, const VARIANT FAR& Profile)
{
....
}
/////////////////////////////////////
header file declarations:
afx_msg void Connect(BSTR FAR* Host, const VARIANT FAR& Profile);
afx_msg void GetProfile(const VARIANT FAR& l_Profile);
afx_msg void SetProfile(const VARIANT FAR& l_Profile);
/////////////////////////////////////
Dispatch calls:
DISP_FUNCTION(CAquariusCtrl, "Connect", Connect, VT_EMPTY, VTS_PBSTR, VTS_VARIANT)
DISP_FUNCTION(CAquariusCtrl, "GetProfile", GetProfile, VT_EMPTY, VTS_VARIANT)
DISP_FUNCTION(CAquariusCtrl, "SetProfile", SetProfile, VT_EMPTY, VTS_VARIANT)