{$APPTYPE CONSOLE}
program testmain; uses sysutils;
// main program written by Glenn9999 at tek-tips.com. Illustrates calling the
// DLL function provided as a sample.
function GetWallPaperPath(wallpaper: PChar; var buflen: Word): Bool;
stdcall; external 'testdll.dll';
var
Teststring: string;
teststringlen: Word;
begin
{ this is how I usually call Windows API functions which involve string data.
While there may be an easier way which is compatible, this seems the easiest
that I know. You can change the size of a string, point to the string and
then change it back to the actual length of the returned data. }
teststringlen := 255;
SetLength(teststring, teststringlen);
GetWallPaperPath(PChar(teststring), teststringlen);
SetLength(teststring, teststringlen);
{ writing * here so the length of the string can be easily spotted. Returning
a string that is complete and of the right length is perhaps the more difficult thing in calling "compatible" DLL functions which return string data.}
writeln('WallPaper path for current user is: ', teststring, '*');
readln;
end.