I came across a question today and i find it very interesting. I never thought of this back then when i haven’t tested C’s .dll and VB .NET together. This post would more be of a theory and it’s pretty simple. By the way, “Auto Updater” do mean that the program is capable of updating the version itself.
If you already know how to create a dynamic link library file, i think it’s pretty easy for you to do it. There is alot of method to do so but what i am suggesting here is to use 2 files. 1 would be your .exe file and the other would be your .dll file. I’ll assume that you’re building everything in C/++ because i am.
In your main program, you’ll have to decide when you’re going to check for updates and you’ll have to provide the if-else yourself. I’m only guiding on how will you perform the update for the function.
Now, the idea is to build your functions in a .dll form and your .exe file would execute them. So whenever a bug occurs it would occur in the .dll file. And when that happens you could send a trigger to your .exe file maybe by having them check your website whether there is a need for it to do so. When it does need to update, it performs the update function and it will download automatically from your website (probably a link that you’ve provided) and replace it with the .dll that you previously have. Voilà!
How do you call a function in a .dll in C/++
Let’s assume the .dll file is called “math.dll” and the function is called “Addition” as below
__declspec(dllexport) short Addition(short num1, short num2)
In order to call the function from the library, we have to first specify the function in our .exe. The codes below shows the full syntax for what is required.
typedef short (__stdcall *fAddition)(short num1, short num2);
HINSTANCE math = LoadLibrary("math.dll");
fAddition ptAddition = (fAddition)GetProcAddress(math, "Addition");
printf("%d", ptAddition(1, 2));
As you can see,
line 1 is used to define the function and its parameters
line 2 is used to load the library into an HINSTANCE variable so that we could free it later
line 4 is used to get the address of the function from the library by using GetProcAddress
line 6 as you can see is to show you that it works
line 8 is used to free the library once we’re done using it
Other information on C/++ calling dynamic link library – http://goffconcepts.com/techarticles/development/cpp/calldll.html
If you think that this is pretty silly for a small program (or some other reason), you might just want to build it in a single executable file. Have it check when to update and when it does, download the updated executable (the new version) from your website or somewhere and replace it with the original file. Produce creative ideas and you’ll be able to solve it in your own way.