Hello everybody.
i was created COM project. I want invoke the COM object interface by VC,VB,Javascript.....etc.
but my project problems. i'm create the *.idl files. Invoke the MIDL command make to the *.tlb.
what about the tlb import to the DLL resource?????

i'm invoke the object in VC++,but is failed. :sad:

//------------------------------------------------------------------------------------------------------------------------------------------------
IID IID_IHEC_Designer = {0x971E5760, 0x9186, 0x4DAE,{0xA7, 0x28, 0xDE, 0xFE, 0xAD, 0x34, 0xD0, 0xFD}};
CLSID CLSID_HEC_Designer = {0x18D2B8E7, 0x103D, 0x40EA,{0xBE, 0x63, 0x34, 0x70, 0x6B, 0xD7, 0x34, 0x76}};

HRESULT hr;
IUnknown *pUnk = NULL;
IDispatch *pDis = NULL;
hr = CoCreateInstance(CLSID_HEC_Designer, NULL, CLSCTX_INPROC_SERVER, IID_IHEC_Designer, (void**)&pUnk);

if(FAILED(hr))
{

return S_OK;
}

if(pUnk==NULL)
{
::MessageBox(NULL,"pUnk==NULL",NULL,NULL);
return S_OK;
}

if(FAILED(pUnk->QueryInterface(IID_IDispatch,(void**)&pDis)))
{
::MessageBox(NULL,"DISPATH FAILD",NULL,NULL);
return S_OK;
}

DISPID dispid;
OLECHAR* func = L"Detach";
if (FAILED(pDis->GetIDsOfNames(IID_NULL, &func, 1, GetUserDefaultLCID(), &dispid)))
{
::MessageBox(NULL,"GETIDSOFNAMES FAILED",NULL,NULL);
return S_OK;
}

LONG lTest = 123;

DISPPARAMS dispparams;
memset(&dispparams, 0, sizeof dispparams);
dispparams.cArgs = 1;
dispparams.rgvarg = new VARIANT;

dispparams.rgvarg[0].vt = VT_I4;
dispparams.rgvarg[0].lVal = lTest;


dispparams.cNamedArgs = 0;
EXCEPINFO excepInfo;
memset(&excepInfo, 0, sizeof excepInfo);
CComVariant vaResult;
UINT nArgErr = (UINT)-1;


if (FAILED(pDis->Invoke(dispid, IID_NULL,GetUserDefaultLCID(), DISPATCH_METHOD, &dispparams,&vaResult,&excepInfo,&nArgErr)))
{
::MessageBox(NULL,"INVOKE FAILED",NULL,NULL);
return S_OK;
}

return S_OK;

//----------------------------------------------------------------------------------------------------------------------------------------

what about to modified the project . thanks.

this is my Project
Attachments:
Posted on 2005-07-06 05:37:52 by AirSky

Some remarks:

1. this is an ASM forum and your project is in C
2. there are many good C forums in the net, and there are thousands of COM samples written in VC
3. Please don''t tell us that your project has problems and leave the rest to the reader to find out!
4. > what about the tlb import to the DLL resource?????
  If you mean how to add your .TLB file to your DLL:
  - create a .RC file to be compiled (by RC) and added to your dll (by the linker, in case you dont know)
  - your .RC file should contain a line: 1 TYPELIB MOVEABLE PURE "xxxx.TLB"
    where xxxx.TLB is the file created by MIDL

Regards

Japheth
Posted on 2005-07-07 07:35:06 by japheth
http://support.microsoft.com/kb/q194873/
Posted on 2005-07-07 07:59:19 by comrade


Some remarks:

1. this is an ASM forum and your project is in C
2. there are many good C forums in the net, and there are thousands of COM samples written in VC
3. Please don''t tell us that your project has problems and leave the rest to the reader to find out!
4. > what about the tlb import to the DLL resource?????
? ?If you mean how to add your .TLB file to your DLL:
? ?- create a .RC file to be compiled (by RC) and added to your dll (by the linker, in case you dont know)
? ?- your .RC file should contain a line: 1 TYPELIB MOVEABLE PURE "xxxx.TLB"
? ? ?where xxxx.TLB is the file created by MIDL

Regards

Japheth



Thanks.
er.........

But my project is an ASM project (HECHernel.zip). 
invoke in VC is a test.
I  Want written in ASM COM project  invoke  by VC,Javascript,VB etc.......
Posted on 2005-07-10 19:39:01 by AirSky