DLL and Application

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2007
Posts: 290
Reputation: kv79 is an unknown quantity at this point 
Solved Threads: 7
kv79 kv79 is offline Offline
Posting Whiz in Training

Re: DLL and Application

 
0
  #21
Dec 21st, 2007
Hi,
when i ->include linking as
errors


Circular Untitled2 <- Untitled2.o dependency dropped.

Circular Untitled2 <- Untitled2.o dependency dropped.


When i turn off linking i get 3 more files ,
.dll, .lib, .a
And when i use my WIN API file who is some were above.Get no errors.BUT i did not see message box ,and it was ON included linking.
Last edited by kv79; Dec 21st, 2007 at 3:25 pm. Reason: And "Makefile "
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 176
Reputation: dubeyprateek is an unknown quantity at this point 
Solved Threads: 22
dubeyprateek's Avatar
dubeyprateek dubeyprateek is offline Offline
Junior Poster

Re: DLL and Application

 
0
  #22
Dec 21st, 2007
Originally Posted by elite1986 View Post
Hi,
when i ->include linking as
errors


Circular Untitled2 <- Untitled2.o dependency dropped.

Circular Untitled2 <- Untitled2.o dependency dropped.


When i turn off linking i get 3 more files ,
.dll, .lib, .a
And when i use my WIN API file who is some were above.Get no errors.BUT i did not see message box ,and it was ON included linking.
Well I could not understand the errors. I don't know how do you add lib refreence in dev++. however you can use

#pragma comment(lib, "myfile.lib") in your cpp. It will autometicallty link the lib. After that you need not call the LoadLibrary. Just declare the prototype of function and call the function.
I know I am. Therefore I am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 176
Reputation: dubeyprateek is an unknown quantity at this point 
Solved Threads: 22
dubeyprateek's Avatar
dubeyprateek dubeyprateek is offline Offline
Junior Poster

Re: DLL and Application

 
0
  #23
Dec 21st, 2007
Did you tried the impliementation I suggested earlier ? What is the error code ?
I know I am. Therefore I am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 290
Reputation: kv79 is an unknown quantity at this point 
Solved Threads: 7
kv79 kv79 is offline Offline
Posting Whiz in Training

Re: DLL and Application

 
0
  #24
Dec 21st, 2007
Hi,
  1.  
  2. #include <windows.h>
  3. #pragma comment(lib, "myfile.lib")
  4. typedef void (*function1_ptr) ();
  5. function1_ptr function1=NULL;//Now create pointer and set its default value to NULL
  6.  
  7.  
  8. int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
  9.  
  10. HMODULE myDll = LoadLibrary("myfile.dll");
  11.  
  12. if(myDll) {
  13. //obtain the function address
  14. function1 = (function1_ptr)GetProcAddress(myDll,"function1");
  15. }
  16.  
  17. //use function where needed, but check before
  18. if(function1)
  19. function1();
  20.  
  21. //finally free library
  22. FreeLibrary(myDll);
  23.  
  24.  
  25. return 0;
  26. }
Had no errors and i have not seen message box
Last edited by kv79; Dec 21st, 2007 at 8:23 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 290
Reputation: kv79 is an unknown quantity at this point 
Solved Threads: 7
kv79 kv79 is offline Offline
Posting Whiz in Training

Re: DLL and Application

 
0
  #25
Dec 21st, 2007
I am now really confused ,
Were to go to understand these dll,
When i seen MSDN i understud 2 types but when i seen code it is really confusing.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 290
Reputation: kv79 is an unknown quantity at this point 
Solved Threads: 7
kv79 kv79 is offline Offline
Posting Whiz in Training

Re: DLL and Application

 
0
  #26
Dec 22nd, 2007
Hi,
I am really sorry it is my mistake.
It is working ,i get a message only when i put a
dll in same directory where is my exe and correct the names of .dll look up there code.

Thank you all for your effort for trying help me but basicly i needed to help my self.

But one or two more question 's what i do not understand.
1)When i writeing program in other language can i use dll or not?
2)It is his mistake or MSND

