Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,928 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,795 people online right now. Registration is fast and FREE... Join Now!




pass char string from dll to messagebox

 
Reply to this topicStart new topic

pass char string from dll to messagebox

AntiBNI
20 Jan, 2008 - 11:57 AM
Post #1

D.I.C Head
**

Joined: 21 Jul, 2006
Posts: 62


My Contributions
I have a small question,i want to display a messagebox with text defined in a char string in a dll.

like so:
dll.cpp

CODE
__declspec(dllexport) void Links(char* test)
{
test="this is just a test";
}


dll.h
CODE

#include "windows.h"

__declspec(dllexport) void Links();


now the Dialog:

testDlg.cpp

CODE

#include "dll.h"

**all the code created automatically by MFC**

void CtestDlg::OnButton1()
{
Links();
//show text string from dll into the messagebox
MessageBox(test,"Test",MB_OK);
}


I want to show the char* text that i specified in the dll into the messagebox.

thanks,help will be appreciated.
User is offlineProfile CardPM
+Quote Post

skaoth
RE: Pass Char String From Dll To Messagebox
21 Jan, 2008 - 01:18 PM
Post #2

D.I.C Regular
Group Icon

Joined: 7 Nov, 2007
Posts: 356



Thanked: 12 times
Dream Kudos: 100
My Contributions
What you can do is use the LoadLibrary() and GetProcAddress() combination.

You may need to have the Kernel32.lib built with you program if it isn't
already being linked in.

Also be aware of the calling conventions (I can't remember what they are)
as c++ tends to mangle up names.
User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 03:15PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month