#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>
char image[255];
FILE *file;
int main(int argc, char *argv[])
{
HKEY hKey;
strcpy(image, argv[1]);
if((file = fopen(image, "r"))==NULL){
printf("The specified file doesn't exist!");
}
else
{
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_SET_VALUE, &hKey) != ERROR_SUCCESS){
printf("Couldn't open registry!");
}
else
{
RegSetValueEx(hKey, "Wallpaper", 0, REG_SZ, (const unsigned char*)image, sizeof(image));
RegCloseKey(hKey);
}
}
fclose(file);
system("RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters");
printf("Check your background, it should be changed!");
system("PAUSE");
return 0;
}
There, this is the code, uncommented but if someone doesn't understand something feel free to ask. The program has only one bug, it crashes when no argument is given. So the usage goes like this, "nameofbin nameofimage", the image has to be a 24-bit BMP (don't ask why, its windows) u wanted the program compact so no place for conversion algorithms. I hope u can get it to work, if not ask and ill try to fix that. ^_^