Dll issue while launching the application
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 ..
Re: Dll issue while launching the application
I've never tried to capture that but here are some functions that might be useful http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
1 Attachment(s)
Re: Dll issue while launching the application
I have the screenshot of theerror message ..
Please FDA .
Re: Dll issue while launching the application
Quote:
Originally Posted by
vikuseth
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.
Code:
extern "C" {
// define exported functions
} // extern "C"
Re: Dll issue while launching the application
Quote:
Originally Posted by
vikuseth
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.
Regards,
Paul McKenzie