Solved

Registred DLL

Posted on 2000-03-21
7
397 Views
Last Modified: 2010-04-10
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
Comment
Question by:mahno
  • 4
  • 2
7 Comments
 
LVL 5

Accepted Solution

by:
Wyn earned 100 total points
ID: 2639244
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
 
LVL 1

Author Comment

by:mahno
ID: 2639531
Adjusted points from 50 to 100
0
 
LVL 1

Author Comment

by:mahno
ID: 2639532
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:wardkd
ID: 2639723
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
 
LVL 1

Author Comment

by:mahno
ID: 2639886
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
 
LVL 5

Expert Comment

by:Wyn
ID: 2641130
->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
 
LVL 1

Author Comment

by:mahno
ID: 2643500
Thanks Win, thanks wardkd

My program works with both methods

regards,
  mahno
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now