Article View: borland.public.csharpbuilder.language.csharp
Article #163Re: Passing a delegate to a DLL as a 'void *'
From: Marc Rohloff TeamB
Date: Mon, 18 Sep 2006 21:50
Date: Mon, 18 Sep 2006 21:50
23 lines
2069 bytes
2069 bytes
On 18 Sep 2006 02:43:38 -0700, Andrue Cope [TeamB] wrote: > I have a DLL written in C++ and I need to pass it a delegate so that it > can call me back. The DLL has been around for a while and it takes > commands using a structure to contain input and output data. Callbacks > are passed to it in 'void *' pointers members. Why don't you the type of fsCmd.Value_VOIDS_2 to be a TCBProgress delegate instead? A common trick is to have several different structures matching the expected types of the fields and then overload the DLL call for each possible type. Another possibility which /might/ work is to either use type information to get the _methodPtr and _methodPtrAux fields or just use the HashCode (which currently is the same thing). Of course this is not guaranteed to work the same in different versions of the framework. -- Marc Rohloff [TeamB] marc rohloff -at- myrealbox -dot- com
Technical Details
Message-ID:
<xl2or5ol7j8v.dlg@dlg.marcrohloff.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<450e6a4a$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,497a94e42bdc0848 X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Marc Rohloff [TeamB]" <"on request"> Subject: Re: Passing a delegate to a DLL as a 'void *' Newsgroups: borland.public.csharpbuilder.language.csharp User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit References: <450e6a4a$1@newsgroups.borland.com> Date: Mon, 18 Sep 2006 17:50:29 -0400 Message-ID: <xl2or5ol7j8v.dlg@dlg.marcrohloff.com> X-Face: "huzh55Xi]!ZNni78>a*5+).`SK?<^q2MlHk-C]Z2M9T@\J5ZCB$95Ey+s"XQuhGFA[eutZ :0^AV!Q;t>gE`1-=8d;HZ6~*o1dH<X9\b$!|(}+I'!Xq)@3Op}%0ArW&nf'Qh*EwR X-Antivirus: avast! (VPS 0637-2, 09/15/2006), Outbound message X-Antivirus-Status: Clean NNTP-Posting-Host: 65.31.1.121 X-Trace: newsgroups.borland.com 1158616222 65.31.1.121 (18 Sep 2006 14:50:22 -0700) Lines: 23 X-Authenticated-User: mrohloff Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail