How to read remote INI files
I read INI file strings through GetPrivateProfileString API. However, the INIs in local windows directory could be read like 开发者_Python百科that. How can I read and edit a INI file in a Remote machine.
You should not expect to be able to modify INI files stored on remote machines. Whatever your problem is, this is not the solution.
I guess you're asking how to read a remote file (which is what this would boil down to). The easiest option if it's available is probably to just read the file using a remote UNC file path, e.g. \\SomeMachine\SomeShare\TheFile.ini
. If you can't do that, you need to figure out a way to transfer the file to the local machine, either out of band or on demand using named pipes, TCP sockets, or something similar.
Why are you using INI files anyway? They were essentially deprecated after the 16-bit Windows era. I'd highly recommend a different approach (e.g. the registry, an XML config file, ...).
I only found out recently that you can't access INI files on UNC paths.
My solution was to map a drive letter to that location and it worked.
So instead of \myserver\myinipath\myinifile.ini
I mapped X to that location...........
net use x: \myserver\myinipath
in case you need to login to that UNC path/server then
net use x: \myserver\myinipath /user:loginname password
I now use x:\myinifile.ini
精彩评论