Hi All,
I know that I can use the GetProcAddress to get the proc address of a global
exported function from a WIn32 dll.
But if I have an exported class in the dll, is there a way to dynamically
load this dll and get an instance of this class? (No static linking with the
lib file) I am currently thinking about having global exported functions
which internally calls the member functions of the class's single instance.
These global exported dunctions can be accessed through GetProcAddress anyway.
Can anyone please throw some light into this?
TIA,
Jessy 4 2682
Jessica wrote:
Hi All,
I know that I can use the GetProcAddress to get the proc address of a
global exported function from a WIn32 dll.
But if I have an exported class in the dll, is there a way to
dynamically load this dll and get an instance of this class? (No
static linking with the lib file) I am currently thinking about
having global exported functions which internally calls the member
functions of the class's single instance. These global exported
dunctions can be accessed through GetProcAddress anyway.
Can anyone please throw some light into this?
The usual way is to have a factory method, an exported C function used to create
the desired class (something like COM DllGetClassObje ct). Your client only needs
the factory method signature and the class definition.
Regards
--
Cholo Lennon
Bs.As.
ARG
"Jessica" <Je*****@discus sions.microsoft .comha scritto nel messaggio
news:EE******** *************** ***********@mic rosoft.com...
But if I have an exported class in the dll, is there a way to dynamically
load this dll and get an instance of this class? (No static linking with
the
lib file) I am currently thinking about having global exported functions
which internally calls the member functions of the class's single
instance.
These global exported dunctions can be accessed through GetProcAddress
anyway.
Can anyone please throw some light into this?
What you propose (i.e. a pure-C wrapping interface to your C++ class) is an
option.
However, you may also consider exporting a factory function, which creates
an instance of your class, so you can use GetProcAddress( ) to get a pointer
to the factory function, and call the factory function to create an instance
of the class.
i.e. you can export a function like this from the DLL:
CMyClass * BuildMyClass();
and call GetProcAddress( ) to get its address after loading the DLL with
LoadLibrary(), and then call that function to get a CMyClass pointer.
HTH,
Giovanni
Cholo Lennon wrote:
Jessica wrote:
>Hi All,
I know that I can use the GetProcAddress to get the proc address of a global exported function from a WIn32 dll.
But if I have an exported class in the dll, is there a way to dynamically load this dll and get an instance of this class? (No static linking with the lib file) I am currently thinking about having global exported functions which internally calls the member functions of the class's single instance. These global exported dunctions can be accessed through GetProcAddress anyway.
Can anyone please throw some light into this?
The usual way is to have a factory method, an exported C function
used to create the desired class (something like COM
DllGetClassObje ct). Your client only needs the factory method
signature and the class definition.
BTW, to avoid problems with different heaps, you can also export a complementary
function to destroy the object.
Regards
--
Cholo Lennon
Bs.As.
ARG
"Cholo Lennon" <ch*********@ho tmail.comha scritto nel messaggio
news:OB******** ******@TK2MSFTN GP05.phx.gbl...
BTW, to avoid problems with different heaps, you can also export a
complementary
function to destroy the object.
Or use a reference counting technique like COM AddRef/Release (and when
reference counter becomes 0, the object destroys itself).
Giovanni This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kevin Crosbie |
last post by:
Hi,
I have the following situation:
I have a 3rd party DLL which does not include a LIB file, just a header file
with typedef declarations for exported functions (It is intended for dynamic
linking)
I need to wrap the DLL to allow for callbacks to my own code (in Lisp), and
to do this I need to load the DLL using LoadLibrary and access each function
|
by: DotNetJunkies User |
last post by:
Hi,
Does anyone know how/if you can instantiate a C# reference type object dynamically? More specifically, my project has a number of classes that I've created and in some cases it would be very handy to be able to instantiate them based on a string variable representing their class name.
Here's an example of what I'd be looking to do.
public object DynamicInstantiation(string className)
{
return new ;
}
|
by: Kamal Jeet Singh |
last post by:
Hi Friends !!
I am facing problem in controlling the dynamically created
controls on web page. The problem Scenario is
Scenario:- My requirement is to load the web user controls on the web
page dynamically. To do this, First I including a web page
(MainPage.aspx) and I made form tag to Runat=Server. I included one
table tag and also made this table Runat=Server side. Second I created
three Web User Controls e.g. wucCustomerInfo.ascx,
|
by: Egbert Nierop \(MVP for IIS\) |
last post by:
Hi,
I have a complex asp.net 1.1 program that dynamically needs to load controls
(LoadControl)
The textboxes etc inside these controls keep viewstate and values but not
within
Page_Load()
when that event is 'going on' the load control happens but the values are
not yet 'filled in' They are filled in only -when- the pageload event has
|
by: Reza Nabi |
last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a
placeholder dynamically based on the ctlName querystring passed in the URL.
Webform (LoadCtl.aspx) also passes a variable (targetId) in to the
usercontrol (IntergySite.aspx) by calling its setter method.
Currently, I am using if-then-else and hardcoded the User Control Object to
do casting and call the setter method.
Question: Is there any way I could load,...
| |
by: Steve Booth |
last post by:
I have a web form with a button and a placeholder, the button adds a user
control to the placeholder (and removes any existing controls). The user
control contains a single button. I have done all the usual stuff of
recreating the usercontrol in the Page Init event.
The 'failure' sequence is as follows:
- select web form button to display the user control
- select user control button, event fires
- select web form button to display...
|
by: Konstantin Andreev |
last post by:
Recently I became interested, - Are the data, bulk loaded in the table with
LOAD utility, consume the same disk space as loaded with IMPORT utility? The
answer turned out to be NOT !
Here is a nutshell description of the test. The testing was done at
"DB2/LINUX 8.2.3".
Tables for tests:
F4106 has 5203 rows, 32 columns.
F42199 has 1399252 rows, 245 columns.
|
by: Smithers |
last post by:
I have a Windows Forms application that implements a plug-in architecture
whereby required assemblies are identified and loaded dynamically.
Here are the relevant classes:
A = application = Windows Forms class
B = a singleton hosted within A. B is responsible for dynamically loading
classes X, Y, and Z.
|
by: filhodapuc |
last post by:
How to Load the class "MyContent" dynamically ?
I have 1 interface<T>, 1 abstract generic class<T> and 1 class. Check my code out:
public interface IMyObjectInterface{
}
public abstract MyAbstractObject : IMyObjectInterface{
}
public class MyObject : MyAbstractObject{
}
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |