C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 19th, 2003, 05:29 PM
Combat Combat is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 42 Combat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
using multiple dlls

i need to use multiple dlls, they dont have to intercommunicate. any body know how to get my executable to use them?

Reply With Quote
  #2  
Old May 19th, 2003, 08:53 PM
Combat Combat is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 42 Combat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
Doesnt anybody know this?

Reply With Quote
  #3  
Old May 19th, 2003, 11:40 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,402 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 8 h 53 m 6 sec
Reputation Power: 4080
What development environment are you using? Visual C++ or Borland C++. Also, are these Active-X DLLs or plain old DLLs?

Reply With Quote
  #4  
Old May 20th, 2003, 02:00 AM
Combat Combat is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 42 Combat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
sorry i wasnt clearer before, im using Dev-C++ and just plain old dlls will do fine.

Reply With Quote
  #5  
Old May 20th, 2003, 04:54 AM
TechNoFear TechNoFear is offline
Offensive Member
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2002
Location: in the perfect world
Posts: 618 TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 13 h 50 m
Reputation Power: 26
implicit (at run, easiest but whole app will fail if DLL not found) or explicit (as needed) linking?

Look at LoadLibrary(), GetProcAddress()

here is a quick example to explicitly load the function TrackMouseEvent() from the user32.dll

Code:
//define a funtion type
typedef BOOL (CALLBACK * TEST)(LPTRACKMOUSEEVENT);
//declare an instance of this function type
TEST				Test_TrackMouseEvent;
//DLL handle
HANDLE   hTME=NULL:

//ensue we are where the DLL will be found
SetCurrentDirectory(szDLLInThisDirectory);
//load up the DLL
hTME=LoadLibrary(".\\user32.dll");
if (hTME!=NULL)
{
//get the function we want and lock to our function pointer	
Test_TrackMouseEvent=(TEST)GetProcAddress(hTME,"TrackMouseEvent");

//error check
if(Test_TrackMouseEvent==NULL)
{
	iError=GetLastError();
}
//use if no error


//free library after use
FreeLibrary(hTME);
__________________
The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

Frank Zappa

Reply With Quote
  #6  
Old May 20th, 2003, 01:06 PM
Combat Combat is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 42 Combat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
Smile

wow, thanks so much!

Reply With Quote
  #7  
Old June 1st, 2003, 05:26 PM
Combat Combat is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 42 Combat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
Well i tried this now and i had a few problems. I fixed a typo and got rid of iError. Now ANSI C++ is causing me some problems. I get two Errors:

ANSI C++ forbids implicit conversion from `void *' in argument passing


ANSI C++ forbids implicit conversion from `void *' in argument passing

One points to this:


Code:
hTME=LoadLibrary(".\\user32.dll");


and this:



Code:
FreeLibrary(hTME);


Does anybody have any idea of how to fix this? remember i am using Dev-C++.

Reply With Quote
  #8  
Old June 1st, 2003, 11:09 PM
Combat Combat is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 42 Combat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
Doesn't anybody know how to make this ANSI compliant???

Reply With Quote
  #9  
Old June 2nd, 2003, 11:47 AM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 94
well i've never used Dev-C++ but if i got that error i would try casting those arguments to (void *).

Reply With Quote
  #10  
Old June 2nd, 2003, 06:28 PM
Combat Combat is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 42 Combat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
i found out what the problem was:
it doesnt like HANDLE hTME=NULL;

i got rid of hTME and only check if it loads the function (close enough) but now it doesnt load the dll. oh, i also got rid of SetCurrentDirectory(szDLLInThisDirectory);
szDLLInThisDirectory was undefined, i didnt feel like defining it and i dont think it really needs it.

Is there something i need to do different in the dll to make it load that function?

Reply With Quote
  #11  
Old June 2nd, 2003, 09:15 PM
TechNoFear TechNoFear is offline
Offensive Member
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2002
Location: in the perfect world
Posts: 618 TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 13 h 50 m
Reputation Power: 26
The dangers of using code you do not understand.............Each line has a specific and at times essential purpose.

SetCurrentDirectory(szDLLInThisDirectory);

Ensures you are in the folder the DLL is in. I use GetCurrentDirectory() to 'fill in' szDLLInThisFolder as the app starts and keep as a global. I included it to show you that you must set the full path or set the app to look in the folder containing the DLL.

hTME=LoadLibrary(".\\user32.dll");

This actually loads the DLL. Without it you can't lock the functions down with GetProcAddress()

I seem to have led you astray. hTME should have been a HMODULE not a HANDLE (but HANDLE will work).

If you still get the error try a cast back to the type you want ie HMODULE
HINSTANCE will also work as HMODULE is a #define of HINSTANCE.

hTME = (HMODULE)LoadLibrary( ".\\user32.dll" );

or

hTME = (HANDLE)LoadLibrary( ".\\user32.dll" );

FreeLibrary(hTME);

is also essential as it frees the memory and resoucres associated with the DLL.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > using multiple dlls

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap