How can I paste any data in the <project>.exe file?

Started by sp00n, May 01, 2007, 10:01:56 AM

Previous topic - Next topic

sp00n

I need to keep a binary data(near 3Mb) inside my exe-file. How can I do it in Pelles C?
P.S. data is just binary file, no bitmap, no text, no any known format:)

JohnF

Try using RCDATA in the .RC file

2  RCDATA "data.dat"

John

sp00n

Thanks a lot
And next noob question: How can I work with this resource(reading/writing)? Or must I use the WizWriteFileFromResource function?

TimoVJL

May the source be with you

JohnF

Quote from: sp00n on May 01, 2007, 10:26:57 AM
Thanks a lot
And next noob question: How can I work with this resource(reading/writing)? Or must I use the WizWriteFileFromResource function?

I expect you could use WizWriteFileFromResource() but if not look at these API's

HRSRC hRes = FindResource(hInst, name, RT_RCDATA);
DWORD dwResSize = SizeofResource(hInst, hRes);
HGLOBAL hResGlobal = LoadResource(hInst, hRes);
LPVOID lpResMem = LockResource(hResGlobal);

You should check the return values of course.

John

sp00n


sp00n

Quote from: JohnF on May 01, 2007, 01:10:21 PM
Quote from: sp00n on May 01, 2007, 10:26:57 AM
Thanks a lot
And next noob question: How can I work with this resource(reading/writing)? Or must I use the WizWriteFileFromResource function?

I expect you could use WizWriteFileFromResource() but if not look at these API's

HRSRC hRes = FindResource(hInst, name, RT_RCDATA);
DWORD dwResSize = SizeofResource(hInst, hRes);
HGLOBAL hResGlobal = LoadResource(hInst, hRes);
LPVOID lpResMem = LockResource(hResGlobal);
Thanks John. It working well.

TimoVJL

QuoteIs it work on PocketPC? Cause I have a linker error about Invalid machine type
No, there was machine type IMAGE_FILE_MACHINE_I386 .
In File2Obj1.zip have changed ifh.Machine = IMAGE_FILE_MACHINE_UNKNOWN .
Perhaps this works with PocketPC.
May the source be with you

Vortex

Quote from: sp00n on May 01, 2007, 10:01:56 AM
I need to keep a binary data(near 3Mb) inside my exe-file. How can I do it in Pelles C?
P.S. data is just binary file, no bitmap, no text, no any known format:)

sp00n,

You can use a binary to MS COFF object module converter to embed binary data in your executable.
Code it... That's all...

TimoVJL

May the source be with you

sp00n