com object, [out] params (pointers to values), C#
-
I have a COM object written in C++. I want to use it from C#. For getting values out of the COM object I used functions like: HRESULT myfunction (/*[out]*/ BSTR* stringvalue, /*[out]*/ int* intvalue); How can I use these functions from c#? -Alma-
After you add a reference to your COM dll you will see the IntelliSence info for its COM objects. Also, you could just go to the Object Browser and check how the syntax looks like. Your function will probably translate into this:
void myfunction(ref string stringvalue, ref int intvalue);
Alexandre Kojevnikov MCAD charter member Leuven, Belgium -
After you add a reference to your COM dll you will see the IntelliSence info for its COM objects. Also, you could just go to the Object Browser and check how the syntax looks like. Your function will probably translate into this:
void myfunction(ref string stringvalue, ref int intvalue);
Alexandre Kojevnikov MCAD charter member Leuven, BelgiumIn the object browser my functions syntax looks this way: HRESULT _stdcall MyGetValue([out] int* value); IntelliSence info looks like this: void MyGetValue(out int value); whatever I put as a parameter it results in an error: The best overloaded method match for 'MYComObjectDllLib.IMyObject.MyFunction(out int)' has some invalid arguments -Alma-
-
In the object browser my functions syntax looks this way: HRESULT _stdcall MyGetValue([out] int* value); IntelliSence info looks like this: void MyGetValue(out int value); whatever I put as a parameter it results in an error: The best overloaded method match for 'MYComObjectDllLib.IMyObject.MyFunction(out int)' has some invalid arguments -Alma-
The calling code should look like this:
int myValue;
myCOMObject.MyGetValue(out myValue);Alexandre Kojevnikov MCAD charter member Leuven, Belgium
-
The calling code should look like this:
int myValue;
myCOMObject.MyGetValue(out myValue);Alexandre Kojevnikov MCAD charter member Leuven, Belgium