LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

After open a ini file, can i set deny attribute using deny access function?

Solved!
Go to solution

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.

 

 

0 Kudos
Message 1 of 21
(4,590 Views)
Solution
Accepted by topic author mmm2006

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.

inirefnum.JPG

 

 

Message 2 of 21
(4,576 Views)

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.

0 Kudos
Message 3 of 21
(4,555 Views)

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:

 iniref.JPG

0 Kudos
Message 4 of 21
(4,541 Views)

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.

 

 

0 Kudos
Message 5 of 21
(4,532 Views)

Hi Jonnie 5,

you should definitively delete the local varibales and use the wire. 🙂

 

Mike

Message 6 of 21
(4,528 Views)
I just knew someone would rip me on that (at least I didn't use globals).  They do make useful educational labels though rather than a teal wire nest. :smileyvery-happy:
0 Kudos
Message 7 of 21
(4,521 Views)

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.  

0 Kudos
Message 8 of 21
(4,460 Views)

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

0 Kudos
Message 9 of 21
(4,453 Views)

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.

0 Kudos
Message 10 of 21
(4,451 Views)