save file from resource to disk

I've been trying to do this program for like 2 hours already, googling and stuff, however I can't finish it because Im having troubles with saving file from resource, basically this program is supposed to:

1.find current wallpaper (working) it on the desktop as wallpaper.jpg (working)
3.load new wallpaper from resource (working) loaded wallpaper on the desktop (kinda working)
5.set new wallpaper using function SetNewWallpaper(char path[MAX_PATH]) (doesn't work because of #4)

so, when I try to load my bmp image from resource it will load it fine (i guess) but I can't load it after saving, also after I open it with notepad++ (the image) it has slightly different "source code" than the original, well, actually I've noticed that only first line is different, I dont know why, but could someone help me? I actually never used resources for this purpose



where's the problem?

also am I using function to set wallpaper correctly?
To fix the file save, swap BITMAP for RCDATA in the .rc file and use RT_RCDATA rather than RT_BITMAP in the .cpp file. (Follows links below for explanation).

Note that a bitmap stored using RCDATA cannot be loaded with LoadImage.

also am I using function to set wallpaper correctly?

Looks ok to me. (And worked for me, too!)


Is there a way to preserve the BITMAPFILEHEADER when loading a Bitmap as a Windows resource?

The format of bitmap resources

I "fixed" this by adding that first line manually (first few characters that were missing) since i had to do it in that day, but I'll take a look at your solution too! :)
The first 14 bytes? If so, you were adding back the BITMAPFILEHEADER (see Raymond Chen's article (in his The Old New Thing blog.)

Topic archived. No new replies allowed.