Subject | Delphi UDF with PChar |
---|---|
Author | yaedos2000 |
Post date | 2006-02-15T16:33:05Z |
Hi,
I'm having trouble writing a UDF in Delphi that returns a PChar. This
is a simple example of what I'm trying to do:
function test(InputString: PChar): PChar;
begin
result := StrAlloc(Length(InputString));
StrCopy(result, InputString);
// Presumably the StrAlloc will be freed by the UDF's FREE IT???
end;
function test2(InputString1, InputString2: PChar): PChar;
begin
result := StrAlloc(Length(InputString1) + Length(InputString2) + 1);
StrCopy(result, InputString1);
StrCat(result, InputString2);
end;
Neither of these functions work as a UDF. It does work if the StrCopy
and StrCat functions aren't used, as in:
result := 'Output text';
Any ideas what might be going wrong and how to fix it?
Thanks
I'm having trouble writing a UDF in Delphi that returns a PChar. This
is a simple example of what I'm trying to do:
function test(InputString: PChar): PChar;
begin
result := StrAlloc(Length(InputString));
StrCopy(result, InputString);
// Presumably the StrAlloc will be freed by the UDF's FREE IT???
end;
function test2(InputString1, InputString2: PChar): PChar;
begin
result := StrAlloc(Length(InputString1) + Length(InputString2) + 1);
StrCopy(result, InputString1);
StrCat(result, InputString2);
end;
Neither of these functions work as a UDF. It does work if the StrCopy
and StrCat functions aren't used, as in:
result := 'Output text';
Any ideas what might be going wrong and how to fix it?
Thanks