943,793 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 1053
  • C++ RSS
Oct 27th, 2008
0

DLL Function Call

Expand Post »
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??

C++ Syntax (Toggle Plain Text)
  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???
Similar Threads
Reputation Points: 46
Solved Threads: 0
Light Poster
uim_1977 is offline Offline
25 posts
since Oct 2008
Oct 27th, 2008
0

Re: DLL Function Call

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Oct 27th, 2008
0

Re: DLL Function Call

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
Reputation Points: 46
Solved Threads: 0
Light Poster
uim_1977 is offline Offline
25 posts
since Oct 2008
Oct 27th, 2008
0

Re: DLL Function Call

>>but i got it by myself
Great job Now you will easily remember that the next time you encounter that problem.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Oct 27th, 2008
0

Re: DLL Function Call

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]
Reputation Points: 1105
Solved Threads: 389
Posting Virtuoso
mitrmkar is offline Offline
1,714 posts
since Nov 2007
Oct 27th, 2008
0

Re: DLL Function Call

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
Reputation Points: 46
Solved Threads: 0
Light Poster
uim_1977 is offline Offline
25 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Average and sum with array
Next Thread in C++ Forum Timeline: C++ how to create this program?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC