Hi, I've got a problem with passing a record to dll.
I do it like this:
[tt][blue]
type
TMyRec = record
field1: PChar;
field2: integer;
end;
type
PMojRec = ^TMojRec;
//of course in my application there is more fields
[/tt][/blue]
Then in main application I create array of those records and fill them in:
[tt][blue]
var
devArr: array of TMyRec;
begin
setLength(devArr, 1);
devArr[0].field1:=PChar('blabla');
function_from_dll(@devArr[0]);
end;
[/tt][/blue]
And in dll:
[tt][blue]
function function_from_dll(MyRec: PMyRec): HResult; safecall;
var
s: string;
begin
s:=MyRec^.field1; //and here I get AccessViolation
end;
[/tt][/blue]
I think that I am doing everything the way it should be, but this AV still appears. WHY?
I do it like this:
[tt][blue]
type
TMyRec = record
field1: PChar;
field2: integer;
end;
type
PMojRec = ^TMojRec;
//of course in my application there is more fields
[/tt][/blue]
Then in main application I create array of those records and fill them in:
[tt][blue]
var
devArr: array of TMyRec;
begin
setLength(devArr, 1);
devArr[0].field1:=PChar('blabla');
function_from_dll(@devArr[0]);
end;
[/tt][/blue]
And in dll:
[tt][blue]
function function_from_dll(MyRec: PMyRec): HResult; safecall;
var
s: string;
begin
s:=MyRec^.field1; //and here I get AccessViolation
end;
[/tt][/blue]
I think that I am doing everything the way it should be, but this AV still appears. WHY?