|
Hi,
I am a little confused on the use of DLL's first I guess there is a difference between a static load and a Dynamic Load
A LoadLibrary is a Dynamic Load of a Dll So my questions is How can you ensure a DLL is Automatically Loaded when your app/exe starts up ??? (which I guess would be a static Load)
Second If want execute a Function in a DLL I can do A GetProcAddress and use the function or use IMPORT/EXPORT (__declspec) pairs
These are two mutally exclusive way of excuting the function ???
Thankx
|
|
|
|
|
ForNow wrote: which I guess would be a static Load)
yes
ForNow wrote: These are two mutally exclusive way of excuting the function ???
They are not exclusive. Even can mix both this method. How ever if you want to call a function by with any of the aboce technique, the only this you need to ensure is that the function should be exported eith using the __declspec or by adding the entry in the .def file.
|
|
|
|
|
How can you do a static load or ensure that the DLL get loaded when your app/exe starts up
|
|
|
|
|
Suppose you have a function say, void test() exported from a dll( using __declspec or using def file ). when you build the dll, along with the dll and lib file will also be generated.
. Now Declared the function in the exe( usually we include the header file of the dll in which the function is already declared )
.After that you can call the function. Also add the lib file of that dll in the project settings of the exe ( project settings->link->object or library modules).
|
|
|
|
|
The .lib file is the glue
The funny thing about this is when you run a app/exe Windows will somtimes not find because its not in the Path
However I guess it will always find a .DLL anywhere on your machine to Load it
|
|
|
|
|
ForNow wrote: However I guess it will always find a .DLL anywhere on your machine to Load it
I dont think so. The windows will load the dll only if the dll is in working directory of exe or the path of dll is added in the PATH environment variable.
|
|
|
|
|
Okay begining to get the picture thankx for your help
|
|
|
|
|
Well, it is not so funny, roughly speaking:
(1) When you build the application, the linker uses the lib file to place only calling info to DLL functions inside application executable.
(2) When you run the executable the loader needs to find the DLL and make the calls
become effective glued to actual DLL functions.
The OS has well definite strategy to find DLL s, see http://msdn2.microsoft.com/en-us/library/ms682586(VS.85).aspx[^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
|
you might be wanting to read this article[^]...
static loading a DLL ensures that the DLL is found when the program starts up. if the DLL is not found, an error message is thrown, and the application stops straight.
|
|
|
|
|
Since
toxcct wrote: static loading a DLL ensures that the DLL is found when the program starts up.
hence
toxcct wrote: if the DLL is not found
cannot happen.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
yes it can
I meant, static loading ensures that if the applications is started, the the DLL has been found.
but still the DLL may not be found, thus application bornt dead.
|
|
|
|
|
toxcct wrote: thus application bornt dead
And wasn't it alive before actual birth? Was it?
Oh, this is an arduous ethical debate...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
|
ForNow wrote: first I guess there is a difference between a static load and a Dynamic Load
The difference is actually referred to as implicit vs. explicit linking.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Is there a way to read with/write into databases with C++?
|
|
|
|
|
|
Yes. What is your specific question?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
How can I implement a context menu for a menu. That's mean when I right click on the menu a context menu will appearing. Like the favorite menu of Firefox or IE.
Thank you for your help
|
|
|
|
|
|
Thank you very much Mark
|
|
|
|
|
Is there any way to specify which Ethernet adapter a socket connetion uses? I'm creating the socket as follows:
<br />
SOCKET Socket;<br />
int opt_on = 1;<br />
<br />
<br />
Socket = socket(AF_INET, SOCK_STREAM, 0);<br />
<br />
if(Socket == INVALID_SOCKET)<br />
return - 1; <br />
<br />
if( setsockopt( Socket, SOL_SOCKET, SO_REUSEADDR, (char*)&opt_on, sizeof (opt_on) ) == SOCKET_ERROR )<br />
{ <br />
<br />
return -1;<br />
<br />
}
<br />
cliAddr.sin_family = AF_INET;<br />
cliAddr.sin_addr.s_addr = inet_addr( "169.254.148.9" );<br />
cliAddr.sin_port = htons( 4200 );<br />
<br />
if ( connect( Socket, (struct sockaddr *)&cliAddr, sizeof(cliAddr) ) == SOCKET_ERROR )<br />
{<br />
<br />
GetSocketError();<br />
return -1;<br />
<br />
}
<br />
The connection will always try to use the first available network adapter, which is not necessarily the one connected to the requested port. Is there a way to change this without having to specify different domains?
Thanks.
|
|
|
|
|
masnu wrote: Is there any way to specify which Ethernet adapter a socket connetion uses?
For a local socket, that's what the bind() function is for.
masnu wrote: The connection will always try to use the first available network adapter, which is not necessarily the one connected to the requested port.
I'm confused here. The port you specified is for the destination address, not the
local address. Again, use bind() to bind a socket to the adapter with the specific
address before calling connect().
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Been a while, but if i recall correctly,
- use GetAdaptersInfo to walk through the adapters
- for each adapter you can walk its list of (local) IP addresses
- create the socket then bind to the local address for the adapter you want
- after the bind connect to the desired peer
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Is there a way how to catch system messages in a driver created by DDK ?
directly from win or using some way like callback functions in WIN32
<br />
switch(Msg){<br />
case WM_CLOSE:<br />
...<br />
break;<br />
}<br />
thank you for any support
modified on Wednesday, January 09, 2008 11:24:13 AM
|
|
|
|