[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to use a DLL without the *.h and *.lib files...

Posted on 2001-06-06
6
Medium Priority
?
414 Views
Last Modified: 2013-11-20
I understand that to use a DLL, i should have a *.lib and a *.h file along with the dll file... Is there a way i can use a dll without the other two files present?  I want to use an existing dll, problem is there are no .lib and .h files available for the dll...

Im new at this... please help...

Thanks...
0
Comment
Question by:3Mann
[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
  • 3
  • 2
6 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 6159864
You need to know the parameters for any functions you need in the DLL but you DO NOT need any .lib or .h files to use a DLL.

You can load the DLL using LoadLibrary() and find any function in it using GetProcAddress().

After that, however, it's up to you to make sure you call the functions with the proper calling convention, proper parameters, and proper return type.  That's where the .h file is very handy.  The .lib file has export information that the linker can use to make this almost transparent.

But....neither of these are required.
0
 
LVL 1

Author Comment

by:3Mann
ID: 6162068
Jhance,
Thanks for the info... But im new at this...
Im trying to create an OCX...  Where would i be calling LoadLibrary()?  Should it be in the initInstance method?

btw, im increasing my points... this seems hard... (for me anyway... =))
0
 
LVL 1

Author Comment

by:3Mann
ID: 6162078
cont...

Or would it be in the constructor for the control...
if it can be placed in both methods... where would it be most adviceable...

Thanks again...
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 

Accepted Solution

by:
gilad_no earned 300 total points
ID: 6164461
Suppose you have a dll called: MYDLL.DLL and a function:

int Test(CString szStr,int nX,int nY);


you need to add the following code:

typedef int (TestProc)(CString,int,int);
HINSTANCE hLib=LoadLibrary("MYDLL.DLL")
if (hLib==NULL)
 return;
TestProc *Test=(TestProc*)GetProcAddress(hLib,"Test");
if (Test!=NULL)
{   // Here we will call the function
   CString szStr("Test string");
   int x=0,y=0;
   int result=(*Test)(szStr,x,y);
{
FreeLibrary(hLib);
0
 

Expert Comment

by:gilad_no
ID: 6164470
cont...

If you use the "Test" function many times, you can load the library in the constructor and free it in the destructor.
If you intend to use it once, you can load it, use it and free it from memory. This will save system resources
0
 
LVL 1

Author Comment

by:3Mann
ID: 6170012
what a complete answer...
i have to also give credit to jhance also...
thanks jhance... but if its ok.. im giving my points to gilad...

btw, i already acquired a .h and a .lib... so this lessens my prob... =)
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

649 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