How to pass reference parameter to unmanaged dll
-
Hi I have a function in unmanaged(VC++) dll which is accepting a refernce parameter
void check(UInt32& c) { c=20; }
I want to call this function from my managed code(C#) so i used the following codeclass Program { [DllImport("samp.dll")] public static extern void check(ref UInt32 c); static void Main(string[] args) { UInt32 s = 0; check(ref s); Console.WriteLine(s.ToString ()); Console.ReadLine(); } }
but it shows me the error"Unable to find an entry point named 'check' in DLL 'samp.dll'." is there any way to call a unmanaged dll's function(which has reference parameter) from managed code without using DLL import?? if yes please send me a sample code. Thanks in advance Srini -
Hi I have a function in unmanaged(VC++) dll which is accepting a refernce parameter
void check(UInt32& c) { c=20; }
I want to call this function from my managed code(C#) so i used the following codeclass Program { [DllImport("samp.dll")] public static extern void check(ref UInt32 c); static void Main(string[] args) { UInt32 s = 0; check(ref s); Console.WriteLine(s.ToString ()); Console.ReadLine(); } }
but it shows me the error"Unable to find an entry point named 'check' in DLL 'samp.dll'." is there any way to call a unmanaged dll's function(which has reference parameter) from managed code without using DLL import?? if yes please send me a sample code. Thanks in advance SriniYou can try using
out
:[DllImport("samp.dll")]
public static extern void check(out ref UInt32 c);Dunno if it works though (maybe only out, no ref?) ...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.." -- Mark McCormick
|| Fold With Us! || Pensieve || VG.Net ||
-
You can try using
out
:[DllImport("samp.dll")]
public static extern void check(out ref UInt32 c);Dunno if it works though (maybe only out, no ref?) ...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.." -- Mark McCormick
|| Fold With Us! || Pensieve || VG.Net ||