Jump to content
Sign in to follow this  
MHz

PrivateProfileStringW

Recommended Posts

MHz

These functions handle ANSI and unicode inifiles similar to IniRead, IniWrite and IniDelete.

  • _WinAPI_WritePrivateProfileStringW
  • _WinAPI_GetPrivateProfileStringW

So you can read from unicode inifiles created from other programs or perhaps read and write to your own inifiles.

I was unable to figure out how the API function of WritePrivateProfileStringW can create a unicode file initially so I instead used FileOpen to create a unicode file and write the 1st entry to achieve this. Further use uses WritePrivateProfileStringW is ok to handle the unicode entries. ANSI file creation is done by WritePrivateProfileStringW by default.

Deletion of keys and sections may need use of Null which is in AutoIt 3.3.9.0 and later. I put comments with the code so hopefully understandable to you.

The functions use a similar parameter syntax to IniRead and IniWrite. _WinAPI_WritePrivateProfileStringW has an additional parameter to handle the flag passed to FileOpen for the initial creation of the inifile. _WinAPI_GetPrivateProfileStringW has an additional parameter in case you want the buffer that holds the return value within the UDF to be larger.

The example has some russian text in it so you need to save it in a unicode script for correct testing.

Example

; show message if script is not unicode. Unicode text in this script requires it to be UTF encoded.
; if needed in Scite, use menu bar, File -> Encoding -> UTF (any UTF type that suits you) and save the script.
If Not FileGetEncoding(@ScriptFullPath) Then MsgBox(0, @ScriptName, 'Script is not unicode')

; write to ini file
$return = _WinAPI_WritePrivateProfileStringW("test.ini", 'russian', 'Open', 'Открыть', 0x21)
_Notify('Write', $return)

; read from ini file
$return = _WinAPI_GetPrivateProfileStringW("test.ini", 'russian', 'Open', 'Default')
_Notify('Read', $return)

#cs AutoIt 3.3.9.0 or later using Null keyword
; setting $sValue parameter with Null keyword will delete a key using AutoIt 3.3.9.x or later.
$return = _WinAPI_WritePrivateProfileStringW("test.ini", 'russian', 'Open', Null)

; setting $sKey parameter with Null keyword will delete a section using AutoIt 3.3.9.x or later.
$return = _WinAPI_WritePrivateProfileStringW("test.ini", 'russian', Null, Null)

; setting $sSection parameter with Null keyword will flush using AutoIt 3.3.9.x or later.
$return = _WinAPI_WritePrivateProfileStringW("test.ini", Null, Null, Null)
#ce ; More info of an API that mimics these functions and explains use of Null at http://code.google.com/p/privateprofilestring/

Func _Notify($title, $return = 0, $error = @error, $extended = @extended)
    ; notify results from other function calls
    MsgBox(StringRegExpReplace($error, '-{0,1}([1-9])[0-9]*', '0x30'), $title, _
        '@error = ' & $error & @CRLF & _
        '@extended = ' & $extended & @CRLF & _
        '$return = ' & $return _
    )
EndFunc

User defined functions

; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_WritePrivateProfileStringW
; Description ...: Write to ANSI and unicode encoded ini files
; Syntax.........: _WinAPI_WritePrivateProfileStringW($sFileName, $sSection, $sKey, $sValue[, $iMode = 1])
; Parameters ....: $sFileName - The filename of the .ini file
;                  $sSection - The section name in the .ini file
;                  $sKey - The key name in the in the .ini file
;                  $sValue - The value to write/change
;                  $iMode - Refer to FileOpen mode parameter
; Return values .: Success - Not 0
;                  Failure - 0
;                  @error 1 to 5 - Refer to DllCall
;                  @error 6 - FileOpen failed to open a handle to create the file
; Author ........: MHz
; Modified.......: 
; Remarks .......: Similar to IniWrite but uses unicode API calls. If $sValue is Null then $sKey is deleted. If $sKey is Null,
;                  then $sSection is deleted. If $sSection, $sKey and $sValue are all Null, then $sFileName is
;                  flushed. *** Null is a keyword that only exists in AutoIt3 versions 3.3.9.x and later ***
; Related .......: DllCall, FileOpen, IniWrite
; Link ..........: http://msdn.microsoft.com/en-us/library/windows/desktop/ms725501%28v=vs.85%29.aspx
;                  http://msdn.microsoft.com/en-us/library/windows/desktop/bb773660%28v=vs.85%29.aspx
; Example .......: Yes
; ===============================================================================================================================
Func _WinAPI_WritePrivateProfileStringW($sFileName, $sSection, $sKey, $sValue, $iMode = 1)
    Local $handle_write, $ret
    ; check if path is relative and make it absolute if it is relative
    $ret = DllCall('Shlwapi.dll', 'bool', 'PathIsRelativeW', 'wstr', $sFileName); lpszPath
    If Not @error And $ret[0] Then $sFileName = @WorkingDir & '\' & $sFileName
    ; create a unicode encoded file if needed and write the entry
    If Not FileExists($sFileName) And $iMode > 0x20 Then
        $handle_write = FileOpen($sFileName, $iMode)
        If $handle_write = -1 Then Return SetError(6, 0, 0)
        FileWrite($handle_write, '[' & $sSection & ']' & @CRLF & $sKey & '=' & $sValue & @CRLF)
        FileClose($handle_write)
        Return 1
    EndIf
    ; write to the ini file. $ret[0] will contain nonzero if successful
    $ret = DllCall('Kernel32.dll', 'bool', 'WritePrivateProfileStringW', _
        'wstr', $sSection, _
        'wstr', $sKey, _
        'wstr', $sValue, _
        'wstr', $sFileName _
    ); lpAppName, lpKeyName, lpString, lpFileName
    If @error Then Return SetError(@error, @extended, 0)
    Return SetExtended(0, $ret[0])
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_GetPrivateProfileStringW
; Description ...: Read from ANSI and unicode encoded ini files
; Syntax.........: _WinAPI_GetPrivateProfileStringW($sFileName, $sSection, $sKey[, $sDefault = ''[, $iBufferSize = 65536]])
; Parameters ....: $sFileName - The filename of the .ini file
;                  $sSection - The section name in the .ini file
;                  $sKey - The key name in the in the .ini file
;                  $sDefault - The default value to return if the requested key is not found
;                  $iBufferSize - Adjustable buffer size which contains the chars from the API call
; Return values .: Success - Returns the requested key value
;                  Failure - Returns the default string if requested key not found
;                  @error 1 to 5 - Refer to DllCall
; Author ........: MHz
; Modified.......: 
; Remarks .......: Similar to IniRead but uses unicode API calls
; Related .......: IniRead
; Link ..........: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724353%28v=vs.85%29.aspx
;                  http://msdn.microsoft.com/en-us/library/windows/desktop/bb773660%28v=vs.85%29.aspx
; Example .......: Yes
; ===============================================================================================================================
Func _WinAPI_GetPrivateProfileStringW($sFileName, $sSection, $sKey, $sDefault = '', $iBufferSize = 65536)
    Local $buffer, $ret
    ; check if path is relative and make it absolute if it is relative
    $ret = DllCall('Shlwapi.dll', 'bool', 'PathIsRelativeW', 'wstr', $sFileName); lpszPath
    If Not @error And $ret[0] Then $sFileName = @WorkingDir & '\' & $sFileName
    ; create a buffer to hold the returned string
    $buffer = DllStructCreate('wchar[' & $iBufferSize & ']')
    ; read from the ini file. $ret[0] will contain number of chars returned
    $ret = DllCall('Kernel32.dll', 'dword', 'GetPrivateProfileStringW', _
        'wstr', $sSection, _
        'wstr', $sKey, _
        'wstr', $sDefault, _
        'ptr', DllStructGetPtr($buffer), _
        'dword', DllStructGetSize($buffer), _
        'wstr', $sFileName _
    ); lpAppName, lpKeyName, lpDefault, lpReturnedString, nSize, lpFileName
    If @error Then SetError(@error, @extended, $sDefault)
    Return SetExtended($ret[0], DllStructGetData($buffer, 1))
