Definition issues encountered in ATL in ADO programming

zhaozj2021-02-16  82

When you want to define methods in an interface, you are 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 (B

32A

7D72-12D4-11D5-AC09

-00a

0247A

8577)

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 (B

32A

7D

7f

-12D4-11D5-AC09

-00a

0247A

8577)

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 (B

32A

7D81-12D4-11D5-AC09

-00a

0247A

8577)

Helpstring ("_ ieSearchevents Interface")

]

Dispinterface_isearchevents

{

Properties:

Methods:

}

[

UUID (B

32A

7D80-12D4-11D5-AC09

-00a

0247A

8577)

Helpstring ("Search Class")

]

CoClass Search

{

[default] interface iesarch;

[Default, Source] Dispinterface_isearchevents;

}

}

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

New Post(0)