Article View: borland.public.cppbuilder.nativeapi
Article #8744Re: calling host executable functions/methods from a dll
From: Andrue Cope [TeamB]
Date: Wed, 22 Sep 2004 14:13
Date: Wed, 22 Sep 2004 14:13
27 lines
2082 bytes
2082 bytes
Roger Warren wrote: > if i have TForm1 *Form1 in the host executable, can i pass a pointer > to an instance of TForm1 to the dll? If the method is virtual I *think* the DLL will be happy since it should get the address of the function from the VMT of the object you are passing in. If OTOH the method is static then the DLL has to have its own copy of the function since nothing in the VMT tells you where to find static methods. An in-memory image of an instantiated object has two main data areas. The data members you have created are in one and something called a VMT (Virtual Method Table) is in the other. A VMT is a list of addresses for all the virtual methods and is how polymorphism works. When you call a virtual function the compiler generates code to grab its address from the table and call it. Static functions are not, by definition, referenced by the VMT so their address is hard coded by the linker. I'll add that all methods called while processing a class method will have to be static for the same reason. -- Andrue Cope [TeamB] [Bicester, Uk] http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID:
<41518884@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<41516f76@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,61cd17292f50f8cb,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Andrue Cope [TeamB]" <no.spam@not.a.valid.address> Subject: Re: calling host executable functions/methods from a dll Newsgroups: borland.public.cppbuilder.nativeapi References: <41516f76@newsgroups.borland.com> User-Agent: XanaNews/1.16.4.6 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 NNTP-Posting-Host: 217.207.223.34 Message-ID: <41518884@newsgroups.borland.com> Date: 22 Sep 2004 07:13:24 -0700 X-Trace: newsgroups.borland.com 1095862404 217.207.223.34 (22 Sep 2004 07:13:24 -0700) Lines: 27 X-Authenticated-User: acope Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail