...continues from Part
II
Again we will check what
things look like in OLE/COM Object Viewer.
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: sample.tlb
[
uuid(AD7B6A7C-4F96-3710-B1AC-5170E611BA57),
version(1.0),
custom(90883F05-3D28-11D2-8F17-00A0C9A6186D, sample, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null)
]
library sample
{
// TLib : // TLib : Common Language Runtime Library : {BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}
importlib("mscorlib.tlb");
// TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
interface _T;
[
uuid(4996A037-02BD-3839-A363-A9A321885D2C),
version(1.0),
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, T)
]
coclass T {
[default] interface _T;
interface _Object;
};
[
odl,
uuid(C145FF57-9C23-355C-B068-BADECB60531B),
hidden,
dual,
nonextensible,
oleautomation,
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, T)
]
interface _T : IDispatch {
[id(00000000), propget,
custom(54FC8F55-38DE-4703-9C4E-250351302B1C, 1)]
HRESULT ToString([out, retval] BSTR* pRetVal);
[id(0x60020001)]
HRESULT Equals(
[in] VARIANT obj,
[out, retval] VARIANT_BOOL* pRetVal);
[id(0x60020002)]
HRESULT GetHashCode([out, retval] long* pRetVal);
[id(0x60020003)]
HRESULT GetType([out, retval] _Type** pRetVal);
[id(0x60020004)]
HRESULT A(
[in] BSTR s,
[out, retval] BSTR* pRetVal);
};
};
If we compare it with
old IDL now our class T is described with interface _T as last time but
there are all methods (some of them are inherited from Object).
If you like its possible to do things slightly differently, you can generate
tlb in one go using command regasm sample.dll /tlb:sample.tlb or you can
generate registry file and do registration manually using regasm str.dll
/regfile:sample.reg which looks like this
REGEDIT4
[HKEY_CLASSES_ROOT\T]
@="T"
[HKEY_CLASSES_ROOT\T\CLSID]
@="{4996A037-02BD-3839-A363-A9A321885D2C}"
[HKEY_CLASSES_ROOT\CLSID\{4996A037-02BD-3839-A363-A9A321885D2C}]
@="T"
[HKEY_CLASSES_ROOT\CLSID\{4996A037-02BD-3839-A363-A9A321885D2C}\InprocServer32]
@="C:\WINNT\System32\mscoree.dll"
"ThreadingModel"="Both"
"Class"="T"
"Assembly"="sample, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
"RuntimeVersion"="v1.0.3705"
[HKEY_CLASSES_ROOT\CLSID\{4996A037-02BD-3839-A363-A9A321885D2C}\ProgId]
@="T"
[HKEY_CLASSES_ROOT\CLSID\{4996A037-02BD-3839-A363-A9A321885D2C}\Implemented
Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}]
I hope this article cover
How we can Invoke Managed Code from Unmanaged Code., Pls lemmi noe your
comments and queries
Regards,
Smith
Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you
|
|