views:

260

answers:

1

I am working on a DLL in Delphi 2010. It exports a procedure that receives an array of variants. I want to be able to take one of these variants, and convert it into a string, but I keep getting ?????

I cannot change the input variable - it HAS to be an array of variants. The host app that calls the DLL cannot be changed. It is written in Delphi 2006.

Sample DLL code:

Procedure TestArr(ArrUID : array of variant); stdcall;  
var 
  i: integer;  
  s: string;
begin  
  s:= string(String(Arruid[0]));  
  showmessage(s);  
end;  

Using D2006 my DLL works fine. I have tried using VartoStr - no luck. When I check the VarType I am getting a varString. Any suggestions how to fix this?

A: 

1/ How have you call the VarToStr() function ? VarToString(Arruid[0]) ?

2/ Does your Delphi2006 Application send AnsiString or WideString to the DLL ? If so, and if (1) is not working, try to cast to AnsiString instead of string.

TridenT