<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>> Note: if your MyString is valid through the complete lifetime it could <br><div>> be used you can also use "Result := PChar(MyString);"<br><br>Hum, to be sure that i understand...<br><br>type<br> TStringClass = class(TObject)<br> Name: AnsiString; //// does not change<br> SomeText: AnsiString; ///// may change..<br> end;<br><br>var<br>AStringClass : TStringClass;<br><br>....<br><br>function GetName: PChar; cdecl ;<br>begin
<br>result := PChar(AStringClass.Name);<br>end;<br><br>function GetSomeText: PChar; cdecl ;<br>var<br> MyString: AnsiString ;<br>begin
<br> MyString := AStringClass.SomeText ;<br> Result := GetMem(Length(MyString) + 1);
<br> Move(@MyString[1], Result, Length(MyString));
<br> Result[Length(MyString)] := 0;
<br>end;
<br><br>Is it OK ?<br><br>Thanks.<br></div> </div></body>
</html>