|
Hi,
I know that the most obvious answer is "check it out" but...
If I code a dll with some functions and, in a part of the main programm, I use it with
MyDll::MyFunction ();
if the DLL is not present when it is supposed to be... obviously the function won't be called, but will the programm give an assertion? or just try the line and go on as nothing?
I have already coded the functions in my program, that should be in the dll. The functions work, but I have no experience with dll and I would like to know the best way to use the functions only when the Dll is there, but having no problems when it is not there.
I have thought to check an easy
CFile f;
if (f.Open ("MyPathToDll\\MyDll.dll", CFile::modeRead))
{
f.Close ();
MyDll::MyFunction ();
}
else
MessageBox ("This function is only reachable if the \"XXX.dll\" is present on \"MyPathToDll\", "Info", MB_OK);
Is it "good"? Which methode is the apropiated one?
-- modified at 3:09 Tuesday 30th October, 2007
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
If your EXE is linked to the DLL dynamically, then the OS will load the DLL for you when needed. If it can't find it then your application will throw an exception and stop. It will not continue without any error. Mainly because there is code missing.
If you use LoadLibrary to load the DLL and GetProcAddress, then you can code your application such that it can continue without the DLL.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Nelek wrote: MyDll::MyFunction ();
What is this MyDll ?? Is it a class ?
You have two options to load your dll: either implicitely (you link to a static library supplied wioth the dll that contains informations about how to load the dll), or explicitely (you load the dll yourself using LoadLibrary and then using GetProcAddress).
When you load implicitely, if your dll is not present, the program will generate a message box saying that the dll is not present before any of your code is executed, meaning that you have no control at all to 'fix' the problem (the program will exit directly afterwards).
When you load explicitely, the LoadLibrary function will return NULL if the dll was not loaded successfully (if it was not present for example). In that case, you have full control about what you would like to do if the dll is not present. But, beware, with this method you cannot import classes, just functions (of course, you can import functions that return a pointer to a class ).
|
|
|
|
|
Actually, "MyDll" was the name of the dll. I saw it in an example (I don't remember where).
The problem with this is that in this way, (Coding my read / write functions) in two different DLLs as my boss wants, is being a bit confusing to me. All my code is already working in the application but he wants it separated (for security and money). My problem is... "read", should be ALWAYS present (we deliver it with the programm), but "write" will be sold. And both tasks uses code from a third party dll that will be delivered with my programm in demo version (but functional for what is needed).
So I have to code my functions in a dll, and these functions will use a third party dll as well and to know which specifical function has to be called I should read some values from the registry of local computer. I have difficulties to find the best way/solution to do this (I am a bit newbie with DLLs).
So...
1 sure thing: Use LoadLibrary and if not NULL then call my functions, else give my message or do nothing.
The third party is statically linked (I have a *.lib and *.h and there is an error if the files are not present). May I use the methodes of this one inside my dll as I now use them (as part of my classes because of the *.h)?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Nelek wrote: Actually, "MyDll" was the name of the dll. I saw it in an example (I don't remember where).
That's the first time I see something like that . They probably declared a class with the same name as the dll.
Anyway, I suggest that you take some time to learn how dll's work. Getting answers on a forum is nice when you want to learn something quite concrete. You learn something so like dlls just by asking questions on a forum. Nothing is better than reading articles in that case. Take a look here[^], there are quite some good articles.
|
|
|
|
|
|
Nelek wrote: But the problem is that no one says something about calling dll methodes from another dll
There is no difference if you call the functions from an executable or from a dll. So you don't have to worry about that.
Nelek wrote: and the most of them take some parameters, do some things inside with these parameters and give a value as return
Well, that's the purpose of all functions isn't it ? So, what's the problem with that ?
Nelek wrote: But I have to define interactions between dinamical datas, registry and more things.
Yes, and ? What is the problem ?
|
|
|
|
|
The problem is inexperience in the thema. But now I at least am quiet with your answers. I will read a bit more info and start with my code. Thanks
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
There's something familiar with your name... You're from Spain... you're living in Germany...
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
Yes fernando, and the nick is the same (webdelprogramador). We "know" us about 1 and half year.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Hey Friends
I have a combo box on a dialog box
I have handle of Main Window & of Combo Box as well.
Now i need to send a Up Arrow Key / Down Arrow Key to the above combobox/main window
tried
SendMessage(cr_MainWindow,WM_KEYDOWN,VK_UP,0);
SendMessage(cr_Combo,WM_KEYDOWN,VK_UP,0);
However it seems i am missing something.
Need help.
Regards
|
|
|
|
|
What are trying to accomplish...? And what is missing?
- NS -
|
|
|
|
|
Hi
I am trying to change vista theme
I open Theme settings & then try to change the vista theme by clicking down arrow to go to some other theme
if i use ccombobox::selectstring
it does'nt works & it seems it needs down arrow key or up arrow key to change theme.
so i am trying to send up arrow or down arrow key to combo box in theme settings
Regards
|
|
|
|
|
vikrant kpr wrote: SendMessage(cr_MainWindow,WM_KEYDOWN,VK_UP,0);
SendMessage(cr_Combo,WM_KEYDOWN,VK_UP,0);
Are these messsages being received by the application?
"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
|
|
|
|
|
no idea whether it receives or not
do u think that the syntax/way is correct?
I am trying to change vista theme
I open Theme settings & then try to change the vista theme by clicking down arrow to go to some other theme
if i use ccombobox::selectstring
it does'nt works & it seems it needs down arrow key or up arrow key to change theme.
so i am trying to send up arrow or down arrow key to combo box in theme settings
Regards
|
|
|
|
|
vikrant kpr wrote: do u think that the syntax/way is correct?
No.
You've completely ignored the LPARAM when sendig the WM_KEYDOWN message.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
vikrant kpr wrote: no idea whether it receives or not
Then how do you know if the problem is with the way you are sending the message, or the way the message is being received? Knowing that much would eliminate 50% of the possibilities.
"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
|
|
|
|
|
How to programatically change the User Locale?
In the NLS documentation it is mentioned that it is not possible, is there any way around for this?
Thanks!
|
|
|
|
|
a.mulay wrote: How to programatically change the User Locale?
How about setlocale() ?
"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
|
|
|
|
|
Thanks but this is not enough.
setLocale() is specific to the current program, I need to modify User Local which we modify through the Control Panel --> Regional and Language Options --> Regional Settings.
One way I found out is modifying the registry at the following location HKEY_CURRENT_USER --> Control Panel --> International --> Locale
But I need an elegent solution.
|
|
|
|
|
a.mulay wrote: setLocale() is specific to the current program...
It helps to specify all of your requirements up front.
"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,
I have a msflexgrid with 2 columns and 25 rows(all with data in it) in my dialog.i'm also having a edit box in the same dialog above the flex grid.now wat i want is..if i type a name or a letter in the edit box the mouse pointer should go to that row that contains the name.
for example if i hav 2 colums(name and rollno)in msflexgrid
if i type "A" in the edit box,thn the mouse cursor should go to the row where that name column contains first letter as "A".Is there any function for getting the mouse pointer to our flexgrid?
Anybody please help mi in this regard.
Thanks in advance,
Saravana..
|
|
|
|
|
iam not sure, weather you can take your mouse pointer or current focus to the required cell, but you can select the required cell and also set its color.
if you are stuck up in searching the item, then,
you have to initialise the loop and search every item, and see if any letter has the starting digit A (for example).
any more guidance required?
you are welcome.
good luck.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
How create MFC toolbar with png icons ?
|
|
|
|