Click here to Skip to main content
15,173,031 members
Please Sign up or sign in to vote.
5.00/5 (3 votes)
See more:
Hi All,
I spend Last 45 days to deal with dll i got lots of advantages of dll for my big project management.
As Well as in every 2 Hours I got new milestone problem.

Problem :-
I used dll function with _descpsec(dllexport)Which work greate,
Now lets consider following scenerio,

A function called TwoString()Normal dll function that fill strings in dll.
extern "C" __descspec(dllexport)void WINAPI TwoString(CString* First,CString* Second)
   Cstring tempstr,tempstr1;

This dll function works greate now,
As i passed the pointer as function argument then string of that pointer must be updated.

Lets take following function call
CString Name,Surname;

As I thing values of Name and Surname should change after DLL Called.

but Not Changed.
I have try:
1)I doesn't want implement structure or StringArray for return value.
2)Function can return only one values.
3)When i debug program pointers of Name And Surname not changed untill
All related helps,Links,codeblocks,suggestions are welcome.
Updated 23-Mar-11 1:10am

Try (i.e remove the addressof operators):
Cstring tempstr,tempstr1;
tempstr = "SANTOSH";
*First = tempstr;
tempstr1 = "DHANAWADE";
*Second = tempstr1;

Alternatively use references rather than pointers.

[edit]Added Carlo's fixes.[/edit]
[no name] 23-Mar-11 5:16am
How i can assign refernce to pointer
Richard MacCutchan 23-Mar-11 6:38am
You don't; you use the reference operator in your calling code and in the dll you treat the parameters as objects rather than pointers. Check your C++ notes for more detail.
CPallini 23-Mar-11 6:14am
Richard you forgot a couple of stars. Alternatively stars forgot you... :-)
Richard MacCutchan 23-Mar-11 6:36am
Thank you, not enough coffee this morning.
*First = "SANTOSH";
*Second = "DHANAWADE";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900