Thread: i/o text file compiled with .exe

  1. #1
    Registered User canine's Avatar
    Join Date
    Sep 2001
    Posts
    125

    i/o text file compiled with .exe

    if you included a text file with your program could you acess it for read/write?
    In a perfect world every dog would have a home and every home would have a dog.
    Visit My Web Site, Canine Programming
    I use Win32 API

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    162
    I don't know how you could compile a text file in your .exe without the compiler giving errors, but if you mean include in in a zip file or something, you can try fstream, found in fstream.h.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    37
    i know
    (donīt hurt me for that)
    you can add a text file to the end of your exe so that the exe could read the text. but you have to know the exact size of it and start reading from the end of the compiled code. anyway windows donīt take care of additional data at the end of an exe, so it is still executable.

    for some reasons you cannot modify it during runtime

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    You should be able to add the file as a user defined resource.....

    Then use FindResource() to get a handle on it.......load it into memory with LoadResource()......lock it with LockResource() ......this then gives you a handle to the resource contents......then use WriteFile() to dump the data into a file.......

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Read word from text file (It is an essay)
    By forfor in forum C Programming
    Replies: 7
    Last Post: 05-08-2003, 11:45 AM