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)
2.save it on the desktop as wallpaper.jpg (working)
3.load new wallpaper from resource (working)
4.save 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

source:

http://pastebin.com/GniL72JQ

.rc

http://pastebin.com/biPTDPPN

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!)

Andy

Is there a way to preserve the BITMAPFILEHEADER when loading a Bitmap as a Windows resource?
http://stackoverflow.com/questions/1134050/is-there-a-way-to-preserve-the-bitmapfileheader-when-loading-a-bitmap-as-a-windo

The format of bitmap resources
http://blogs.msdn.com/b/oldnewthing/archive/2009/12/11/9935462.aspx
thanks!

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.)

Andy
Topic archived. No new replies allowed.