dullboy
May 11th, 2006, 08:29 AM
Here is my code.
// C++ server
typedef struct tagData
{
char* s;
int* pX;
}data;
void func2(LPVOID item)
{
data* pData = (data*)item;
*(pData->pX) = 9;
pData->s = "test";
}
void __declspec(dllexport) func(char* str, int& x)
{
data* pData = new data;
pData->s = str;
pData->pX = &x;
_beginthread(func2,0,pData);
}
// C++ Client
int main(int argc, char* argv[])
{
char* str = new char[100];
str = " ";
int x;
func(str, x);
MessageBox(NULL,NULL,str,MB_OK);
char s[30];
sprintf(s,"x=%d",x);
MessageBox(NULL,NULL,s,MB_OK);
return 0;
}
Actually, I am able to get the modified integer x but I couldn't get the modified string str from my C++ client. Can any guru help me how to fix the problem? Thanks so much in advance.
// C++ server
typedef struct tagData
{
char* s;
int* pX;
}data;
void func2(LPVOID item)
{
data* pData = (data*)item;
*(pData->pX) = 9;
pData->s = "test";
}
void __declspec(dllexport) func(char* str, int& x)
{
data* pData = new data;
pData->s = str;
pData->pX = &x;
_beginthread(func2,0,pData);
}
// C++ Client
int main(int argc, char* argv[])
{
char* str = new char[100];
str = " ";
int x;
func(str, x);
MessageBox(NULL,NULL,str,MB_OK);
char s[30];
sprintf(s,"x=%d",x);
MessageBox(NULL,NULL,s,MB_OK);
return 0;
}
Actually, I am able to get the modified integer x but I couldn't get the modified string str from my C++ client. Can any guru help me how to fix the problem? Thanks so much in advance.