|
-
Jun 17th, 2008, 10:18 PM
#1
Thread Starter
Lively Member
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
-
Jun 17th, 2008, 10:35 PM
#2
Re: Creating my own extension
You're right that it's about encrytion but you can't stop other programs from opening a file. You'll need to use encryption to prtect the data.
-
Jun 17th, 2008, 10:40 PM
#3
Thread Starter
Lively Member
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?
-
Jun 17th, 2008, 11:02 PM
#4
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:
Private Sub Form_Load()
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...
-
Jun 17th, 2008, 11:10 PM
#5
Thread Starter
Lively Member
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?
-
Jun 18th, 2008, 03:10 AM
#6
Re: Creating my own extension
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 20th, 2008, 08:13 AM
#7
Member
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).
-
Jun 20th, 2008, 08:41 AM
#8
Re: Creating my own extension
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|