G
Guest
I am currently trying to pass a string (two actually; sResponse and sErrMsg
in the code) by reference from a C# windows application to a (managed) C++
dll and the main goal is to change the value of the string in the C++ code.
I understand that C# by default passes by value so therefore you must use
"ref" or "out" to make the reference. I am unable to do this because Visual
Studio 2003 does not recognize that (I think) the method I am calling
(httpGet) uses pass by reference. Also no matter how I reference the string
in the C++ code I cannot change the value of the string itself.
Any help at all will be greatly appreciated.
This is my C# code and below it is my C++ code
private void button1_Click(object sender, System.EventArgs e)
{
string sURL = textBox1.Text;
string sResponse = "this is a test";
int nResult = 0;
string sErrMsg = "2";
WCRobotInternet test = new WCRobotInternet();
bool result = test.httpGet(sURL, sResponse, nResult, sErrMsg);
label1.Text = sResponse;
label2.Text = sErrMsg;
}
bool WCRobotInternet::httpGet(String* sURL, String& sResponse, int nResult,
String& sErrMsg)
{
sResponse = ?
sErrMsg = ?
}
Thanks
in the code) by reference from a C# windows application to a (managed) C++
dll and the main goal is to change the value of the string in the C++ code.
I understand that C# by default passes by value so therefore you must use
"ref" or "out" to make the reference. I am unable to do this because Visual
Studio 2003 does not recognize that (I think) the method I am calling
(httpGet) uses pass by reference. Also no matter how I reference the string
in the C++ code I cannot change the value of the string itself.
Any help at all will be greatly appreciated.
This is my C# code and below it is my C++ code
private void button1_Click(object sender, System.EventArgs e)
{
string sURL = textBox1.Text;
string sResponse = "this is a test";
int nResult = 0;
string sErrMsg = "2";
WCRobotInternet test = new WCRobotInternet();
bool result = test.httpGet(sURL, sResponse, nResult, sErrMsg);
label1.Text = sResponse;
label2.Text = sErrMsg;
}
bool WCRobotInternet::httpGet(String* sURL, String& sResponse, int nResult,
String& sErrMsg)
{
sResponse = ?
sErrMsg = ?
}
Thanks