[fpc-pascal]Synapse for FPC
Marco van de Voort
marcov at stack.nl
Thu Jul 24 11:34:26 CEST 2003
[ Charset ISO-8859-1 unsupported, converting... ]
> > I would prefer a language that is tightly integrated with an OS... so
> tightly
> > that OS calls and language calls fit together in one smooth flow. I should
> not
> > have to translate strings or use trickery like "A := B+A+#0" or "@A[1]" to
> get
> > things to work. OS calls should be so seamless as to appear to be part of
> the
> > language, not part of yet another complex bag of tricks that has to be
> studied
> > and understood.
>
> In most cases, casting an ansistring as pchar will work. The only caveat is
> when Windows wants to alter the variable you pass' contenets.
>
> e.g.
> MessageBox( pchar(MyMessage), 'test', MB_OK);
>
> but not:
>
> GetUserName( pchar(Username), 255 ); //error!!!
>
> instead:
>
> var
> Username: array[0..255] or char;
>
> begin
> GetUserName( Username, 255 ); //This works!!
> end;
What about
var username:AnsiString;
begin
SetLength(Username,255);
GetUserName( pchar(Username), 255 );
Setlength(username,strlen(pchar(username));
end
Or does that mess up reference counts?
More information about the fpc-pascal
mailing list