Hi Friends

Hi Friends,

I have created one DLL called "IntegrationDLL.dll" in delphi and trying to use that in C#. one of my function in delphi dll is like below
Function GetClientDetails(pstrClient: widestring):OleVariant;stdcall;
var
  RecClientMatterBAL:TClientMatterBAL;
  PtrClientMatterBAL:ClientMatterBAL;
  size:Smallint;
begin
        ShowMessage('Start');
        RecClientMatterBAL.Disb := 11.11;
        RecClientMatterBAL.Bills := 12.12;

        RecClientMatterBAL.Client := 13.13;
        RecClientMatterBAL.Deposit := 14.14;
        RecClientMatterBAL.WIP := 15.15;
        Size := SizeOf(RecClientMatterBAL);
        Result := VarArrayCreate([0, Size], varByte);
        PtrClientMatterBAL := VarArrayLock(Result);
        CopyMemory(PtrClientMatterBAL,@RecClientMatterBAL, Size);
        VarArrayUnlock(Result);
        ShowMessage('Done');

end;

it returns olevariant which i used to make compatiable with c# and it contain

record like below
type
  TClientMatterBAL = record
     Disb,Bills,Client,Deposit,WIP:Double;
   end;
   ClientMatterBAL = ^TClientMatterBAL ;


i am trying to use above function in c# like
      [DllImport("IntegrationDLL.dll")]
        public static extern object GetClientDetails([MarshalAs(UnmanagedType.BStr)] string pstrClientno);

and
        private void button1_Click(object sender, EventArgs e)
        {
 object Result=GetClientDetails("00001001");
}

but it return error like
"pinvoke restriction cannot return variants"

Can any one help me to  use dll function which return record/olevariant written in delphi and used in c#

Comments