Jump to content

Recommended Posts

Posted

Hi.

Anyone got a tip on how to list the keys in HKEY_CLASSES_ROOT that hav an "." in front of them?

For example...

[HKEY_CLASSES_ROOT\.zip]

@="WinZip"

This is the "(default)" key under [HKEY_CLASSES_ROOT\.zip] that show what app that opens this type of file.

I'm building a search for users that wants to know what kind of filetypes a particular app is using :)

------------------------------------------

:P : Have you tried the new vista?

:nuke: : No... I don't play games...

Posted

You could type "assoc" in the dos box, it gives the same result.

Thanks! :nuke: That should do the trick actually... :P

  • Moderators
Posted

If you were wanting a long UDF, this could start you off:

$aArrayReturned = _RegEnum('HKEY_CLASSES_ROOT\')
Func _RegEnum($sKey)
    Local $aArray[1][1], $sEnum, $sHold, $iCC
    While 1
        $iCC += 1
        $sEnum = RegEnumKey($sKey, $iCC)
        If @error Then ExitLoop
        If StringLeft($sEnum, 1) = '.' Then
            $sHold &= $sEnum & Chr(01)
        EndIf
    WEnd
    MsgBox(0, '', $sHold);could use StringSplit(StringTrimRight($sHold, 1), Chr(01)) to make it an array
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

If you were wanting a long UDF, this could start you off:

$aArrayReturned = _RegEnum('HKEY_CLASSES_ROOT\')
Func _RegEnum($sKey)
    Local $aArray[1][1], $sEnum, $sHold, $iCC
    While 1
        $iCC += 1
        $sEnum = RegEnumKey($sKey, $iCC)
        If @error Then ExitLoop
        If StringLeft($sEnum, 1) = '.' Then
            $sHold &= $sEnum & Chr(01)
        EndIf
    WEnd
    MsgBox(0, '', $sHold);could use StringSplit(StringTrimRight($sHold, 1), Chr(01)) to make it an array
EndFunc

Thanks :P

  • Moderators
Posted

Thanks :P

LOL, this seems to be much faster using xandl's suggestion!!

#include <array.au3>
$aReturned = _AssocExt()
_ArrayDisplay($aReturned, 'Array')
Func _AssocExt()
    RunWait(@ComSpec & ' /c assoc > "' & @TempDir & '\AssocOutput.txt"', '', @SW_HIDE)
    If Not FileExists(@TempDir & '\AssocOutput.txt') Then Return SetError(1, 0, 0)
    Local $aSplit = StringSplit(StringStripCR(FileRead(@TempDir & '\AssocOutput.txt')), @LF)
    FileDelete(@TempDir & '\AssocOutput.txt')
    Return $aSplit
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

LOL, this seems to be much faster using xandl's suggestion!!

#include <array.au3>
$aReturned = _AssocExt()
_ArrayDisplay($aReturned, 'Array')
Func _AssocExt()
    RunWait(@ComSpec & ' /c assoc > "' & @TempDir & '\AssocOutput.txt"', '', @SW_HIDE)
    If Not FileExists(@TempDir & '\AssocOutput.txt') Then Return SetError(1, 0, 0)
    Local $aSplit = StringSplit(StringStripCR(FileRead(@TempDir & '\AssocOutput.txt')), @LF)
    FileDelete(@TempDir & '\AssocOutput.txt')
    Return $aSplit
EndFunc

I know... :P Just what I needed actually. Hehe...

  • Moderators
Posted

I know... :P Just what I needed actually. Hehe...

How about we take it one step more... read them, then write them to your own .ini then use IniReadSection() to get all the Keys and their Values stored nice and neat right there for you:
$hOutFile = @ScriptDir & '\AssocIni.ini'
$sString = _AssocExt($hOutFile)
$aSection = IniReadSection($hOutFile, 'AssocExtValues')
If IsArray($aSection) Then
    For $iCC = 1 To $aSection[0][0]
        MsgBox(64, 'Info', 'Key = ' & $aSection[$iCC][0] & @CR & _
            'Value = ' & $aSection[$iCC][1])
    Next
EndIf

Func _AssocExt($hOutIni)
    RunWait(@ComSpec & ' /c assoc > "' & @TempDir & '\AssocOutput.txt"', '', @SW_HIDE)
    If Not FileExists(@TempDir & '\AssocOutput.txt') Then Return SetError(1, 0, 0)
    Local $sFRead = FileRead(@TempDir & '\AssocOutput.txt')
    FileDelete(@TempDir & '\AssocOutput.txt')
    FileClose(FileOpen($hOutIni, 2))
    FileWriteLine($hOutIni, '[AssocExtValues]')
    Return FileWrite($hOutIni, $sFRead)
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...