Solved

Registred DLL

Posted on 2000-03-21
7
396 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

707 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

17 Experts available now in Live!

Get 1:1 Help Now