File types trouble...

This is a discussion on File types trouble... within the Windows Programming forums, part of the Platform Specific Boards category; Ok, I am sorry for making a thread about something like this but I have searched to no avail on ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    673

    Question File types trouble...

    Ok, I am sorry for making a thread about something like this but I have searched to no avail on google. I am trying to find a file type that I can write text to and retrieve those values, but I need my program to be the only program able to open it. I dont care what type of file it is as long as it cant be opened with notepad, wordpad, MS Works, Word processor or anything like that. If anything can you point me to a site showing something on making my own filetype. Any help is greatly appreciated.

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    Basically, you can read and write from / to absolutely *any* file type using either ostream or ifstream. Really, you can read an .exe and write on a .jpeg if you want. If you want it to be "impossible" to read your file using a text editor, I suggest you to look into encryption. There are many algorithms out there. Choose whichever is the best suited for your needs. I know that RSA and MD5 are *very* good but I'm not quite good with encryption so perhaps someone else can fill you in.

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    I know XOR if that would work? I just didnt wanna have to go into encryption. but if I must then fine. Yet again anyone know how to make a file type? Thanks alot desolation.

  4. #4
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Simply, you can't stop a file from being opened in Notepad/Wordpad/etc. You shouldn't try. Why would you want to stop a user from being able to view it? It is of course, their data. If it's not, that's what file permissions are for - see if the underlying filesystem can solve your problems before getting extreme.

    If you write your file format in binary, then the average computer user opening it in Notepad will be confronted with "random junk" and probably won't mess with it. Otherwise, there is encryption, but is it needed? (MD5, btw, is a hash function. What you put into it, you won't be getting back out.)

    "Make a file type" Write data to a file.
    To read a file, you have to know how the data in the file is laid out. Either you design this yourself, or you follow specs if you're reading a file type you didn't design. To "make" a file type, you just write data to a file in a way meanful to yours or someone else's program.

    Windows merely checks the extension on a file, and makes a guess at what "type" it is. A PNG file named "mypic.bmp" is still a PNG file - but will be wrongly detected as a bitmap by Windows. The associations between extensions and types are stored in the registry. (Other OSs examine the file's contents and plug a (better) guess that way.)
    Last edited by Cactus_Hugger; 07-09-2006 at 08:41 PM.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble writing to file using fwrite()
    By yougene in forum C Programming
    Replies: 4
    Last Post: 12-30-2008, 05:13 PM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 09:39 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 11:51 PM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21