Hi,i am using one external dll.here i am in the need of sending parameters to that dll.The function parameter like,
string Myfun(HWND hwnd, char *params);
Here how to pass value from c#.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jan 7, 2012, 8:19 AM
[DllImport("somedll.dll", CharSet = CharSet.Ansi)]
static extern IntPtr(IntPtr hwnd, [MarshalAs(UnmanagedType.LPStr)] string params);
However, as Sam said, if the return type is a C++ string, I doubt whether you're going to be able to do anything with the IntPtr you get back as it's not a type which the .NET marshaller supports.
Sam HobbsPosted Jan 7, 2012, 5:45 AM
I am concerned about the return type "string". If it is a C++ string then you probably cannot use the DLL with any language other than C++.
If the return type is a .Net string type then you do not need to use p/invoke. So you need to determine for sure whether the DLL is unmanaged or managed. The best way to determine for sure whether the DLL is unmanaged or managed is to look at the documentation of the DLL.
Gomathi PalaniswamyPosted Jan 7, 2012, 2:05 AM