CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2012
    Posts
    17

    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 ..

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    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
    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

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Jan 2012
    Posts
    17

    Re: Dll issue while launching the application

    I have the screenshot of theerror message ..
    Please FDA .
    Attached Images Attached Images  

  4. #4
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,042

    Re: Dll issue while launching the application

    Quote Originally Posted by vikuseth View Post
    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"
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

  5. #5
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Dll issue while launching the application

    Quote Originally Posted by vikuseth View Post
    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured