DLL Function Call

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

Join Date: Oct 2008
Posts: 25
Reputation: uim_1977 is an unknown quantity at this point 
Solved Threads: 0
uim_1977 uim_1977 is offline Offline
Light Poster

DLL Function Call

 
0
  #1
Oct 27th, 2008
Hello !!!!

I'm callind a form from Dll it works jut pirfect, but i have no idea how it works, so now i need to add parameters to the function,so i can pass some parammeters to the form, and have no idea how to do this, any one can help??

  1. {
  2. 1 typedef void (*CALLEDFUNCTION) (TComponent* Owner);
  3. 2 CALLEDFUNCTION DllFunctionPtr;
  4. 3 AnsiString fDllName = "MyDll.dll";
  5. 4 AnsiString fFunctionName = "MyFunction";
  6. 5 AnsiString fMessage;
  7. 6 char fDllNameStr[50];
  8. 7 strcpy(fDllNameStr, fDllName.c_str());
  9. 8 HINSTANCE DLLInst = NULL;
  10. 9 DLLInst = LoadLibrary(fDllNameStr);
  11. 10 if (DLLInst) {
  12. 11 DllFunctionPtr = (CALLEDFUNCTION) GetProcAddress(DLLInst, unctionName.c_str());
  13. 12 if (DllFunctionPtr) DllFunctionPtr(this);
  14. 13 else {
  15. 14 fMessage = "Could not obtain pointer for function";
  16. 15 fMessage += fFunctionName;
  17. 16 fMessage += " in DLL ";
  18. 17 fMessage += fDllName;
  19. 18 }
  20. 19 }
  21. 20 else {
  22. 21 fMessage = "Could not load DLL ";
  23. 22 fMessage += fDllName;
  24. 23 Edit1->Text= fMessage;
  25. 24 }
  26. 25}

in line 3 is set the dll file name, in line 4 is set the function thet is defined and implemented in the dll file, it is a void MyFunction() now i need to run the same function but with parammeters, like void MyFunction(AnsiString A, TIBTable* IBTable1), how do i do this???
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,521
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: 1481
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: DLL Function Call

 
0
  #2
Oct 27th, 2008
First you will have to change the DLL to accept the parameters that you want. That means you will have to recompile the dll with the new set of parameters.
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: Oct 2008
Posts: 25
Reputation: uim_1977 is an unknown quantity at this point 
Solved Threads: 0
uim_1977 uim_1977 is offline Offline
Light Poster

Re: DLL Function Call

 
0
  #3
Oct 27th, 2008
I did recompile the dll it was the easiest think to do..
but it was hard for me ti figure out that i had to add a parameters in line 1 of the code and than add the parameters in line 12 it took me whole night.. but i got it by myself
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,521
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: 1481
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: DLL Function Call

 
0
  #4
Oct 27th, 2008
>>but i got it by myself
Great job Now you will easily remember that the next time you encounter that problem.
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: 978
Reputation: mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice 
Solved Threads: 208
mitrmkar mitrmkar is offline Offline
Posting Shark

Re: DLL Function Call

 
0
  #5
Oct 27th, 2008
About code tags ... you don't have to type in the line numbers in the code you post, just specify cplusplus as the syntax i.e.

[code=cplusplus]
// code pasted here ...
[/code]
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 25
Reputation: uim_1977 is an unknown quantity at this point 
Solved Threads: 0
uim_1977 uim_1977 is offline Offline
Light Poster

Re: DLL Function Call

 
0
  #6
Oct 27th, 2008
Thanks, a good tip, i've just started to use the forum, did not have enoff time to figer it all out. really a good sears for knowlage. i really aprisiate help on the site
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



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC