Definition issues encountered in ATL in ADO programming

xiaoxiao2021-03-06  56

The definition issues encountered in ATL in ADO program When you want to define methods in an interface as follows:

[ID (1), Helpstring ("Method SearchCust")] HRESULT SEARCHCHCUST ([In] BSTR BSTRCUSTID, [OUT, RETVAL] _Recordset ** PTR);

Since the _recordset type is used, it must be

Importlib ("C: / Program Files / Common Files / System / ADO / Msado15.dll");

So the entire IDL file should be rewritten as the following way:

// FindCust.Idl: IDL Source for FindCust.dll

//

// this file will be processed by the Mid Tool To

// Produce the Type Library (FindCust.tlb) And Marshalling Code.

Import "OAIDL.IDL";

Import "OCIDL.IDL";

[

UUID (B32A7D72-12D4-11D5-AC09-00A0247A8577),

Version (1.0),

Helpstring ("FindCust 1.0 Type Library)

]

Library FindCustLib // Library gives manual advancement

{

Importlib ("stdole32.tlb");

Importlib ("stdole2.tlb");

// modify here

Importlib ("C: / Program Files / Common Files / System / ADO / Msado15.dll");

[

Object,

UUID (B32A7D7F-12D4-11D5-AC09-00A0247A8577),

Dual,

Helpstring ("ISEARCH Interface"),

Pointer_DEFAULT (UNIQUE)

]

Interface ISEARCH: IDispatch

{

[ID (1), Helpstring ("Method SearchCust")] HRESULT SEARCHCHCUST ([In] BSTR BSTRCUSTID, [OUT, RETVAL] _Recordset ** PTR);

}

[

UUID (B32A7D81-12D4-11D5-AC09-00A0247A8577),

Helpstring ("_ ieSearchevents Interface")

]

Dispinterface_isearchevents

{

Properties:

Methods:

}

[

UUID (B32A7D80-12D4-11D5-AC09-00A0247A8577),

Helpstring ("Search Class")

]

CoClass Search

{

[default] interface iesarch;

[Default, Source] Dispinterface_isearchevents DISPINTERFACE

}

}

转载请注明原文地址:https://www.9cbs.com/read-83106.html

New Post(0)