How to read/write to ini file on a network? 
Author Message
 How to read/write to ini file on a network?

Hi
I am a relative newcomer to VB and have just finished installing an App on a
small network (3 computers). There is a password required to access my
program, and this is saved in an ini file on one of the computers.  The
problem I am having is that if I change the password the change is not
recognisd unless I reboot, or physically access the file through Network
Neighborhood.  Is there a way I can force/refresh an update everytime I read
and/or write to the file?

--
*************************************************

Peter Marquet


************************************************



Sun, 19 May 2002 03:00:00 GMT  
 How to read/write to ini file on a network?
If you write to the .INI file using the WritePrivateProfileString() API
call, then the change "should" be immediately available to your application,
providing you don't have any weird (non-Microsoft) networking software that
is caching writes etc.  I've seen that sort of thing happen with NFS from
FTP Corp.

Regards
Ian


Quote:
> Hi
> I am a relative newcomer to VB and have just finished installing an App on
a
> small network (3 computers). There is a password required to access my
> program, and this is saved in an ini file on one of the computers.  The
> problem I am having is that if I change the password the change is not
> recognisd unless I reboot, or physically access the file through Network
> Neighborhood.  Is there a way I can force/refresh an update everytime I
read
> and/or write to the file?

> --
> *************************************************

> Peter Marquet


> ************************************************



Sun, 19 May 2002 03:00:00 GMT  
 How to read/write to ini file on a network?
I am using the Get and WritePrivateProfileString() API for entering the
information

There are 3 computers (Terminal 1, Terminal 2, Terminal 3), each is writing
and reading to the ini path  "\\Terminal 1\C\Program
Files\Rewards\Password.ini"

If I enter a new password on any of the terminals the change is not
reflected unless I reboot. (or open the file manually through network
neighborhood )

If  I change the password on Terminal 1 using the string "c:\Program
Files\Rewards\Password.ini" , the change is reflected immediately - but if I
use the network string "\\Terminal 1\C\Program Files\Rewards\Password.ini"
it doesn't.

It is like the last used ini information is stored in memory, rather than
physically accessing the file. (The OS is WIN98 2nd edition)

Quote:
> > *************************************************

> > Peter Marquet


> > ************************************************



Sun, 19 May 2002 03:00:00 GMT  
 How to read/write to ini file on a network?
Pete,
I don't have Win-98 machines to compare this on (Company decission to avoid
98) but the following works as expected on NT to NT and on NT to 95.

This is only a guess but maybe 98 is holding the file handle open and
therefore your write data is cached.  You could try placing another
WritePrivateProfileString() call to a dummy local drive after the proper
one.  If my guess is right, then this might force the original handle closed
etc.

Regards
Ian

Private Declare Function WritePrivateProfileString Lib "kernel32" Alias
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal
lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal
lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As
String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Private Sub Command1_Click()
Dim lRc         As Long
Dim szResult    As String
Dim lResult     As Long

    lRc = WritePrivateProfileString("APP_NAME", "KEY_NAME", "Value",
"\\xxx\D\TEST.INI")
    lResult = 255
    szResult = Space$(lResult)
    lRc = GetPrivateProfileString("APP_NAME", "KEY_NAME", "", szResult,
lResult, "\\xxx\D\TEST.INI")
    Debug.Print Left$(szResult, lResult)
End Sub


Quote:
> I am using the Get and WritePrivateProfileString() API for entering the
> information

> There are 3 computers (Terminal 1, Terminal 2, Terminal 3), each is
writing
> and reading to the ini path  "\\Terminal 1\C\Program
> Files\Rewards\Password.ini"

> If I enter a new password on any of the terminals the change is not
> reflected unless I reboot. (or open the file manually through network
> neighborhood )

> If  I change the password on Terminal 1 using the string "c:\Program
> Files\Rewards\Password.ini" , the change is reflected immediately - but if
I
> use the network string "\\Terminal 1\C\Program Files\Rewards\Password.ini"
> it doesn't.

> It is like the last used ini information is stored in memory, rather than
> physically accessing the file. (The OS is WIN98 2nd edition)

> > > *************************************************

> > > Peter Marquet


> > > ************************************************



Sun, 19 May 2002 03:00:00 GMT  
 How to read/write to ini file on a network?
One of the beauties of INI files is that they are cached in memory. Once you
read one, it is fast to get to it again.
I don't know how you get rid of it and cause a refresh, though.
--
Gary, MCT, MCP, MCSD
home site http://www.enter.net/~garyl


Quote:
> I am using the Get and WritePrivateProfileString() API for entering the
> information

> There are 3 computers (Terminal 1, Terminal 2, Terminal 3), each is
writing
> and reading to the ini path  "\\Terminal 1\C\Program
> Files\Rewards\Password.ini"

> If I enter a new password on any of the terminals the change is not
> reflected unless I reboot. (or open the file manually through network
> neighborhood )

> If  I change the password on Terminal 1 using the string "c:\Program
> Files\Rewards\Password.ini" , the change is reflected immediately - but if
I
> use the network string "\\Terminal 1\C\Program Files\Rewards\Password.ini"
> it doesn't.

> It is like the last used ini information is stored in memory, rather than
> physically accessing the file. (The OS is WIN98 2nd edition)

> > > *************************************************

> > > Peter Marquet


> > > ************************************************



Sun, 19 May 2002 03:00:00 GMT  
 How to read/write to ini file on a network?
Many thanks for replies...  I have set the ini to refresh itself when users
enter password - it's working fine!
Quote:
> *************************************************

> Peter Marquet


> ************************************************



Mon, 20 May 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Read/Write INI Files w/Access 7.0

2. Ini-file, read write and empty lines.

3. Reading and writing from and to ini files

4. read/write an .ini file

5. Reading and writing to an INI file?

6. Reading and Writing to .ini files - help please.

7. Read and Write to INI files

8. Reading/writing to an INI file

9. Reading / Writing an INI file

10. Reading / Writing an INI file

11. How to read and write an ini file with Qbasic 4.5

12. Reading/Writing to the Registry and .INI file???

 

 
Powered by phpBB® Forum Software