MSLx Fanboy Posted August 30, 2005 Posted August 30, 2005 Is there a reason why file handles are not acceptable for INIRead and INIWrite functions? ;;This works $output = IniRead("C:\Windows\avrack.ini", "Settings", "Volume", "") MsgBox(0, "test", $output & @CRLF & @ERROR) ;;This doesn't $file = FileOpen("C:\Windows\avrack.ini", 0) $output = IniRead($file, "Settings", "Volume", "") $output = IniRead("C:\Windows\avrack.ini", "Settings", "Volume", "") MsgBox(0, "test", $output & @CRLF & @ERROR) FileClose($file) Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
Gigglestick Posted August 30, 2005 Posted August 30, 2005 (edited) Possibly because the FileOpen already has the file open, so the parts of IniRead/IniWrite that open the file are blocked? Edit: They'd be stepping on each other's I/O. Edited August 30, 2005 by c0deWorm My UDFs: ExitCodes
Josbe Posted August 30, 2005 Posted August 30, 2005 Is there a reason why file handles are not acceptable for INIRead and INIWrite functions?;;This works $output = IniRead("C:\Windows\avrack.ini", "Settings", "Volume", "") MsgBox(0, "test", $output & @CRLF & @ERROR) ;;This doesn't $file = FileOpen("C:\Windows\avrack.ini", 0) $output = IniRead($file, "Settings", "Volume", "") $output = IniRead("C:\Windows\avrack.ini", "Settings", "Volume", "") MsgBox(0, "test", $output & @CRLF & @ERROR) FileClose($file)<{POST_SNAPBACK}>Why do you need the handle for read an INI file?Simply, just compare the documentation: About IniRead page says :IniRead ( "filename", "section", "key", "default" )not like FileRead , the syntax is: FileRead ( filehandle or "filename", count )Mainly, IniRead wasn't designed for use file handles. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
/dev/null Posted August 30, 2005 Posted August 30, 2005 Is there a reason why file handles are not acceptable for INIRead and INIWrite functions?because IniRead() and IniWrite() are not implemented to accept a file handle. See source code script_file.cpp AutoIt_Script::F_IniRead.CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
MSLx Fanboy Posted August 31, 2005 Author Posted August 31, 2005 I know according to the help file that one says that file handles are permitted the other does not. My question is, Why not?If I can start learning more advanced C++ programming techniques, I might try to work on that code (just a wee bit). Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
Valik Posted August 31, 2005 Posted August 31, 2005 I know according to the help file that one says that file handles are permitted the other does not. My question is, Why not?If I can start learning more advanced C++ programming techniques, I might try to work on that code (just a wee bit).<{POST_SNAPBACK}>The INI functions wrap underlying INI-related Windows API calls. Unless you are prepared to write your own INI reading/writing code and re-implement all of it, there is no point (or sense) in making the INI functions accept a file handle.
MHz Posted August 31, 2005 Posted August 31, 2005 I know according to the help file that one says that file handles are permitted the other does not. My question is, Why not?<{POST_SNAPBACK}>Writing to an INI file is similar to writng to registry. Both IniWrite and RegWrite are more related to each other then as to FileWrite. You cannot have a handle for RegWrite? So IniWrite should not have one.
Valik Posted August 31, 2005 Posted August 31, 2005 And to confirm what MHz says, Microsoft agrees since they list the API functions for writing to INI files under the Registry section.
JSThePatriot Posted August 31, 2005 Posted August 31, 2005 Well to further concrete the idea of INI and Registry being related... Before the Registry there were INI files. They became very numerous, and Micro$oft wanted a central place to configure applications. They came up with what is known to us today as the Registry. *Disclaimer* Micro$oft may not have come up with the 'registry' idea, but they are certainly using it. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
MSLx Fanboy Posted September 2, 2005 Author Posted September 2, 2005 Ok, thanks, that would explain why. I'll stick with the existing code... Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now