[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 405
  • Last Modified:

Registred DLL

Hi,

I'm using VC60. How can I open registred DLL? DLL developed using VB.
Dumpbin shows (with "/exports"):
          1    0 00044B0A DllCanUnloadNow
          2    1 00044ADE DllGetClassObject
          3    2 00044AF4 DllRegisterServer
          4    3 00044AC8 DllUnregisterServer
CLSID is {0x3A62424F,0xE9D5,0x11D3,{0x9C,0x5A,0x00,0x20,0x18,0x8C,0xA3,0x65}}
How can I open this dll, get object and work with this object (call methods)?

Thanks
0
mahno
Asked:
mahno
  • 4
  • 2
1 Solution
 
WynCommented:
Those exported functions are not used in our programs.They are called by system and tools.

After it gets registered.

To use it ,basically the process is as follows:

1) Call OleInitialize() or CoInitialize() from your program.

2) Use CoCreateInstance() to get the object's IUnknown interface. You'd specify the CLSID and IID.You can get from friendly name by using ) Use CLSIDFromProgID().

3) Then you can quiry interface you want by calling QueryInterface() function through IUnknown pointer or get it directly from 2)

4) Now,you can call functions you want throught interface pointers.
pinter->somefunc().

Hope helpful.

Free to ask.

Regards.

0
 
mahnoAuthor Commented:
Adjusted points from 50 to 100
0
 
mahnoAuthor Commented:
Thanks Wyn,

Can U please clearify for me

In my Registry I have key:
HKEY_CLASSES_ROOT\SomeName.clSomeName
(default) SomeName.clSomeName

HKEY_CLASSES_ROOT\SomeName.clSomeName\Clsid
(defoult) {3A62424F-E9D5-11D3-9C5A-0020188CA365}

In my program:

  HRESULT hResult;
  CLSID clsid = {0x3A62424F,0xE9D5,0x11D3,{0x9C,0x5A,0x00,0x20,0x18,0x8C,0xA3,0x65}};
  LPVOID *ppv = new (LPVOID);
  IID iid; //?What this?

  hResult = OleInitialize(NULL); //OK
  hResult = CoCreateInstance((REFCLSID)clsid, //Right?
            NULL, //Right?
            CLSCTX_LOCAL_SERVER, //Right?
            (REFIID)iid, //What this?
            ppv //Right?
            );
Is it right?

And one more question:
How can I use CLSIDFromProgID()?
lpszProgID should contain "SomeName.clSomeName"?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
wardkdCommented:
There is a much easier way to do this using classWizard which will create a wrapper class in your project:
1. Call up classWizard
2. Take "Add class"
3. Take "from a type library"
4. Navigate to your dll and hit enter on everything else.

This will create a new pair of files containing the new class.

Simply instantiate this class and call the member functions directly.
0
 
mahnoAuthor Commented:
Hi wardkd,

I try Ur method, It's create new class with my functions; But when I try to start this funstions nothing wrong. In generated source files there are no places where my DLL attaches (or CLSID?)

Why? May be I something forgot?
Or I need to attach DLL by myself?

To Wyn:
U can't tell me where I mistaken? Or put some code (may from Ur project)

ps: I want to know both methods (using CoCreateInstance() and using Class Wizard). I give points to you both.

Thanks,
  mahno
0
 
WynCommented:
->LPVOID *ppv = new (LPVOID);
IID iid; //?What this?
=========================
The IID structure is a GUID structure used to describe an identifier for a  interface.
Here is GUID structure:
typedef struct _GUID
{
    unsigned long        Data1;
    unsigned short       Data2;
    unsigned short       Data3;
    unsigned char        Data4[8];
} GUID;
 



->And one more question:
How can I use CLSIDFromProgID()?
lpszProgID should contain "SomeName.clSomeName"?
===============================
CLSIDFromProgID() looks up a CLSID in the registry, given a ProgID.

Here is signature:

HRESULT CLSIDFromProgID(
  LPCOLESTR lpszProgID,  //Pointer to the ProgID
  LPCLSID pclsid         //Pointer to the CLSID
);

So you'd use it this way:

// Get the CLSID for the application.
/////////////////////////////////////

//You should know the progid.      
wchar_t progid[] = L"Myapplication.version1" ;
      CLSID clsid ;
       CLSIDFromProgID(progid, &clsid) ;

//Here you get the clsid and you can use it in the CoCreateInstance().

========================================
mahno ,here is a sample I just rearrange to use a com object ,this com contains a class Iface which has two interface ,IX and IY.
Check it:

============

// Client.cpp

#include <iostream.h>
#include <objbase.h>

#include "Iface.h"

// {32bb8320-b41b-11cf-a6bb-0080c7b2d682}
const IID IID_IX =
      {0x32bb8320, 0xb41b, 0x11cf,
      {0xa6, 0xbb, 0x0, 0x80, 0xc7, 0xb2, 0xd6, 0x82}} ;

// {32bb8321-b41b-11cf-a6bb-0080c7b2d682}
const IID IID_IY =
      {0x32bb8321, 0xb41b, 0x11cf,
      {0xa6, 0xbb, 0x0, 0x80, 0xc7, 0xb2, 0xd6, 0x82}} ;

const CLSID CLSID_Iface =
      {0x0c092c21, 0x882c, 0x11cf,
      {0xa6, 0xbb, 0x0, 0x80, 0xc7, 0xb2, 0xd6, 0x82}} ;

//
// main function
//
int main()
{
      // Initialize COM Library
      CoInitialize(NULL) ;
      IX* pIX = NULL ;
//Here you get the IX pointer
HRESULT hr = ::CoCreateInstance(CLSID_Iface,
 NULL,
 CLSCTX_INPROC_SERVER,
 IID_IX,
 (void**)&pIX) ;
            
// Use interface IX.
    pIX->Fx() ;          

//now,let's get the IY interface pointer
        IY* pIY = NULL ;
        hr = pIX->QueryInterface(IID_IY, (void**)&pIY) ;
//call IY functions

     pIY->Fy() ;       // Use interface IY.
  //You'd release them.      
            pIY->Release() ;
            pIX->Release() ;

      // Uninitialize COM Library
      CoUninitialize() ;

      return 0 ;
}


////////////////////////////////////

Sincerely hope above helpful.

Regards
W.Yinan




0
 
mahnoAuthor Commented:
Thanks Win, thanks wardkd

My program works with both methods

regards,
  mahno
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now