[fpc-pascal] GetProcAddress

Anthony Walter sysrpl at gmail.com
Thu Jan 14 21:48:23 CET 2010

I am not too sure why GetProcAddress is returning nil, but a few points:

1) you do not need to typecast string literals as PChar

FGetAsText := GetProcAddress (FHandle, 'clipboard_getastext');

2) You really should not return strings as PChar, passing them is fine, but
return, nope

result := PChar (Clipboard.AsText);

Why? Because string types are managed and referenced counted. The project
returning the string is likely to deallocate the memory returned upon exit
(unless you save a copy locally) . A better approach would be to have the
caller allocate the memory and return the expected buffer size:

function clipboard_getastext(Buffer: PChar; BufferSize: Integer): Integer;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20100114/50c7c9fb/attachment.html>

More information about the fpc-pascal mailing list