Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Build read-only file into exe file?

Status
Not open for further replies.

davyzhu

Advanced Member level 1
Joined
May 23, 2004
Messages
494
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Location
oriental
Activity points
4,436
A read-only data file is read in a C/C++ program.
And I use stdio function such as fopen() to fread() to operate the file.
The content of the data file is constant.

How to build the file into exe file.

I work on MS windows. I use Visual C++ 6.0.

Any suggestions will be appreciated!
Best regards,
Davy
 

Check your compiler's linker manual to see how to link binary data into your executable. Every linker works differently.

If your linker doesn't provide that feature (shame on it!), then you can use a hex converter utility to convert your data to a large char array (or whatever type is appropriate for your data), and then simply compile it. Maybe like this:
const char mydata[] = {0x35, 0x4F, 0x7C, 0xC1, 0x1D, ...};
 

Hi echo47,

I use Visual C++ 6.0.

Can I include "resources" file in my executable?

Best regards,
Davy
 

just # include the binary data only

what i do is make a bin file from the data hex

then just add an include to the project
and paste the block there to a fresh file of the right namings

inside a stucture as the member above mentions

you can leave it as hex but i prefer bins
{this way you can encrypt it if needed easier than in hex form}

once this is done you can call it like a file and load it to an 3d array
for use within your exe using a simple loop

make the array like

BYTE mydata[256][256][16];

you now have array 256 by 256 by 16 bytes

same trick works for dlls also
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top