Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8856065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:16:34+00:00 2026-06-14T14:16:34+00:00

I have a text file that I would like to include in a stand

  • 0

I have a text file that I would like to include in a stand alone executable. The file itself sits in source control in another directory and I think I want to have the text file added to the executable at compile time.

I’ve been reading a bit about resources but I’m not sure exactly what would be the best way to add the file. I also don’t know how I would reference and read from the file during execution.

The project is statically linked MFC, and I’m using vs2010. Any help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:16:35+00:00Added an answer on June 14, 2026 at 2:16 pm

    Simply add the file as a resource into your application. You can “read” it with code similar to this:

    /* the ID is whatever ID you choose to give the resource. The "type" is
     * also something you choose. It will most likely be something like "TEXTFILE"
     * or somesuch. But anything works.
     */
    HRSRC hRes = FindResource(NULL, <ID of your resource>, _T("<type>")); 
    HGLOBAL hGlobal = NULL;
    DWORD dwTextSize = 0;
    
    if(hRes != NULL)
    {
        /* Load the resource */
        hGlobal = LoadResource(NULL, hRes);
    
        /* Get the size of the resource in bytes (i.e. the size of the text file) */
        dwTextSize = SizeofResource(NULL, hRes);
    }
    
    if(hGlobal != NULL)
    { 
        /* I use const char* since I assume that your text file is saved as ASCII. If
         * it is saved as UNICODE adjust to use const WCHAR* instead but remember 
         * that dwTextSize is the size of the memory buffer _in bytes_).
         */
        const char *lpszText = (const char *)LockResource(hGlobal);
    
        /* at this point, lpszText points to a block of memory from which you can
         * read dwTextSize bytes of data. You *CANNOT* modify this memory.
         */
        ... whatever ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a huge text file that I would like to split into multiple
I have text file with some stuff that i would like to put into
I have some HTML text files that I would like to dynamically include in
I have a text file that looks like this. A 102 B 456 C
I have a text file that has a list of directory names like this:
I have a text file that looks like this: 1 2 4 3 5
I have a bunch of JavaScript files that I would like to include in
I would like to automatically pre-translate a bunch of text files that I have
I have Text file that contains data separated with a comma , . How
I have a text file that I want to edit by rewriting it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.