I am using one dll in my application for including the functionality provided by that dll . This dll i am getting after installing one msi . But in my application i have a requirement like if the user has not installed that msi then we have to show one warning message(e.g msi has not installed , code for this i have implemented in the main() of my application ) and have to exit from the application .
But the problem is if the user has not installed the msi , then while launching the application itself its showing one error message since its not able to get the dll and this time control not even coming to my main() where i have written the code for this msi checking (through registry entry).
Is there any efficient way to resolve this issue ..
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
But the problem is if the user has not installed the msi , then while launching the application itself its showing one error message since its not able to get the dll and this time control not even coming to my main() where i have written the code for this msi checking (through registry entry).
Is there any efficient way to resolve this issue ..
That's because the application tries to load the DLL when the application is loaded. The only way to prevent this, is to delay-load the DLL in the application using LoadLibrary and get the address of each exported function using GetProcAddress. You won't be able to use classes exported from the DLL in the application and it's best (in my experience) to use a C calling convention, i.e. put the exported functions in an 'extern "C"' block.
I have the screenshot of theerror message ..
Please FDA .
If there is any possiblity that a DLL doesn't exist, then the proper way to write your code is to use LoadLibrary() and GetProcAddress() as D_Drmmr suggested. This method is also used if your application doesn't require a DLL to run, but if it is available, to use it (i.e. a "plugin" architecture)
But in general, why doesn't your code first check if all components are available before starting the application? There are many more API functions that search for files on the path, and you should be using all of these facilities instead of hoping the user installed everything. Then you don't get these standard error boxes showing up, and instead you display your error to the user in any way you see fit.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.