Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show an (custom) error when "required" runtime libraries are not present?

I've been making a program in Visual Studio 2012, what comes with it is that when I send my application to someone, they need the VS2012 Runtime, which sometimes they don't know where to download or what they need (for normal users "xxx.dll is missing" is very misleading).

I know exactly which dependencies my application requires (fantom.dll [Lego Mindstorms stuff] and the VC++ 2012 Redist).

I would like to show a dialog when these libraries are missing on application startup and provide the user with download links for these libraries.

Is this possible to accomplish?


2 Answers

Yeah you could do something like:

  1. Move all of the code in your binary into a DLL.
  2. Create an EXE which dynamically loads the DLL using LoadLibrary and unloads it with FreeLibrary.
  3. If LoadLibrary fails, check if its due to missing DLLs, if so then display a MessageBox/your custom message and exit.

Of course this means your EXE project must NOT depend on the runtime itself - this shouldn't be an issue since you'll only need to call 3 win32 API's.

like image 133
paulm Avatar answered May 18 '26 03:05

paulm


No it's not possible but you can create an installer for your program. The error is thrown during the loading of your program, before your code execution...

You can try with that : http://www.codeproject.com/Articles/24187/Creating-an-Installer

like image 41
Pierre Fourgeaud Avatar answered May 18 '26 01:05

Pierre Fourgeaud



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!