Results 1 to 8 of 8

Thread: Creating my own extension

  1. #1

    Thread Starter
    Lively Member feneck's Avatar
    Join Date
    Mar 2007
    Location
    Australia, Queensland, Gympie
    Posts
    85

    Talking Creating my own extension

    I was wondering...

    I have a program that stores text files in the "App.Path".
    The extension I have given these files are ".khj".

    Double clicking on it, windows asks you what do you want to open it with. That is good, because I don't want my users opening these setting files. However, if they say to open the file with notepad, all the data is displayed, perfectly...

    So my question is, how do I make a new extension, that can't just be opened by notepad or word. So only MY program can read it?

    I'm guessing that it might have something to do with encryption?
    Or am I wrong?

    Thanks

    REMEMBER TO RATE

  2. #2

  3. #3

    Thread Starter
    Lively Member feneck's Avatar
    Join Date
    Mar 2007
    Location
    Australia, Queensland, Gympie
    Posts
    85

    Re: Creating my own extension

    So the best way to go about this would to be encrypt the data so that when opened in notepad it comes out scrambled? There's no other way to do it?

    REMEMBER TO RATE

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Creating my own extension

    You can't keep another program from opening the file. Unless you open the file in Lock mode from your program, but your program would need to always be open. Ex:
    vb Code:
    1. Private Sub Form_Load()
    2.     Open "C:\test.txt" For Input Lock Read As #1

    Then trying to open it with notepad, you would get the error:
    "The process cannot access the file because it is being used by another process."

    But if someone closes your program then so much for that...

  5. #5

    Thread Starter
    Lively Member feneck's Avatar
    Join Date
    Mar 2007
    Location
    Australia, Queensland, Gympie
    Posts
    85

    Re: Creating my own extension

    Yeah, good idea, but nah.

    So my next question would be, encryption, whats the best way to go about that?

    REMEMBER TO RATE

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Creating my own extension

    Some basic simple encryption.
    http://vbnet.mvps.org/code/algorithms/index.html
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Member
    Join Date
    Dec 2007
    Posts
    57

    Re: Creating my own extension

    If you don't want to go throught the 'custom' encyption route, there is another simple solution. You could wrap your text files in a password-protected zip file. This can be done programatically using the command-line verison of of 7-Zip (freeware), and the file can still have your .khj extension (it doesn't have to be *.zip).

  8. #8
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Creating my own extension

    Quote Originally Posted by feneck
    Double clicking on it, windows asks you what do you want to open it with. That is good, because I don't want my users opening these setting files.
    If you want to set how the files look in explorer, like assigning them an icon and setting the Details View decription to something other than "khj file", as well as define the action that happens when they're double-clicked, see this thread for details.

Posting Permissions

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



Click Here to Expand Forum to Full Width