EndFunc

Thanks to AZJIO for some russian text for use in the example. :)

Edit:

Updated with summary correction by guiness in post #2

Edited by MHz

Share this post


Link to post
Share on other sites
guinness

If you create a Unicode file then the Ini functions should work with Unicode.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
MHz

Thanks guinness. Indeed they do with some testing. Arrh :censored:  :D

Share this post


Link to post
Share on other sites
guinness

Thanks guinness. Indeed they do with some testing. Arrh :censored:  :D

No problem.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      Hi dear
      With this script you can print Unicode text in the CMD screen
      the script is  easy to use
      just you  write the text that contains Unicode in the first input
      and the script automatically reflect the code in the second input
       you can copy the text to the clipboard
      or you can try printing the text in the CMD window
      I apologize to everyone for colors and shape if not appropriate
      I'm a blind man and I do not see
      Thank you for your understanding
      Greetings to all of youCmdUtM.au3
    • Jibsbrown
      By Jibsbrown
      Need some help understanding why the ConsoleWrite works inside 2nd For loop but not out side. Between Audit Wiki, Help file , Forum searching (lots of code reading), and YouTube ( shout out to TutsTeach), I have not been able to find the reason why. 
      $sIniPath = "installLog.ini" ; - Get section name $iniSctionNames = IniReadSectionNames($sIniPath) ; - Get Keys and Vaules For $a = 1 to UBound($iniSctionNames) - 1 $keys = IniReadSection($sIniPath , $iniSctionNames[$a]) For $b = 1 to UBound($keys) - 1 $oldSysInfo = IniRead($sIniPath , $iniSctionNames[1], $keys[$b][0], "") $PntIPInfo = IniRead($sIniPath , $iniSctionNames[2], $keys[$b][0], "") $NewPCInfor = IniRead($sIniPath , $iniSctionNames[3], $keys[$b][0], "") ;ConsoleWrite($oldSysInfo & @LF) Next ;ConsoleWrite($oldSysInfo & @LF) Next ConsoleWrite($oldSysInfo) My intention is to use the variables later for Listboxes. Any explanation, forum post links or whatever would help. Sorry also very very new to Autoit.
      Also here's the ini file.
      [OldSysInfo] 4=192.168.0.4|DESKTOP-RDIU2SN|R90M05Q8 5=192.168.0.5|SD0123456789101|R9WGP9P 6=192.168.0.6|SD0123456789102|R9WGP9PT 3=192.168.0.3|DESKTOP-3RS4LKL|R9WGP9P 23=192.168.0.23|SD0123456789102|MXL1234P5I [PrinterIp] 50=192.168.0.50 48=192.168.0.48 47=192.168.0.47 [NewSysInfo] newPC = SD0123456789adfs|192.168.0.185|2UA1234FTR Thank you for your time.
    • damon
      By damon
      @JLogan3o13 I apologize, I did not think of it that way.  I have attached all the code and the Ini File information.  Please let me know if I need to add anything else to help understand what is happening.  thank you.
       
       
       
      Guys, I apologize in advance as I did not search for my answer before posting.  I just could not figure out a way to search that made since so I decided to go ahead and post my question.
       
      Getting to it.
      Background: this is being used to validate file names before moving to a new location.  though i have not included all the code, below is what i am having a problem with.
       I have an ini file that i am reading values from. Func ConfigDefineVars() -- I read the value of $ValidationRDA and everything is good then I set 
      $CaseRDALocationCheck = '$SplitFile[$ValidationRDALocation]' <> $ValidationRDA
      the code that will be used in the select case in Func FileSplitCount().  The problem i have is that even though the numbers = each other they are not recognizing as =.  
      This is what i am getting in my log file i create.
      2017-12-04 14:09:53 : RDA was 2403 should have been 2403:
      If I move $SplitFile[$ValidationRDALocation] <> $ValidationRDA to the Case line under the function it works correctly.
       
      I think this has to do with my use of ' ' around the '$SplitFile[$ValidationRDALocation]' but  i don't know what option i have in Func ConfigDefineVars I am not ready to define $SplitFile.  I have tried adding it to my Global Vars at the top of my script but that did not seem to help.
      There will be more fail this is just the first one in the select case.
       
      Any help or ideas would be greatly appreciated.
       
      thanks,
      Damon
      Example of a filename used.
      DWRSSD-37087-95-026.%-064.00-Tatum Family %-%-1230 Academy Rd-%-PERM-TRUE-2403.pdf
      This file will fail on the 95, it should be 095.  The problem i am getting is with the 2403 it fails even though the ini file value ValidationRDA = 2403 
       
       
      Ini File:
      [SSD_FolderPaths]
      pendingFolder=C:\Users\bg01152\Desktop\SSD Test\pending
      reviewFolder=C:\Users\bg01152\Desktop\SSD Test\review
      completedFolder=C:\Users\bg01152\Desktop\SSD Test\Completed
      FileNetProperties=DocumentTitle,ZipCode,County,MapAndGroupID,ParcelID,PropertyOwner,Subdivision,StreetAddress,LotNumber,DocumentType,Approved,RDANumber
      ValidationDocumentTitle=DWRSSD
      ValidationDocumentTitleLocation=1
      ValidationCountyCodeLocation=3
      ValidationRDA=2403
      ValidationRDALocation=12
      Validation3=TRUE
      Validation3Location=11
      Validation4=PERM
      Validation4Location=10
       
       
      #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ;------------Global Vars --------------------- Global $SplitFile, $aFileList, $FileLog, $dFolder, $sFolder, $cFolder, $ConfigFile, $t Global $ValidationDocumentTitle, $ValidationDocumentTitleLocation, $ValidationCountyCodeLocation, $ValidationRDA Global $ValidationRDALocation, $Validation3, $Validation3Location, $Validation4, $Validation4Location, $FileNetPropertiesSplit Global $CaseCountyCheck, $CaseRDALocationCheck, $CaseValidation3LocationCheck, $CaseValidation4LocationCheck, $SplitFile ;;--------------------------------Check and Read Config files-------------------------------- $SysConfigFile = @ScriptDir & "\SysConfig.ini" ;----------------PreCheck for Config File-------------- If FileExists ($SysConfigFile) <> 1 Then Exit EndIf ;----------------End PreCheck-------------------------- $FileNetEXE = @ScriptDir & "\" & IniRead ($SysConfigFile, "FileNetUploader","FileName","") $delimiter = IniRead ($SysConfigFile, "FileInformation", "Delimiter","") $Filter = IniRead ($SysConfigFile, "FileInformation", "Filter", "") $ConfigFile = @ScriptDir & "\Config.ini" ;----------------PreCheck for Config File-------------- If FileExists ($ConfigFile) <> 1 Then Exit EndIf ;----------------End PreCheck-------------------------- ;;-------------------------------------------------------------------------------------------- $Sections = IniReadSectionNames ($ConfigFile) ;MsgBox (0,"test", $Sections[0] & @CRLF & $Sections[1] & @CRLF & $Sections[2] & @CRLF & $Sections[3] & @CRLF & $Sections[4]);TESTING ONLY - DELETE WHEN DONE $p = 0 Do $t = 0 ;used for precheck $p = $p + 1 ConfigDefineVars($Sections[$p]) ;MsgBox(0,"ConfigDefineVars", $sFolder & @CRLF & $dFolder & @CRLF & $cFolder);TESTING ONLY - DELETE WHEN DONE PreCheck($dFolder, $sFolder, $cFolder) ;Runs a Pre-check to make sure folder structure exists before running the program If $t = 0 Then ;MsgBox(0,"PreCheck Run", "Running next functions");TESTING ONLY - DELETE WHEN DONE ListArray($sFolder, $Filter) ;Puts File Names in String Array ;_ArrayDisplay ($aFileList, $Sections[$p]) If $t = 0 Then FileSplitCount($dFolder, $aFileList) ;Takes filename String Array and splits by $delimiter ;MsgBox(0,"PreCheck Run2", "Running split function");TESTING ONLY - DELETE WHEN DONE Else ;MsgBox(0,"PreCheck Run2", "Skipping split function");TESTING ONLY - DELETE WHEN DONE EndIf Else ;MsgBox(0,"PreCheck Run", "Skipping next functions");TESTING ONLY - DELETE WHEN DONE EndIf Until $p = $Sections[0] ExitScript() ;Exit script Function Func ConfigDefineVars($SectionsNum);Defines Variables from config file Sections $sFolder = IniRead ($ConfigFile, $SectionsNum, "pendingFolder","") ;Pending Folder, Folder that is awaiting the process $dFolder = IniRead ($ConfigFile, $SectionsNum, "reviewFolder","") ;Review Folder, Files that did not pass validation check and division needs to review $cFolder = IniRead ($ConfigFile, $SectionsNum, "completedFolder","") ;Completed Folder, Once process is completed this would be location files get moved to $FileNetProperties = IniRead ($ConfigFile, $SectionsNum, "FileNetProperties","") $FileNetPropertiesSplit = StringSplit ($FileNetProperties,",") $ValidationDocumentTitle = IniRead ($ConfigFile, $SectionsNum, "ValidationDocumentTitle","") $ValidationDocumentTitleLocation = IniRead ($ConfigFile, $SectionsNum, "ValidationDocumentTitleLocation","") $ValidationCountyCodeLocation = IniRead ($ConfigFile, $SectionsNum, "ValidationCountyCodeLocation","") $ValidationRDA = IniRead ($ConfigFile, $SectionsNum, "ValidationRDA","") $ValidationRDALocation = IniRead ($ConfigFile, $SectionsNum, "ValidationRDALocation","") $Validation3 = IniRead ($ConfigFile, $SectionsNum, "Validation3","") $Validation3Location = IniRead ($ConfigFile, $SectionsNum, "Validation3Location","") $Validation4 = IniRead ($ConfigFile, $SectionsNum, "Validation4","") $Validation4Location = IniRead ($ConfigFile, $SectionsNum, "Validation4Location","") If $ValidationCountyCodeLocation = 999 Then $CaseCountyCheck = 1 <> 1 Else ;MsgBox (0,"test of county code", "location = " &$ValidationCountyCodeLocation) $CaseCountyCheck = StringLen('$SplitFile[$ValidationCountyCodeLocation]') <> 3 ; Checks for 3 digit County Code EndIf If $ValidationRDALocation = 999 Then $CaseRDALocationCheck = 1 <> 1 Else $CaseRDALocationCheck = '$SplitFile[$ValidationRDALocation]' <> $ValidationRDA ; Checks for 4 Digit RDA EndIf If $Validation3Location = 999 Then $CaseValidation3LocationCheck = 1 <> 1 Else $CaseValidation3LocationCheck = '$SplitFile[$Validation3Location]' <> $Validation3 ; Checks that Approved = True EndIf If $Validation4Location = 999 Then $CaseValidation4LocationCheck = 1 <> 1 Else $CaseValidation3LocationCheck = '$SplitFile[$Validation4Location]' <> $Validation4 ; Checks that Document Type = PERM EndIf EndFunc Func ValidationCheck ($check1) $blank = StringLen ($check1) If $check1 Then EndIf EndFunc Func PreCheck($dFolder, $sFolder, $cFolder) ;----------------PreCheck for Destination Folder-------------- If FileExists ($dFolder) <> 1 Then $t = 1 Return Else $FileLog = FileOpen($dFolder & "\FileLog.log", 1) EndIf ;----------------End PreCheck-------------------------- ;----------------PreCheck for Source Folder-------------- If FileExists ($sFolder) <> 1 Then _FileWriteLog($FileLog, "Path to Pending Folder -- " & $sFolder & " -- does not exist") $t = 1 Return EndIf ;----------------End PreCheck-------------------------- ;----------------PreCheck for Completed Folder--------- If FileExists ($cFolder) <> 1 Then _FileWriteLog($FileLog, "Path to Completed Folder -- " & $cFolder & " -- does not exist") $t = 1 Return EndIf ;----------------End PreCheck-------------------------- EndFunc Func ListArray($sFolder, $Filter) $aFileList = _FileListToArray($sFolder, $Filter, 1) ;Create an array of files from the source folder filtering by filetype ;in the config.ini files for the specified section If @error = 1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") _FileWriteLog($FileLog, "Path to File(s) is Invalid") $t = 1 Return EndIf If @error = 4 Then ;MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") _FileWriteLog($FileLog, "No File(s) were found, exiting.") $t = 1 Return EndIf EndFunc ;==>ListArray  
       
       
       
    • CodeName_SexBobomb
      By CodeName_SexBobomb
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Test () Func Test() $Form1 = GUICreate("Form1", 414, 212, 1449, 1197) $Group1 = GUICtrlCreateGroup("Group1", 0, 0, 201, 161) Global $Combo1 = GUICtrlCreateCombo("", 0, 16, 201, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $Data = GUICtrlSetData($Combo1, "Combo 1|Combo 2|Combo 3") Global $Input1 = GUICtrlCreateInput("", 0, 48, 201, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Group2", 210, 0, 200, 160) Dim $LABELS[20] Local $DIRECTORY = @ScriptDir & "\Test.ini" Local $SECTION = IniReadSection($DIRECTORY, "Section 1") Local $RESULTS = "" For $r = 1 To $SECTION[0][0] $RESULTS &= $SECTION[$r][1] & @CRLF Next $RESULTS = StringTrimRight($RESULTS, 1) For $N = 0 To 10 $LABELS[$N] = GUICtrlCreateLabel($RESULTS, 220, 15, 200, 100) Next GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("Save", 80, 170, 121, 33) $Button2 = GUICtrlCreateButton("Exit", 210, 170, 121, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _WriteData () Case $Button2 Exit EndSwitch WEnd EndFunc _WriteData () Func _WriteData () Local $TestData = GUICtrlRead($Combo1) Local $TestInput = GUICtrlRead($Input1) Local $Directory = @ScriptDir & "\Test.ini" IniWrite ($Directory, "Section 1", "", "" & $TestData & " " & $TestInput & @CRLF & "") EndFunc Hello Friends,
        Perhaps one of you can assist me. Currently I have a semi-working script. The goal of this script is to write the values of the combo box into an INI file and read said INI files. So far it does this.. but the issue is, It writes over line 1. The goal is to write on a new line each time to create a continuous log of submitted data.
    • GordonFreeman
      By GordonFreeman
      Hi, i'm trying to save data in an ini key that contains @LF and @CRLF (to use in an edit control). But @LF and @CRLF cause error in ini files (because it breaks the line). Then im trying to find a workaround. Here's the script thanks in advance:
       
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) $hEDIT = GUICtrlCreateEdit("",11,11,600,400) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### IniWrite("JustATest.ini","TestSec","TestKey","TestValue " & @CRLF & "Testing" & @LF & "test") $sData = IniRead("JustATest.ini","TestSec","TestKey","") GUICtrlSetData($hEDIT,$sData) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd  
×