Hi Sridhar,
Here is my understanding of your question. You have a dll function with a
reference VARIANT parameter, and now you hope to call it in C#.
Here is my sample code below.
Did I misunderstand your meaning?
I do not know why you need to call Marshal.GetObjectForNativeVariant() to
Marshal the Variant data type.
If you have further question, please post some code, such as the dll
function declaration and the DllImport declaration in C#.
[StdDLL.dll]
long __declspec (dllexport) __stdcall Func11(VARIANT& MyArray){
MyArray.vt = VT_BSTR;
char* lpszText = "Test";
BSTR bstrText = _com_util::ConvertStringToBSTR(lpszText);
MyArray.bstrVal =bstrText;
return 8;
}
[DllImport(@"c:\StdDLL.dll")]
public static extern int Func11(ref object var);
[STAThread]
static void Main(string[] args)
{
object s= new object();
int rt = Func11(ref s);
Console.WriteLine((string)s);
}
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure!
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "C. N. Sridhar" <sr********@geind.ge.com>
Sender: "C. N. Sridhar" <sr********@geind.ge.com>
Subject: Marshaling Variant object
Date: Wed, 10 Sep 2003 07:30:45 -0700
Lines: 13
Message-ID: <0e****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcN3qB8487/0YDhRRNePfI0ukOgeKQ==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:107952
NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.general
Hi,
I'm writing a wrapper to a win32 dll in C#. I need to call
a method in DLL which has a Variant type reference
parameter.
How to marshal variant type from win32 (unmanaged code)
to C# (managed code)?
I tried using Marshal.GetObjectForNativeVariant(), but of
no use.
With regards,
-Sridhar