正在做一个进程内组件,有一些信息要反馈给客户端,列如方法:HRESULT GetInfo( BSTR bstrName,short iSex,short iAge...);这样的话参数太多,我想把这些参数定义在一个结构内:
typedef struct _MYINFO
{
   BSTR bstrName;
   short iSex;
   short iAge;
}MYINFO;
然后方法可以这样实现:HRESULT GetInfo( MYINFO * pInfo );
请问如何实现?多谢

解决方案 »

  1.   

    难道没人在com中用过自定义数据类型吗
      

  2.   

    没试过将BSTR放在结构里面,一般的数型结构vb和c都是可以通用的,在IDL中
    定义
    [
       uuid(),
       help_string("sdf")
    ]
    typedef public struct
    {
    }Name;
    你试试看
      

  3.   

    http://www.geocities.com/rktalla/files/atlcom.html#Passing%20structure%20to%20COM%20objects
      

  4.   

    import "oaidl.idl";
    import "ocidl.idl";typedef struct tagTALLASTRUCT
    {
      long age;
      BSTR name;
    }TALLASTRUCT; [
    object,
    uuid(6CEF8A3B-B453-4A49-BF03-F5FE7C98C1D9),

    helpstring("IVote Interface"),
    pointer_default(unique)
    ]
    interface IVote : IUnknown
    {
    [helpstring("method VoterCheck")] HRESULT VoterCheck([in] TALLASTRUCT *b, [out] BSTR *status);
    };
      

  5.   

    本来想建议你用VARIANT *数组的。但是,如果是我,我会把结构里的变量们打包成XML格式,作为一个字符串反馈给客户端,客户端要解析XML是很容易的。
      

  6.   

    xml 当参数http://blog.csdn.net/newkey007/archive/2004/08/10/70139.aspx