943,719 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 334
  • C++ RSS
Mar 25th, 2009
0

Can't use a DLL inside my executable

Expand Post »
OK so I got my executable file that should load all the functions from
"message.dll" so I can use them.

But every time I run my executable file I am getting an error that say my executable is encountered problems and its should be closed than its being closed.

Here is my executable source

C++ Syntax (Toggle Plain Text)
  1.  
  2.  
  3. #include <windows.h>
  4. #include <stdio.h>
  5.  
  6. int main () {
  7.  
  8. /*Typedef the hello function*/
  9. typedef void (*pfunc)();
  10.  
  11. /*Windows handle*/
  12. HINSTANCE HandleDLL;
  13.  
  14. /*A pointer to a function*/
  15. pfunc hello;
  16.  
  17. /*LoadLibrary*/
  18. HandleDLL = LoadLibrary("message.dll");
  19.  
  20. /*GetProcAddress*/
  21. hello = (pfunc)GetProcAddress(HandleDLL,"hello");
  22.  
  23. /*Call the function*/
  24. hello();
  25. return 0;
  26. }

And this is what the hello function suppose to do
source from the dll

C++ Syntax (Toggle Plain Text)
  1. __declspec(dllexport) void hello()
  2.  
  3. {
  4. MessageBox (0, "Hello from injected DLL!\n", "Hi", MB_ICONINFORMATION);
  5. }
Any ideas why my exe crashes when I run it?
Last edited by laconstantine; Mar 25th, 2009 at 6:09 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
laconstantine is offline Offline
70 posts
since May 2007
Mar 25th, 2009
0

Re: Can't use a DLL inside my executable

Listen guys i just discovered that the problem comes when I try to use the hello function from the dll.


any ideas?? please?
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
laconstantine is offline Offline
70 posts
since May 2007

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: array help
Next Thread in C++ Forum Timeline: Waiting till another exe file finishes





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


Follow us on Twitter


© 2011 DaniWeb® LLC