I need to repeatedly generate a Win32 DLL with a registration information function. This function uses literals to return customer specific registration information, with a separate DLL being built per customer.
I have a test version working correctly, with hard-coded information for one customer. The urgency for some sites dictates I generate some DLL's manually, but I would like to give the client an application that dynamically emits the C source and builds a DLL on demand.
What would be the the best way to do this? I have VS 2008 C++ Express, and thus the cl.exe compiler. My current approach would simply be to have a C# application with a string constant for the C source, and before generation, replace tokens in that with required parameters, then build and link by shelling out and running cl.exe.
Put all customer information as string resources in a .rc file. Link the corresponding .res file into your DLL. All code in the DLL that depends on that customer information would call LoadString to fetch this.
Then build a seperate program (or function) called "UpdateDLL.exe" that uses the Win32 APIs: BeginUpdateResource, UpdateResource, etc... to update the DLL with the new information.
Ship the following:
A pre-compiled DLL that has empty (or default) strings for the customer information in the resources.
Your UpdateDLL.exe tool that takes the DLL name and customer info file as command line param.
Your customer runs "UpdateDLL.exe customer.dll myinfo.txt" to update his copy of the DLL with his information.
My generic idea is to have a program like this:
string UserName = "PLACEHOLDER UserName ";
string RegCode = "PLACEHOLDER RegCode ";
bool CheckRegistration(string UserName, RegCode) {
...
}
Compile this to a .dll file. For each user, load the .dll file, find the two PLACEHOLDERs in it, and replace them the real user data. Make sure you pad the string with spaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With