Sorry, Maybe I wasn't clear enough... my actual code is this...
// Std call - this is the function exported from the dll...
function GetDetails(const Name : PAnsiChar; out val : Longword) : Boolean; stdcall;
var
data : TCompanyData;
begin
data := TCompanyData.Instance;
Result := data.get(Name, val);
end;
// Within the dll I have some objects, common code, etc. I'm calling a function to get me some data for a given name
function TCompanyData.Get(const Name: string; out CRC : Longword) : Boolean;
begin
// This bit should work - I get into and out of this function but by the time I get here Name is incorrect...
end;
I've written the calling code in Delphi 2009. The dll then needs to convert back from a PAnsiChar to an AnsiString (just a string) to go away and get me some information.
// Note: Lazarus wont let me debug the DLL so I'm left with dumping info to a file.
// Nothing I've tried works... (judging from the info in the file I dump out)
// For Example suppose "Name" is "Charlie"
function GetDetails(const Name : PAnsiChar; out val : Longword) : Boolean; stdcall;
var
data : TCompanyData;
list : TStringList;
temp : string;
begin
temp := Name;
list := TStringList.Create;
list.Add(Name); // produces 'C'
list.Add(StrPas(Name)); // produces 'C'
list.Add(temp); // produces 'C' // In Delphi 2009 I believe this would be "Charlie"
list.SaveToFile('C:\test.txt');
data := TCompanyData.Instance;
Result := data.get(Name, val);
end;
I've included the directive {$H+}. The result I'm looking for is temp ( in my second example code ) to be 'Charlie' - Any thoughts?! I've tried all manner of Copy, StrPCopy, etc... Can't seem to get Free Pascal / Lazarus to do this.