http://www.apitalk.com/document.php?id=1184209001_1
http://support.microsoft.com/kb/815065

Because he call this EXPLICITE and but msdn not.
3)MSND call load-time dyna... EXPLICIT
is it mind that run-time dyna... IMPLICIT?
4)When i use load-time is it mind when i load first time i do not need anymore dll?
5)Can i use any windows XP dll's?
6)What i need to do to attach another dll with this one?Do i need any other knowlage?
7)
if(function1)
function1();
Why the program won't work right without this ?
8)How to create different moduls in point of
runing faster programs.OR separate moduls.
9)I downloaded Visual C++ 2005 Expres Edition ,why i can't make a project ,what to do reslove that?
Last edited by kv79; Dec 22nd, 2007 at 1:16 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,401
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1467
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: DLL and Application

 
0
  #27
Dec 22nd, 2007
>>I downloaded Visual C++ 2005 Expres Edition ,why i can't make a project ,what to do reslove that?

To create a project: select menu File -->New -->Project, then set Project Type to Win32 and Visual Studio Installed Templates to Win32 Console Application. At the bottom of the screen enter the project name and select the desired location. Finally on that window press the Ok button.

The next window to appear is the Application Settings window. Select Console Application and press the Finish button.

All done.
Last edited by Ancient Dragon; Dec 22nd, 2007 at 7:12 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 290
Reputation: kv79 is an unknown quantity at this point 
Solved Threads: 7
kv79 kv79 is offline Offline
Posting Whiz in Training

Re: DLL and Application

 
0
  #28
Dec 22nd, 2007
It's working but only when i put
in additional option ,empty project.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,951
Reputation: Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of 
Solved Threads: 214
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: DLL and Application

 
0
  #29
Dec 22nd, 2007
1)When i writeing program in other language can i use dll or not?
Yes, you can use a DLL in any language. The trick is only to match the correct "calling convention". Google it and read more about it. Most Windows DLLs have "stdcall" calling convention.

2)It is his mistake or MSND ... Because he call this EXPLICITE and but msdn not.
Both are correct. The difference between explicit and implicit linking is just whether or not the compiler links for you. For example, when writing windows programs, if you include <windows.h> then you can use all kinds of functions found in Windows DLLs without having to explicitly say which DLLs you want to use.

3)MSND call load-time dyna... EXPLICIT is it mind that run-time dyna... IMPLICIT?
This is non-sequitur. If you use LoadLibrary() then that is run-time loading. Otherwise it is load-time loading. This is a fairly simple, but technical issue. You shouldn't need worry about it.

The main interest for the programmer is that if a load-time DLL is not found, your program will not run. However, a run-time DLL (loaded with LoadLibrary()) allows you to choose whether to continue execution or not.

4)When i use load-time is it mind when i load first time i do not need anymore dll?
I don't understand your question.

5)Can i use any windows XP dll's?
Sure, why not?

6)What i need to do to attach another dll with this one?Do i need any other knowlage?
DLLs are separate things. One DLL may use another DLL, just as your EXE may use a DLL, but they are still separate, self-contained things.

7)
if(function1)
function1();
Why the program won't work right without this ?

It is possible that the DLL you loaded doesn't have the requested function. You must check to make sure that the function exists before you use it.

Keep in mind that you are really using a C shortcut here. "function1" is a pointer to a function. So first you test to see if the pointer is not NULL, and if not, then you call the function. To be absolutely explicitly correct it should read:
if (function1 != NULL) (*function1)();
C and C++ are nice and let you write it a shorter way:
if (function1) function1();

8)How to create different moduls in point of runing faster programs.OR separate moduls.
It makes no difference. (That is, if I understand your question correctly.)

Good luck!
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 290
Reputation: kv79 is an unknown quantity at this point 
Solved Threads: 7
kv79 kv79 is offline Offline
Posting Whiz in Training

Re: DLL and Application

 
0
  #30
Dec 22nd, 2007
Thank you all of you for makeing something clear.
Last edited by kv79; Dec 22nd, 2007 at 7:52 pm.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC