Sign in to follow this  
Followers 0
Jochem

regenumkey to array

10 posts in this topic

#1 ·  Posted (edited)

I tried to make some script to collect software versiosn installed on the networkcomputers.

I used this script (found on this forum, and changed it a little bit):

Func _SoftwareInfo32($cI_CompName)
$cI_CompName = "\\" & $cI_CompName & "\"
    Local Const $regkey = $cI_CompName & 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'

    Local $key, $regel = 0, $avArray[1]

    While 1
        $regel = $regel + 1
        $key = RegEnumKey($regkey, $regel)
        If @error Then ExitLoop
        $line1cel1 = RegRead($regkey & '\' & $key, 'Displayname')
    $line1cel2 = RegRead($regkey & '\' & $key, 'Displayversion')
    If @error Then ContinueLoop

        $avArray[0] += 1
        ReDim $avArray[$avArray[0] + 1]
        $avArray[$avArray[0]] = $line1cel1
    WEnd

Return $avArray
EndFunc

this is working good, but the problem is that i want a second collumn to ad the version number. I tried manny things but nothing worked till now. Especially this part is what i dont`understand

$avArray[0] += 1
        ReDim $avArray[$avArray[0] + 1]
        $avArray[$avArray[0]] = $line1cel1

I thought more about this:

ReDim $avArray[$regel]
_arrayadd ($avArray [$regel][0], $line1cel1)
_arrayadd ($avArray [$regel][1], $line1cel2)

can somebody give me a tip.

Edited by Jochem

Share this post


Link to post
Share on other sites



$avArray[0] += 1
ReDim $avArray[$avArray[0] + 1]
$avArray[$avArray[0]] = $line1cel1

Ok, this is fairly common code... Still not nice though.

As a general practice thing (despite being frowned upon by many), the number of elements in an array is held in it's first element (zero). This is mostly because it's easier to work with than UBound, and also some internal functions such as StringSplit return it like that.

So the first line is incrementing OUR counter of the array elements.

The second is changing the AUTOIT size of the array using ReDim (see helpfile). The +1 is for the element with the counter itself.

$avArray[$avArray[0]] now points to the last item in the array (the item at the value of the counter). We set it to the value :x

You want 2 columns? Well you need a 2D array. This is my template code for this sort of stuff

; avArray:
;   [0][0] = counter
;   [*][0] = first column
;   [*][1] = second column
Local $avArray[1][2] ; An 'empty' 2d array
Local $avArray[0][0] = 0 ; The counter

; Add an item:
$avArray[0][0] += 1
ReDim $avArray[$avArray[0][0] + 1][2] ; We are only adding a row!!
$avArray[$avArray[0][0]][0] = '1st'
$avArray[$avArray[0][0]][1] = '2nd'

It's very similar to the first code. A bit more complex though as the counter is now in [0][0]. It also helps when using multi dimensional arrays to say at the top what is stored where (see my comment at the top). Just makes it easy for reference later.

Is that answering the question?

Share this post


Link to post
Share on other sites

thanks, great explanation!

I will continue working on the script tomorrow.

Share this post


Link to post
Share on other sites

Ciao.


apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

DXRW4E,

Try to refrain from opening dead threads, especially when the question has already been provided.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

not open or anything, only indicated a solution that in my opinion and better

if you do not like hmmmmmmmm

instead of saying thanks (for the release of _RegEnumKeyEx) you say hmmmmm (however it seems that your problem is not mine)

I do not know what to say, from the way you wrote it seems that you gave to nuisance one of my publications hmmmmmmm

okay anyway

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
Share on other sites

I think you've misunderstood my point entirely as well as the tone of my last post. Firstly you're providing a solution to a user who hasn't even logged into their account in 5 months, so what's the likelihood they will now or will even need this solution. Secondly, most of us have seen your example in the Examples section, so there is no need to post duplicate copies all over the forum. This doesn't mean I'm not appreciative of your work.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I understand, I apologize (I'm really sorry)

the point is that I before making the RegEnumKeyEx, or read in forums and looking for RegEnumKey, have left 20-30 topics ect ect, after or fate to me that RegEnumKeyEx, after I had already in Firefox browser these posts and precisely or posted here and in another post

always with idea to be of help, because I'm confused actually looking RegEnumKey + array ect ect, there are many topics with all the hanging question and all without a real solution

sorry again

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
Share on other sites

guiness' point was that you posted to a 2 year old thread about something the original poster will never see or care about since he hasn't been here in 5 months. Necro posting dead threads is pointless, and a waste of time.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I know I know, the point was that, before I do RegEnumKeyEx (google sent me to this old topic) I ended up in this topic and many other old topic (looking for a solution), and it more confusing to me ect ect, or put the link up there, not to create even more confusion but with the intention to do better, if someone else like me end up in some old posts also find new posts ect ect

sorry again for my english

Ciao

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

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  
Followers 0