Re: Using DLLImport with a function requiring char *

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Willy Denoyette [MVP] (willy.denoyette_at_pandora.be)
Date: 12/06/04


Date: Mon, 6 Dec 2004 12:23:29 +0100

Jason,
Well, actualy all characters are passed (as unicode characters), it's just
the native code that looks for a single null (0x00) byte in the input buffer
as string terminator.
Note that there is no need to specify LPStr as it's the default.

Willy.

"Jason Bell" <halobear333@yahoo.com> wrote in message
news:Xns95B6A696FB35Bhalobear333yahoocom@198.161.157.145...
> Thanks, I got it working by marshaling it as LPStr. LPWStr just passed
> the
> first character in the string. Here's what I used:
>
> [DllImport("XGL.dll", EntryPoint="XGL_Core_SetCaption",
>
> ExactSpelling=false,CallingConvention=CallingConvention.Cdecl)]
> public unsafe static extern void SetCaption( void * Core,
> [MarshalAs(UnmanagedType.LPStr)]string s );
>
> Thanks again.
>



Relevant Pages

  • Re: Image Module Bug
    ... This allows me to pass NULL characters. ... > I've got a problem with loading images using the Image Module. ... > black in my image which was screwing up the NULL string terminator. ... > This is also a problem when I am trying to do RGBA format because the ...
    (comp.lang.python)
  • Re: Insert asc(0) characters in strings
    ... I'm replacing ' characters with two ', ... Mikael, What do you mean by "characters with two"? ...
    (borland.public.delphi.database.ado)