How to embed a file into an executable?

前端 未结 6 1351
一个人的身影
一个人的身影 2020-11-27 18:21

I have a small demo executable wrote in C++ that depends only on one 5kb PNG image being loaded before it can run, which is used for a pixel text I made. Because of this on

6条回答
  •  没有蜡笔的小新
    2020-11-27 18:22

    You can embed any arbitrary file into your program resources: (MSDN) User-Defined Resource.

    A user-defined resource-definition statement defines a resource that contains application-specific data. The data can have any format and can be defined either as the content of a given file (if the filename parameter is given) or as a series of numbers and strings (if the raw-data block is specified).

    nameID typeID filename
    

    The filename specifies the name of a file containing the binary data of the resource. The contents of the file are included as the resource. RC does not interpret the binary data in any way. It is the programmer's responsibility to ensure that the data is properly aligned for the target computer architecture.

    Once you've done that you can use the LoadResource function to access the bytes contained in the file.

提交回复
热议问题