definition
October 6th, 2005, 09:46 AM
Hey all.
I have this COM server and a method on it takes a variant type, how can i declare a pass a variant in c#?
darwen
October 6th, 2005, 10:10 AM
What does tlbimp.exe have to say about the dll ? Add the dll as a reference to your project and see what the wrapper class does.
Darwen.
cilu
October 6th, 2005, 10:26 AM
A COM VARIANT type (as well as IUnknown* and IDispatch*) is marshalled as a System.Object. Say you have a function like this
HRESULT Open(
[in] VARIANT* FileName,
[in] VARIANT options);
Then you can do it like this:
object fileName = @"c:\test.txt";
object options = 0; // some flags
Open(ref fileName, options);
The COM attribute/C# modifier table is :
[in] - > <no_modifier>
[out] - > out
[in, out] - > ref
[out, retval] - > <return_value>
See this link http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondefaultmarshalingforobjects.asp for more.
definition
October 6th, 2005, 10:42 AM
cheers cilu