2

Im wondering if theres a way to store information inside of a .exe file. Like I've compiled an application using VS 2013 Express, but I'm going to need to be able to save once the program has been opened once, since something different happens the first time. Is there any way I'd be able to save a boolean or a few booleans inside of my .exe instead of creating a .dll or .txt database on the host computer? Creating an external database just seems like a bit of a waste for a handful of booleans.

Thanks!

Nathan
  • 1,287
  • 6
  • 15
  • 32
  • 3
    No - executable files are not writable. You'll need an external data store (file, database, etc.) – D Stanley Feb 17 '14 at 15:28
  • 1
    See this: http://stackoverflow.com/questions/453161/best-practice-to-save-application-settings-in-a-windows-forms-application – Habib Feb 17 '14 at 15:29
  • 1
    @Habib Thanks! Your link should help my figure this out – Nathan Feb 17 '14 at 15:36
  • Hmm, an exectuable that modifies itself... almost sounds like a virus? ;) – Jeff B Feb 17 '14 at 16:09
  • Why everybody say *no*? Ofc you can *store something in the running exe-file* (I doubt it is possible to in *.Net executable*, but does anyone say so?), but this task it not trivial and even making database is way simpler (though, more likely simple configuration file, created by any means, will suffice). – Sinatr Feb 17 '14 at 16:29

3 Answers3

4

Is there any way I'd be able to save a boolean or a few booleans inside of my .exe?

No - executable files are not writable. You'll need an external data store (file, database, etc.)

A config file is probably the easiest approach, and you can easily have config files per user (that are writable) with very little extra coding.

D Stanley
  • 149,601
  • 11
  • 178
  • 240
0

No you can't. The usual practice is to save your values in the Registry or somewhere in protected storage.

Captain Kenpachi
  • 6,960
  • 7
  • 47
  • 68
0

Windows locks .exe file while it is executed and you could not modify this .exe (storing something in it is similar to modification).

curiousity
  • 4,703
  • 8
  • 39
  • 59
  • What if I extract/create/run another exe-file (via scheduler, lol?) and terminate original process. Am I still could not modify *this .exe*? – Sinatr Feb 17 '14 at 16:32