🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.csharpbuilder.com-interop
Article #4

Problem with OleVariant and C#

#4
From: argami
Date: Thu, 05 Oct 2006 17:11
34 lines
1856 bytes
I have a com delphi exe, with this code:

TMyRecord = Record
  a:Integer;
end;

function RecordToVariant(r: TMyRecord):OleVariant;
var
  P:Pointer;
begin
  result :=VarArrayCreate([0, sizeof(TMyRecord)], varByte);

  P := VarArrayLock(result);
  Move(P^, result, sizeof(r));
  VarArrayUnlock(result);
end;


so  i use this code in 1 function like

procedure SomeFunction(var v:OleVariant);
var
  myRecord:TMyRecord;
begin
  myRecord.a := 1;
  v := RecordToVariant(myRecord);
end;

Ok my problem is i can't change this code. In my c# consuming client
I've to use SomeFunction geting this olevariant like object but i dont
know how to extract this record to another c# struct with the same
members.

Anybody can help me?????
Technical Details
Message-ID: <1160068311.273177.29570@b28g2000cwb.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!b28g2000cwb.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 216590,da6abb3917e64042,start
X-Google-Attributes: gid216590,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!b28g2000cwb.googlegroups.com!not-for-mail
From: "argami" <argami@gmail.com>
Newsgroups: borland.public.csharpbuilder.com-interop
Subject: Problem with OleVariant and C#
Date: 5 Oct 2006 10:11:51 -0700
Organization: http://groups.google.com
Lines: 35
Message-ID: <1160068311.273177.29570@b28g2000cwb.googlegroups.com>
NNTP-Posting-Host: 80.35.121.134
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1160068316 17019 127.0.0.1 (5 Oct 2006 17:11:56 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 5 Oct 2006 17:11:56 +0000 (UTC)
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: b28g2000cwb.googlegroups.com; posting-host=80.35.121.134;
   posting-account=37Lbyw0AAACL8WEoQS6v8SJ7-SNHDxIy