How to put your own files into the VC project as resource files? How can I extract (release) this file from the EXE file at runtime?

Source: Internet
Author: User

1. In vc ide, add new resource type such as "res_data", then add your file to the Project

Resource as the new type.

2. Fetch your file from executable file at runtime, can use follow function:
Bool res2file (maid, maid)
{
Hrsrc hres =: findresource (null, lpname, lptype );
Hglobal GL =: loadresource (null, hres );
Lpvoid Lp =: lockresource (GL );
Handle fp =: createfile (filename, generic_write, 0, null, create_always, 0, null

);
If (FP = invalid_handle_value)
Return false;

Dword;
If (! : Writefile (FP, LP, sizeofresource (null, hres), & A, null ))
Return false;

Closehandle (FP );
Freeresource (GL );
Return true;
}
Use this function such as this format:
Res2file (makeintresource (id_res_data), "res_data", "C: // fontres. TTF ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.