Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Registred DLL

Posted on 2000-03-21
7
Medium Priority
?
404 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 5

Accepted Solution

by:
Wyn earned 400 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

636 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