LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Methods of file protection

Hi.

I need a method of file protection because my application doesn't work if my file is deleted (my application depends of a file that contains some settings for my application). I made my settings file read only, hidden and system file using the function:

SetFileAttrs (fileCurentName, 1, 1, 1, 1);

Is there another method to protect my settings file?

Thanks.
0 Kudos
Message 1 of 2
(2,934 Views)
1. Your program should contain some default settings if the settings file isn't found. You could pop-up a dialog box asking the user to confirm some settings, but you should hard-code some defaults if you can't find the file.
2. There is no method of file protection that Windows Explorer can't undo. By default, Explorer doesn't display hidden or system files, but users can change these options. Depending on your Windows security settings, you could put the file in a directory that only an administrator has read/write access to, but then regular users wouldn't be able to update it.
3. You may be better to store the settings in the Windows Registry rather than in a file. Then you won't have to worry about the file being deleted. See the sample that ships with CVI: ..\CVI\samples\apps\regadd. The Programmer's Toolbox has Windows Registry functions. Add ..\\CVI\toolslib\toolbox\toolbox.fp to your project, then on the project window menu, goto Instrument >> Programmer's Toolbox >> Windows Registry (with Flatten not checked) to see the registry functions. Again, you need some defaults if the registry keys aren't found.
Message 2 of 2
(2,931 Views)