dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: how can i customise my own file extension format?

  1. #1
    Join Date
    Nov 2010
    Posts
    139

    how can i customise my own file extension format?

    i have a program i created in c++. its a logon application that i want to use to protect private files.
    i would like to know how to create my own file extentions so that only my program can open it.
    for example if i double click the file, my application opens and the user logs in, if the correct credentials
    are entered they are allowed access to the file (it opens so they can read it).

    at the moment my program opens up a word document when the user enters his correct credentials.
    i am using the system() function for this. however this file when clicked from the start menu opens up using word.

    basically i'm not sure what is best or whats right. is it best to just change the file extension so only my app can open it?
    or create and save a document in a custom file format so that only my program can open it and other applications cannot read them?
    if the latter, how can i do this, what are the steps?

    plus i have looked up on some info online and it says that i have to register my file. does this relate to just
    changing the file extension or creating a file format or both? How do i register my own file extension
    Last edited by katy_price; December 19th, 2010 at 01:41 AM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,406

    Re: how can i customise my own file extension format?

    If you can use MFC then CWinApp::RegisterShellFileTypes will help you.
    If not - see How to: Register Editor File Types

    Note, however, that you cannot prevent user to change the default application to open your file type.
    Victor Nijegorodov

  3. #3
    Join Date
    Nov 2010
    Posts
    139

    Re: how can i customise my own file extension format?

    can you just tell me simply how to create my own file extension for the file i have or a new one please?

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,406

    Re: how can i customise my own file extension format?

    I cannot do it better than Microsoft does it in MSDN.
    Victor Nijegorodov

  5. #5
    Join Date
    Nov 2010
    Posts
    139

    Re: how can i customise my own file extension format?

    Quote Originally Posted by VictorN View Post
    I cannot do it better than Microsoft does it in MSDN.
    hey, i have managed to create a file association by creating my own file extension. i have registered the new file extension and everything is fine that side. when i click a file with my extension my program now opens. however. my program is a login system a user must enter their username and password to see the actual content of the file. how do i do this? am i required to create some sort of code in my program? if so what code?

    plus i am able to change what the program is associated to via control panel >program >default program >set associations in windows 7, is there away of getting round this?

    thanks
    Last edited by katy_price; December 19th, 2010 at 08:24 PM.

  6. #6
    Join Date
    Oct 2010
    Location
    Australia
    Posts
    98

    Re: how can i customise my own file extension format?

    You might look into custom file compression - you create a special type of file compression that only your program knows the pattern of... (encryption)

    Something along the lines of simply changing the file size by removing certain characters in a certain order - and replacing them with your custom file handler to access it...

    This is just speculation because I have no idea how to do it - but I know that it is plausible. I believe that would solve your dilemma of users simply associating the file with the necessary program to open the protected file with just a different extension.

    If it was too easy then everyone would do it.

  7. #7
    Join Date
    Jan 2009
    Posts
    54

    Re: how can i customise my own file extension format?

    You have two separate problems.
    1. File association (now solved but with the caveat that it can be changed)
    2. Preventing other software from "interpreting" NOT reading the contents of the file.
    This is an important distinction. Anyone can use a binary file editor to OPEN and READ your file. The problem is making sure the contents are not actually interpretable. To achieve that you will need to do as Morbane suggested and use an encryption scheme.

  8. #8
    Join Date
    Jan 2009
    Posts
    54

    Re: how can i customise my own file extension format?

    Here is a commercial product that does what you are describing http://www.newsoftwares.net/folderlock/

  9. #9
    Join Date
    Jan 2009
    Posts
    54

    Re: how can i customise my own file extension format?

    You can only prevent users from changing the file NAME through the use of an Access Control List.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)