Re: Unmanaged code(dll) function: int myfunc (char* temp)



Hi,
Thanks for ur Reply....
I tried StringBuilder it worked, But there is some problem with conversion i
think.
When i tried to convert it to string as sb.Tostring(), it is giving me some
junk characters which are not alphanumeric.

Can u tell me what i need to do to convert the stringbuilder sb to some
alphanumeric string.

Murthy.

"<ctacke/>" wrote:

First thing to know is that CE doesn't store strings in a char* type, it
uses UTF16, so they are wchar_t.

If the native DLL will be putting data into that variable, you need to
allocate enough memory for it before the call. The easiest way is with a
StringBuilder.

int myfunc (TCHAR* temp)
{
.....
}

[DllImport("mylib.dll")]
public static extern int myfunc(StringBuilder sb);

void MyCall()
{
StringBuilder sb = new StringBuilder(255);
int ret = myfunc(sb);
}


--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--


"Murthy" <Murthy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5F9D1506-CD19-4390-B633-0BDE53BCC1DA@xxxxxxxxxxxxxxxx
Hi,
I want to do an unmanaged call to an DLL
Unmanaged code(dll) function: int myfunc (char* temp)
Here return int type determines the Success.
After execution of the function temp will contain an value

How to do the unmanaged call to this function from c# and later how to
retrieve the value from temp, which hold a string value.

thanks in Advance,
Murthy




.



Relevant Pages

  • Re: pinvoke with StringBuilder[] not working for me
    ... public static extern int EnumerateBoards ... I want to pass a pointer to an array of char strings, ... int numBoards, StringBuilder boards); ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Unmanaged code(dll) function: int myfunc (char* temp)
    ... Managed Code in the Embedded World ... I tried StringBuilder it worked, But there is some problem with conversion ... public static extern int myfunc; ... Unmanaged codefunction: int myfunc (char* temp) ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: am having a problem with pinvoke and StringBuilder[ ]
    ... DLL: Hello from TestLib.dll ... Since the String class is immutable, I have used StringBuilder in my code ... public static extern int EnumerateBoards(ref int numBoards, ...
    (microsoft.public.dotnet.framework.clr)
  • Re: am having a problem with pinvoke and StringBuilder[ ]
    ... If you don't have the source of the DLL then you are in a world of pain, that means you wont be able to use the interop marshaler, you need to "custom" marshal. ... public static extern int EnumerateBoards(ref int numBoards, ... Since the String class is immutable, I have used StringBuilder in my code ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Unmanaged code(dll) function: int myfunc (char* temp)
    ... If the native DLL will be putting data into that variable, ... public static extern int myfunc; ... StringBuilder sb = new StringBuilder; ... Unmanaged codefunction: int myfunc (char* temp) ...
    (microsoft.public.dotnet.framework.compactframework)

Loading