Читайте также: |
|
;--------------------------------------------------------------------------
;
sIID_IMyCom2 TEXTEQU <{0F8CE5E41H, 01135H, 011D4H, \
{0A3H, 024H, 000H, 040H, 0F6H, 0D4H, 087H, 0D9H}}>
sLIBID_MyCom2 TEXTEQU <{0F8CE5E42H, 01135H, 011D4H, \
{0A3H, 024H, 000H, 040H, 0F6H, 0D4H, 087H, 0D9H}}>
sCLSID_MyCom2 TEXTEQU <{0F8CE5E43H, 01135H, 011D4H, \
{0A3H, 024H, 000H, 040H, 0F6H, 0D4H, 087H, 0D9H}}>
VtIMyCom2 MACRO CastName:REQ
IDispatch methods
VtIDispatch CastName
IMyCom2 methods
Amp;CastName&_GetValue comethod2?
Amp;CastName&_SetValue comethod2?
Amp;CastName&_RaiseValue comethod2?
ENDM
IMyCom2 STRUCT
VtIMyCom2 IMyCom2
IMyCom2 ENDS
The interface is defined as per the previous discussions in Creating COM objects in ASM (the orgional MyCom project). It is kept separate from the DLL file so it may be included in other ASM projects.
--------------------------------------------------------------------------------------------------------------------
rsrc.rc, the resource file
Get standard resources
#include <c:\masm32\include\colib\coserver.rc>
// type libraries here,
IDD_TypeLib TypeLib MyCom2.tlb
// add subsequent type libraries as such:
// IDD_TypeLib + 1 TypeLib MyCom3.tlb
// IDD_TypeLib + 2 TypeLib MyCom4.tlb
The one and only registrar script
IDD_RGS_SCRIPT REGISTRY C:\masm32\MyCom2\MyCom2.rgs
Add additional resources here starting at ID number 300
This should be simple to duplicate. All you are specifying is the type library file and the resistrar script file. Should you have multiple objects, just keep adding the type libraries as the comment suggests. CoLib will register every type lib in the list that appear at the IDD_TypeLib resource number and on. There can only be one registrar file, so if you have multiple objects, you must hand edit these scripts into a single script.
MyCom.IDL Interface Definition File
--------------------------------------------------------------------------------------------------------------------
MyCom2.idl, the interface definition file
I will not pretend that I understand Interface Definition Language or syntax. All I can state is the following code works. I have Jeremy of Collake Software (http://www.collakesoftware.com/main.stm) to thank for the outline of this file (cause I stole mine from him).
// MyCom2.idl: IDL source for MyCom2.ocx (or dll)
//
import "oaidl.idl";
import "ocidl.idl";
[
uuid(F8CE5E42-1135-11d4-A324-0040F6D487D9),
helpstring("MyCom2 1.0 Type Library"),
version(1.0)
]
Library MyCom2Lib
{
importlib("stdole32.tlb");
[
uuid(F8CE5E41-1135-11d4-A324-0040F6D487D9),
dual,
helpstring("IMyCom2 Dispatch Interface")
]
Interface IMyCom2: IDispatch
{
[propget, id(0), helpstring("property Value")] HRESULT Value([out, retval] long *pVal);
[propput, id(0), helpstring("property Value")] HRESULT Value([in] long newVal);
[id(1), helpstring("method Raise")] HRESULT Raise([in] long AddVal);
}
[
uuid(F8CE5E43-1135-11d4-A324-0040F6D487D9),
helpstring("MyCom2 Class")
]
Дата добавления: 2014-12-18; просмотров: 120 | Поможем написать вашу работу | Нарушение авторских прав |