问题是关于DCOM中使用自定义结构数组做接口方法参数的:
下面代码是客户端调用,编译连接都没问题,但执行到如标注所示的那行代码,具体是GetTypeInfoOfGUID()函数时,就出错了,请看:
void CUserLoginDlg::OnBnClickedButtonConfirm()  //验证用户登陆函数
{
// TODO: 在此添加控件通知处理程序代码
HWND ThisHWnd=GetSafeHwnd();
ASSERT(!ThisHWnd==NULL);
CWnd* pWndThis=FromHandle(ThisHWnd);
ASSERT(!pWndThis==NULL);
CWnd* pWnd=pWndThis->GetDlgItem(IDC_BUTTON_CONFIRM);
pWnd->EnableWindow(false); //
    UpdateData(true);
if (m_String_User.IsEmpty()) 
{
MessageBox("请输入用户名!","",MB_ICONERROR);
return;
}
  //下面代码开始执行验证
if (theApp.m_bConnectToORA=false)  
{
try{
   theApp.ptrOracleServer.Attach((BMSServer::IOracleServer*)theApp.bmsMQI[0].pItf);
           theApp.m_bConnectToORA=theApp.ptrOracleServer->ConnectToOracle();
}
catch (_com_error e)
{
AfxMessageBox(e.Error());
}
 }
      if (theApp.m_bConnectToORA=false)
  {
  AfxMessageBox("无法连接到Oracle,请与数据库系统管理员联系,然后再登陆。");
  return CUserLoginDlg::OnCancel();
  }
      const GUID GUID_USER ={0x3df25342,0xc02a,0x4449,{0x8c,0x4a,0x07,0x64,0xf7,0x0a,0x75,0xd3}};   ITypeInfo *pTypeInfo=NULL;
  ITypeLib  *pTypeLib=NULL;
  IRecordInfo *pRecordInfo=NULL;
  SAFEARRAY *psaUser=NULL;
  SAFEARRAYBOUND rgBounds={2,0};
  USER *pUser;
  LCID lcid=GetUserDefaultLCID();
  HRESULT hrrr=LoadRegTypeLib(LIBID_BMSUser,1,0,GetUserDefaultLCID(),&pTypeLib);
  _ASSERTE(pTypeLib!=NULL);
   if FAILED(hrrr) 
 {
 AfxMessageBox("LoadRegTypeLib  Failed!");
 }
HRESULT hrr= pTypeLib->GetTypeInfoOfGuid(GUID_USER,&pTypeInfo);
/*程序运行到上面这里出错!调试时看到 ptypeinfo是空的,没有取到数据; hrr的信息是 “0x8002802b 没有采纳合格名称。”。我使用的是VC.net简体中文版  */
 if FAILED(hrr) 
 {
 AfxMessageBox("GetTypeInfoOfGuid Failed!");
 }
GetRecordInfoFromTypeInfo(pTypeInfo,&pRecordInfo);
//因为pTypeInfo为空,所以程序到上面这里便出现异常
  pTypeLib->Release();
  pTypeInfo->Release();
  psaUser=SafeArrayCreateEx(VT_RECORD,1,&rgBounds,pRecordInfo);
  SafeArrayAccessData(psaUser,(void**)(&pUser));
  _bstr_t UserID(m_String_User);
  _bstr_t Password(m_String_Password);
  IDENTITY  Identity=storager;
  pUser[0].UserID=UserID;//psaUser[0]UserID=UserID;  //
  pUser[0].Password=Password;//psaUser[0].Password
  pUser[0].Identity=Identity;//Identity;
  pUser[1].UserID=UserID;
      pUser[1].Password=Password;
  pUser[1].Identity=Identity;
  SafeArrayUnaccessData(psaUser);
  _ASSERTE(theApp.ptrOracleServer!=NULL);
  theApp.m_bValidate=theApp.ptrOracleServer->Validate(psaUser);
pWnd->EnableWindow(true); 
CUserLoginDlg::OnOK();
}因为从未使用过GetTypeInfoOFGUID函数,所以现在一筹莫展,时间又非常紧,所以万分焦急,恳请各位前辈指点一二,帮忙UP也一定送分!热心的朋友请参阅com集中营:http://comcamp.myrice.com/techarticles/com/2009.htm 我的代码就是仿照里面“自定义数据结构数组客户方”这部分来编写的,编译通过。拜托各位了