ATL中CString,list怎么使用,包含哪个头文件中?在idl文件中要定义结构体,可是系统无法识别这两个结构?
有人说用ATL::cstring可是编绎不过,是不是需要头文件什么的?
请高手指点

解决方案 »

  1.   

    其实 你既然知道 要使用哪个函数或者类 什么的 在微软MSDN里面都表明了头文件!
      

  2.   

    afxwin.h包含了CString的支持。
    list是STL的模板类。
    #include <list>
    using namespace std;
      

  3.   

    首先谢谢各位的回答,但是照着您说的方法,仍然不行呢?
    我是在ATL COM中使用这些类型的,请再次指点。
      

  4.   

    Atl的CString.h在atlstr.h
    IDL放CString,百分百编译不过,IDL只能放些COM规范类型
    如果需要用到字符,应用BSTR,BSTR操作很费劲,如果在CPP里需要用到BSTR,用CComBSTR会比较舒服。
    用list你是想用数组??
    在IDL里用数组应用SAFEARRAY,对应的封装类应用CComSafeArray,此类在atlsafe.h里面。
      

  5.   

    非常感谢,ATL COM :但是我想实现一个这样的API list<sc_dev> send(SC_RESULT T)它做为一个ACTIVEX控的对外开放的函数,在IE中使用。
    其中sc_dev,sc_result都是自定义结构体,里面包含CString,list类型?
    网上很多地方说,自定义的结构要在IDL中定义,那么这个结构体怎么实现? 
      

  6.   

    上面的问题,我把接口函数改了,用SAFEARRAY存储自定义结构体,但是在
     hr=GetRecordInfoFromGuids(LIBID_SUCLib,1,0,GetUserDefaultLCID(),__uuidof(SCEInfo),&pRecordInfo);处出错,VC提示:
    C:\Program Files\Microsoft Visual Studio\MyProjects\suc\success.cpp(26) : error C2787: 'SCE_Info' : no GUID has been associated with this object
    还望高手指点。下面是IDL文件。import "oaidl.idl";
    import "ocidl.idl";
    #include "olectl.h"
    [
    uuid(D124B04A-C5F9-4a16-9671-1E67B75DB1A1) ]
    typedef  struct SCE_Info
    {
    BSTR ID;
    BSTR name;
    BSTR driver_version;
    BSTR provider_name;

    }SCEInfo; [
    uuid(D124B04A-C5F9-4a16-9671-1E67B75DB1A2)
    ]
    typedef struct sc_Standard 
    {
    long SC_STAND_ID;
    BSTR SC_STAND_Ver;
    BSTR Comments;
    BSTR SPEC_CODE;
    BSTR CHECK_PART;
    BSTR CHECK_ITEM;
    BSTR CHECK_CONTENT;
    BSTR EST_STANDARD;
    int SC_type;
    int DATA_TYPE_ID;
    BSTR DATA_UNIT_ID;
    BSTR resultList;
    int CheckMethod;
    float WARN_LOWER;
    float WARN_UPPER;
    float ALARM_LOWER;
    float ALARM_UPPER;
    int Check_Cont;
    }SC_Standard;
    [
    uuid(D124B04A-C5F9-4a16-9671-1E67B75DB1A3)
    ]
    typedef struct sc_dev
    {
    BSTR devID;
    BSTR devName;
    SAFEARRAY *standards;
    }SC_DEV;
    [
    uuid(D124B04A-C5F9-4a16-9671-1E67B75DB1A4)
    ]
    typedef struct sc_zero 
    {
    BSTR ID;
    BSTR Zero_CODE;
    BSTR ZeroName;
    SAFEARRAY *Devs;
    }SC_Zero;
    [
    uuid(D124B04A-C5F9-4a16-9671-1E67B75DB1A6)
    ]
    typedef struct sc_result{
    long SC_StandardID;
    BSTR PlanID;
    BSTR COMPLETE_TM;
    int DEV_status;
    int USER_ID;
    int DATA_TYPE_ID;
    byte  resultData;
    byte resultDataEx;
    BSTR Memo;}SC_RESULT;
    [
    uuid(D124B04A-C5F9-4a16-9671-1E67B75DB1A5)
    ]
    typedef struct SC_Line 
    {
     int ID;
    BSTR name;
    int Specialty;
    int gangwei;
    BSTR  executorID;
    BSTR SC_Period;
    int SC_type;
    BSTR starttime;
    BSTR lastStartTime;
    BSTR lastEndTime;
    SAFEARRAY *Zeroes;}SCLine;
    [
    object,
    uuid(7A6EA7DF-5D06-4DE2-B354-655612C1F8B9),
    dual,
    helpstring("Isuccess Interface"),
    pointer_default(unique)
    ]
    interface Isuccess : IDispatch
    {
    [id(1), helpstring("method Test")] HRESULT Test();
    };[
    uuid(286E923E-611F-48D7-B84C-6BF96E935624),
    version(1.0),
    helpstring("suc 1.0 Type Library")
    ]
    library SUCLib
    {
    importlib("stdole32.tlb");
    importlib("stdole2.tlb"); [
    uuid(877DBFC7-6574-45D1-90B9-C5EDAAAF4B4E),
    helpstring("success Class")
    ]
    coclass success
    {
    [default] interface Isuccess;
    };
    };
      

  7.   

    你参考一下别个怎么的
    http://www.codeproject.com/KB/atl/udtdemo.aspx
      

  8.   

    我强列建议如果做成控件给IE用,最好别用自定义结构体,因为Javascript和VBScript可不知道什么叫自定义结构体,它们只认IDispatch接口。
      

  9.   

    ATL中CString可以直接用的,不用包含头文件,list在MSDN中找找