CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 1999
    Posts
    3

    Using Class Wrappers for COM DLL

    I have created a project that uses raw COM to get IDispatch and then Interface pointers.

    Now I want to create C++ Class Wrappers and make life much easier.

    I have done the following to accomplish my goal:

    In MSVC++ 6 select View|ClassWizard .... then select "Add Class" button then "From Type Library..". Enter path for COM DLL, and select all classes and then press OK. The CPP and H files are created with my class wrappers.

    Then I use CoCreateInstance() as in like:

    HRESULT hr = CoCreateInstance(CLSID_mySystem,NULL,CLSCTX_INPROC_SERVER |
    CLSCTX_LOCAL_SERVER,IID_IADSystem,(void**)&pIMyObj);

    Then I try to use a method like:
    pIMyObj->Connect( vObject );

    I receive an access denied whatever method I try to call. I have traced the problem through to the Invoke function where the exception is received.

    If anyone has done this before I would greatly appreaciate some advice of where to proceed from here.

    Thanks in advance!

    Russ


  2. #2
    Join Date
    May 1999
    Posts
    3

    Re: Using Class Wrappers for COM DLL

    One little detail I forgot to meantion. I am using the COM interface from a JNI DLL.

    I have things working using the raw COM. I am just trying to get them working with the Class wrappers.

    Russ


  3. #3
    Join Date
    Apr 1999
    Posts
    27

    Re: Using Class Wrappers for COM DLL

    do you check the HRESULT hr = CoCreateInstance(CLSID_mySystem,NULL,CLSCTX_INPROC_SERVER |
    CLSCTX_LOCAL_SERVER,IID_IADSystem,(void**)&pIMyObj)successfully?

    Do you pass the correct parameters to that method?
    pIMyObj->Connect( vObject );

    In fact , sometime needn't export the type library, just include .h and define the interface,
    you can get method through the direct way(
    no use IDispath), most interface in system
    are dual interface.


  4. #4
    Join Date
    May 1999
    Posts
    3

    Re: Using Class Wrappers for COM DLL

    Thanks for the response.

    To answer your questions Yes, and Yes. hr was 0(zero) and the correct parameters were being passed.

    In the mean time, it looks Iike I got things working.

    The solution was to take the pIMyObj returned from CoCreateInstance and do the following:

    DIADClass TempClass(pIMyObj);

    Then do:
    TempClass.Connect(vObject);

    It looks like it is now working!!

    Thanks again for the response!

    Russ



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured