DXRW4E Posted March 29, 2012 Share Posted March 29, 2012 (edited) Sorry for my EnglishHi All, I'm curious who and pramenter in this case SetupOpenInfFile Function ???SetupApiEx.au3Global Const $h_SetupApiDll = DllOpen("SetupApi.dll") Global Const $h_Kernel32DLL = DllOpen("Kernel32.dll") Global Const $INF_STYLE_NONE = 0 Global Const $INF_STYLE_OLDNT = 1 ;A legacy INF file format. Global Const $INF_STYLE_WIN4 = 2 ;A Windows INF file format. Global Const $INF_STYLE_NULL = Null ;; Or AutoIt v3.3.8 Global Const $INF_STYLE_NULL = "Null" ;;; ERROR_CLASS_MISMATCH = -536870399 ;;; ERROR_WRONG_INF_STYLE = -536870656 ;;; ERROR_LINE_NOT_FOUND = -536870654; Func _SetupOpenInfFile($FileName, $InfClass = 0, $InfStyle = 0) ;;AutoIt v3.3.8 ;~ Local $HINF, $sType = "wstr" ;~ If $InfClass = $INF_STYLE_NULL Then $sType = "ptr" ;Thanks ProgAndy ;~ $HINF = DllCall($h_SetupApiDll, "long", "SetupOpenInfFileW", "wstr", $FileName, $sType, $InfClass, "dword", $InfStyle, "uint*", 0) ;~ Return SetError(_WinAPI_GetLastErrorEx(), $HINF[4], $HINF[0]) $HINF = DllCall($h_SetupApiDll, "long", "SetupOpenInfFileW", "wstr", $FileName, "wstr", $InfClass, "dword", $InfStyle, "uint*", 0) Return SetError(_WinAPI_GetLastErrorEx(), $HINF[4], $HINF[0]) EndFunc ;==>_SetupOpenInfFile Func _SetupGetLineText($Context = 0, $InfHandle = "", $Section = "", $Key = "", $RBSize = 65536) Local $SGLT, $RBuffer = DllStructCreate("wchar") $SGLT = DllCall($h_SetupApiDll, "int", "SetupGetLineTextW", "ptr", $Context, "long", $InfHandle, "wstr", $Section, "wstr", $Key, "wstr", DllStructGetPtr($RBuffer), "dword", $RBSize, "dword*", 0) If Not $SGLT[0] Then Return SetError(_WinAPI_GetLastErrorEx(), $SGLT[0], "") Return SetError(0, $SGLT[7], $SGLT[5]) EndFunc ;==>_SetupGetLineText Func _SetupCloseInfFile($InfHandle) DllCall($h_SetupApiDll, "none", "SetupCloseInfFile", "long", $InfHandle) EndFunc ;==>_SetupCloseInfFile Func _WinAPI_GetLastErrorEx() Local $GetLastError = DllCall($h_Kernel32DLL, "long", "GetLastError") Return $GetLastError[0] EndFunc ;==>_WinAPI_GetLastErrorExto say more clear this and OK#include <SetupApiEx.au3>; ;; Display.inf ;;[Version] ;;signature="$Windows NT$" ;;ClassGUID={4D36E968-E325-11CE-BFC1-08002BE10318} ;;Class=Display ;; ;;[sectionname] ;;KeyName="AAAAAAA" ;; ;;[sectionname2] ;;BBB="BBBBBBBB" ;; ;;[sectionname3] ;;CCC="CCCCCCCC" local $hInf, $a, $b, $c, $d $InfClassTest = "Display" ;$InfClassTest = 0 $hInf = _SetupOpenInfFile(@DesktopDir & "display.inf", $InfClassTest, $INF_STYLE_WIN4) If Not @Error Then $a = _SetupGetLineText(0, $hInf, "SectionName", "KeyName") EndIf Msgbox(0, 0, $a)but if you use the $InfClassTest = 0 (Null ?) fails to work (Return ERROR_CLASS_MISMATCH), when both Microsoft and all their write clear examples that can be used InfClass = Null without problems http://msdn.microsoft.com/en-us/library/aa376965%28v=VS.85%29.aspxHINF MyInf; //variable to hold the INF handle UINT ErrorLine; //variable to hold errors returned BOOL test; //variable to receive function success MyInf = SetupOpenInfFile ( szInfFileName, //the filename of the inf file to open NULL, //optional class information INF_STYLE_WIN4, //the inf style &ErrorLine //line number of the syntax error );why can not I open for example layout.inf, for example[Version] signature="$Windows NT$" ClassGUID={00000000-0000-0000-0000-000000000000} ;; Or SetupClass=Base [sectionname] AAA="AAAAAAA" [sectionname2] BBB="BBB" [sectionname3] CCC="CCCCCCCC"EDITall OK, Thanks again ProgAndy;; file.inf ;;[Version] ;;signature="$Windows NT$" ;;ClassGUID=ClassGUID={00000000-0000-0000-0000-000000000000} ;; ;;[sectionname] ;;KeyName="AAAAAAA" ;; ;;[sectionname2] ;;BBB="BBBBBBBB" ;; ;;[sectionname3] ;;CCC="CCCCCCCC" local $hInf, $a, $b, $c, $d ;;;$InfClassTest = "Display" $InfClassTest = Null ;; Or AutoIt v3.3.8 $InfClassTest = "Null" $hInf = _SetupOpenInfFile(@DesktopDir & "file.inf", $InfClassTest, $INF_STYLE_WIN4) If Not @Error Then $a = _SetupGetLineText(0, $hInf, "SectionName", "KeyName") EndIf Msgbox(0, 0, $a) Edited March 29, 2012 by DXRW4E Link to comment Share on other sites More sharing options...
ProgAndy Posted March 29, 2012 Share Posted March 29, 2012 The current AutoIt-Beta supports the NULL-Keyword: DLLCall(..., "wstr", Null) In the stable version, you will have to do something like this: $sType = "wstr" If Not IsString($value) And $value = 0 Then $sType = "ptr" DLLCall(..., $sType, $value) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
DXRW4E Posted March 29, 2012 Author Share Posted March 29, 2012 Hi ProgAndy, it seems that everything works OK Thank You Very Much Ciao. Link to comment Share on other sites More sharing options...
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