07-14-2009 11:15 AM
I want to open a ini file and set its access attribute to no sharing with other person. But when running,
labview will crash every time. My enviroment is xp+labview8.5. please help me to check my subvi.
If labview don't support this, how can i set ini file access attribute?
Thanks very much.
Solved! Go to Solution.
07-14-2009 02:59 PM
The output to Open Config Data is a refnum to the *data* in the file and not to the file itself.
You need to open an instance (Open/Create/Replace File) of the file to generate a file refnum.
07-14-2009 07:58 PM
hi, Jonnie,
Thank you very much.
According to your opinion,If I want to read or write data from ini file,I must use ini refnum,right?
How about close file, should I call different close function to close two refnum one by one?
Thanks.
07-15-2009 07:57 AM
I'm not entirely sure what you are trying to accomplish, but yes you'd need to open both a config file data ref and a file ref and then subsequently close both at the end of the program. Nothing gets written to the config file until Close Config Data.vi is executed, which also requires allowing access to the file. I used local variables to show which refnums are used where:
07-15-2009 10:12 AM
hi, Jonnie,
I just want to write test result to a ini file in a test subvi, and read content from it in another display subvi.
When writing file, reading don't be allowed. I think your example data block are very helpful for me.
Thank you very much.
07-15-2009 10:19 AM
Hi Jonnie 5,
you should definitively delete the local varibales and use the wire. 🙂
Mike
07-15-2009 10:42 AM
07-29-2009 07:24 AM
my problem still exist.
After open a ini file, open this ini file as a common file, then call deny access function. I design is that
don't allow other subvi to modify this ini file. But In fact, after call deny access function, current subvi
can not write to ini file. I have to set deny access to 2 to write to ini file.
This is not my wanted solution. Anyone can tell me how to resolve it?
thanks very much!
attache my vi.
07-29-2009 07:51 AM
Hi mmm2006,
why is changing the access shortly before writing the new data not a solution for you? If you need another solution, then you have to change the ini functions. The ini open file also close this file. It only read all contents. You have to change back the access right to two, because the close ini file function has to open the file again (because as i said, it was closed in the open ini file function) to write your data into it.
Mike
07-29-2009 07:54 AM
You can only set file permissions to be:
Allow read and write
Allow only read (no write)
Deny read and write
You cannot set a permission to be write and deny read.
If you set deny access to a file, then this is true for ALL calling vi's. With Config Data, you can still manipulate the data at any time, which does not affect the file until you call Close Config Data. So once you Open Config Data and get a refnum for the data, you can deny access to the file and change the data all you want. The file itself can only be changed by Close Config Data, which requires you to restore R/W access to the file.