I am using a pChar variable to get string infromation from
GetPrivateProfileString, and I would like to put this information
into a string variable. What should I do?
travis
tmet...@teleport.com
Check the online help for string manipulation routines. I think you're
after something like StrPas/StrPCopy.
>I am using a pChar variable to get string infromation from
>GetPrivateProfileString, and I would like to put this information
>into a string variable. What should I do?
Abandon GetPrivateProfileString and take a look at the IniFiles unit
instead. Check out the online docs on the TIniFile type.
/Anders
-----------------------------------------------------------------------------
! The Windoze program you want is at http://www.it.kth.se/~ao/yacpu20.zip !
! !
! Anders Ohlsson - a...@sto.foa.se - http://www.it.kth.se/~ao !
-----------------------------------------------------------------------------
MyString := StrPas(MyPChar);
{deallocate the PChar}
end;
But you might try and use TIniFile type.....it worked for me (except
for a *slight* bug in WriteBool(..)!)
Regards
Conor Cagney
Look up StrToPas in the Help Section.
All the best
Marc
What was I thinking.
BTW a trick way Pascal to Str type:
var
AString: String;
AStr: PChar;
begin
AString:='This is a normal Pascal String'+#0;
AStr:=@AString[1];
WritePrivateProfileString(.....@Astring[1]....);
end;
Why?
A pascal String is layed out with the length of the string in
character[0] with the actual characters starting at character[1]
This also means than Ord(AString[1]) gives you the length!
A C string is a pointer (Hence the @) to the first character of
a string (Hence AString[1]). No length is encoded, the string is
variable length and stops at a null character (Ascii 0 or ASCIIZ)
hence the #0!
All the best
Marc