Problem Description
I have an application that loads a dll at runtime. I want to allow a user to change code in that dll while the app is running. When the user clicks the "compile" button in the app it would free all the data from the dll. After freeing up the dll the app would then rebuild the dll. Essentially acting as a Run time compiled program.
Ideal Implementation
void ReCompile()
{
//hDLL contains dll that was already loaded.
FreeLibrary(hDLL);
//code to rebuild MyDll.DLL would go here.
LPCWSTR dll = L"MyDll.dll";
hDLL = LoadLibrary(dll);
}
This currently works i just need to know how to rebuild the dll through code so it feels much more smooth and intuitive.
Current Implementation
void Free()
{
FreeLibrary(hDLL);
}
//I go into my other visual studio that's running and press the build button myself.
void ReloadDll()
{
LPCWSTR dll = L"MyDll.dll";
hDLL = LoadLibrary(dll);
}