I'm using Com Interop method to communicate with unmanaged C++ and C#.
I need to send data to unmanaged C++ from C#.
Im already sending "bool" values values from C# & accessing it through "VARIANT_BOOL*" in c++.
I need to send a integer from C#. How can i access that integer value in unmanaged c++ side ?
for example:
C#
public int myValue()
{
return 5;
}
Unmanaged C++
CoInitialize(NULL);
MyNSpace::MyClassPtr IMyPointer;
HRESULT hRes = IMyPointer.CreateInstance(MyNSpace::CLSID_MyClass);
if (hRes == S_OK)
{
//// ??? define x type
IMyPointer->myValue(x);
}
VT_I4. But keep in mind that the length of your C++ integer type can differ from the default C# 32-Bit integer. (This depends on the compiler.) But usually it is handled by the definition of yourVARIANTstructurelong x;and call it withIMyPointer->myValue(&x);