passing (short) strings to a DLL
Posted on 1997-11-18
Can someone tell me how i can pass a couple of short strings and a record type containing a few more short strings from my delphi program to my delphi DLL ?
i know all about using ShareMem and DelphiMM DLLs with long strings.
i want to pass shortstrings (and preferably as value parameters)
The following is not working (an under statement: it crashes win 95 quite often !)
record type var is not in these funcs.
Any comments ?
in the DLL:
function AddCRToLF(Caller:HWND; infile, outfile: ShortString):boolean;
//do all i want
exports AddCRToLF index 1;
in the calling program
function calldll(caller:HWND; s1,s2:shortstring);
var h : THandle;
f : function(Caller:HWND; infile, outfile: ShortString):boolean;stdcall;
h := LoadLibrary('MyDLL.DLL');
if h <> 0 then
@f := GetProcAddress(h, 'AddCRToLF');
if @f <> nil then
AddCRToLF := f(Caller, s1, s2);//<======crashes here !
FreeLibrary(h); // Free the library...