Sign in to follow this  
Followers 0
MasterJ

_GUIImageList_AddIcon:-1?

2 posts in this topic

OK, Inside of script I've commented where I get error... Maybe someone will tell me, what is wrong...

CODE
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_Version=beta

#AutoIt3Wrapper_UseX64=y

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

;Includes

#include <GUIConstantsEx.au3>

#Include <GuiListView.au3>

#include <ModernMenu.au3>

#include <GuiImageList.au3>

;Global variables

$ver = "0.3 ALPHA"

;Main Window

$mainwindow = GUICreate("WinVISTA Control Panel Expander v" & $ver, 800, 600)

GUISetState(@SW_SHOW, $mainwindow)

$filemenu = GUICtrlCreateMenu("&File")

$exit = _GUICtrlCreateODMenuItem("Exit", $filemenu, "shell32.dll", -110)

GUICtrlSetState(-1, $GUI_DEFBUTTON)

$helpmenu = GUICtrlCreateMenu("&Help")

$about = _GUICtrlCreateODMenuItem("About", $helpmenu, "shell32.dll", -24)

$controllistgroup = GUICtrlCreateGroup("Installed control panel items", 10, 5, 780, 200)

$controllist = GUICtrlCreateListView("", 20, 20, 760, 175, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))

_GUICtrlListView_SetExtendedListViewStyle($controllist, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))

_GUICtrlListView_AddColumn($controllist, "Item Name", 385)

_GUICtrlListView_AddColumn($controllist, "Generated GUID", 350)

$imageslist = _GUIImageList_Create()

_GUICtrlListView_SetImageList($controllist, $imageslist, 1)

_GetInstalledItems()

;Actions

Do

$msg = GUIGetMsg()

_DrawHelp()

Until $msg = $GUI_EVENT_CLOSE Or $msg = $exit

GUIDelete($mainwindow)

;Funkcijos

Func _DrawHelp()

If $msg = $about Then

GUISetState(@SW_DISABLE, $mainwindow)

MsgBox(32, "About", "WinVISTA Control Panel Expander v" & $ver & @CRLF & @CRLF & "This software will help you customize your Microsoft© Windows Vista control panel." & @CRLF & @CRLF & "KEEP IN MIND: This software is in ALPHA stage, which means, that isn't ready for everyday use and it comes with no guarantees to work with your software and/or hardware configuration.")

GUISetState(@SW_ENABLE, $mainwindow)

EndIf

EndFunc

Func _GenGUID()

Local $GUIDSTRUCT

Local $aDllRet

Local $sGUID

$GUIDSTRUCT = DllStructCreate("int;int;int;byte[8]")

If Not @error Then

$aDllRet = DllCall("ole32.dll", "long", "CoCreateGuid", "ptr", DllStructGetPtr($GUIDSTRUCT))

If Not @error And $aDllRet[0] = 0 Then

$aDllRet = DllCall("ole32.dll", "long", "StringFromGUID2", _

"ptr", DllStructGetPtr($GUIDSTRUCT), _

"wstr", "", _

"int", 40)

If Not @error And $aDllRet[0] > 0 Then $sGUID = $aDllRet[2]

EndIf

$GUIDSTRUCT=""

EndIf

Return StringLower($sGUID)

EndFunc

Func _GetInstalledItems()

Local $i = 0

Local $f = 0

Dim $controliconsplit

Do

$i = $i+1

$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\ControlPanel\NameSpace\", $i)

If @error <> 0 then $i = -1

$registryvalue = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\ControlPanel\NameSpace\" & $var, "")

If $registryvalue <> "" Then

$controlicon = RegRead("HKEY_CLASSES_ROOT\CLSID\" & $var & "\DefaultIcon", "")

$controliconsplit = StringSplit($controlicon, ",")

If $controliconsplit[0] > 1 Then

If $controliconsplit[2] <> -1 Then

_GUIImageList_AddIcon($imageslist, $controliconsplit[1], $controliconsplit[2])

Else

_NoIcon()

EndIf

Else

_NoIcon()

EndIf

Else

;THERE I GET ERROR: "_GUIImageList_AddIcon:-1". What a hell??

$controlicon = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\ControlPanel\NameSpace\" & $var, "Module")

_GUIImageList_AddIcon($imageslist, $controlicon, 0)

EndIf

If $registryvalue = "" Then

$registryvalue = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\ControlPanel\NameSpace\" & $var, "Name")

$var = "<NO GUID USED>"

EndIf

If $var <> "<NO GUID USED>" Then $var = StringLower($var)

If $i <> -1 Then

_GUICtrlListView_AddItem($controllist, $registryvalue, $i - 1)

_GUICtrlListView_AddSubItem($controllist, $i-1, $var, 1)

EndIf

Until $i = -1

EndFunc

Func _NoIcon()

_GUIImageList_AddIcon($imageslist, @SystemDir & "\shell32.dll", -3)

EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Ok, here I attach ModerMenu file to include.

ModernMenu.au3

Edited by MasterJ

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