Hi, I had no idea if I should post it in Windows Programming or General C-programming, but since win32 is the platform I'm working on I'm posting here...
Mod may move if it's in the wrong section.
So here is my question - I have a program that uses cURL to speak HTTP easily with my webserver.
But cURL needs a couple of DLL-files that should exist in the system32-folder. Now I don't want to ship these files with my executable - but instead have them as resources in my executable and automatically extract them and install in system32.
I am using Dev-Cpp and programming in C.
Do you have any idea on how to implement this in my program?
Thank you for your consideration
Why you would want to do such thing? Your extractiong will not check the version of dll and could replace the newer dll with the older one - breaking other applications
Installer on the other hand - always checks the file version before replacing the dll and notifies the end user - giving him the choice to replace dll or leave it intact.
You can always put the required dlls into the local dir of your application - in this case you can bring them as you like, but still I do not see a reason not to use a self extracting archive and start play with the resources of the executable
I didn't mention error handling etc - but it will offcorse be included.
I have made my choice of handling this problem, and I want to extract them from resources in my executable. With hours of googling, I have yet not found any information.
Btw. This is how I solved it:
1 BIN DISCARDABLE "path-to-.dll"
void Extract(WORD wResId , char szFilePath)
hrsrc = FindResource(NULL, MAKEINTRESOURCE(wResId) ,"BIN");
if(hrsrc == NULL)
//printf("Error Finding resource\n");
hLoaded = LoadResource(NULL, hrsrc);
if(hLoaded == NULL)
//printf("Error Loading Resource\n");
lpLock = LockResource(hLoaded);
if(lpLock == NULL)
//printf("Error Locking Resource\n");
dwSize = SizeofResource(NULL, hrsrc);
hFile = CreateFile(szFilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_HIDDEN, NULL);
if(!WriteFile(hFile, lpLock , dwSize , &dwByteWritten , NULL))
//printf("Error Writing to file\n");
I think you do NOT want CREATE_ALWAYS - that will cause the problems that vart points out with a newer version already existing on the target system and breaking other applications.
By the way, DLL's do not have to reside in system32 - they can be provided in the local directory where the application is located, e.g \program files\myapp.