Page 1 of 1

Update : En\Dis W7 Always show all icons

Posted: Sat Oct 29, 2011 5:51 pm
by RASHAD
The tiltle say it all

Code: Select all

sRemMachName.s = ""
lTopLevelKey.l = #HKEY_CURRENT_USER
sKeyName.s = "Software\Microsoft\Windows\CurrentVersion\Explorer"
sValueName.s = "EnableAutoTray"

Procedure.l QueryValueEx(lhkey.l, szValueName.s) 
    Shared vValue.s 
    cch = 255 
    sValue.s = Space(255)
    lrc = RegQueryValueEx_(lhkey, szValueName, 0, @lType, 0, @cch) 
        
    Select lType 
        Case #REG_DWORD 
            lrc = RegQueryValueEx_(lhkey, szValueName, 0, @lType, @lValue, @cch) 
            If lrc = 0
              vValue = Str(lValue) 
            EndIf 
        Default 
            lrc = -1 
    EndSelect 
    ProcedureReturn lrc 
EndProcedure

Procedure SetValue(lTopLevelKey.l, sKeyName.s, sValueName.s, vValue.s, lType.l, sRemMachName.s) 
 
  If sRemMachName.s = "" 
    GetHandle = RegOpenKeyEx_(lTopLevelKey, sKeyName, 0, #KEY_ALL_ACCESS, @hKey) 
  Else 
    lReturnCode = RegConnectRegistry_(ComputerName, lTopLevelKey, @lhRemoteRegistry) 
    GetHandle = RegOpenKeyEx_(lhRemoteRegistry, sKeyName, 0, #KEY_ALL_ACCESS, @hKey) 
  EndIf 

   If GetHandle = #ERROR_SUCCESS     
    Select lType 
      Case #REG_SZ 
        GetHandle = RegSetValueEx_(hkey, sValueName, 0, #REG_SZ, @vValue, Len(vValue) + 1) 
      Case #REG_DWORD 
        lValue = Val(vValue) 
        GetHandle = RegSetValueEx_(hKey, sValueName, 0, #REG_DWORD, @lValue, 4) 
    EndSelect 
      
    RegCloseKey_(hkey) 
    SetValue = 1 
   Else 
    RegCloseKey_(hKey)
    SetValue = 0 
  EndIf
  ProcedureReturn SetValue
EndProcedure 
 

lRetVal = RegConnectRegistry_(sRemMachName, lTopLevelKey.l, @lHKeyhandle) 
lRetVal = RegOpenKeyEx_(lHKeyhandle, sKeyName, 0, #KEY_ALL_ACCESS, @lhkey) 
lRetVal = QueryValueEx(lhkey, sValueName) 
RegCloseKey_(lhkey) 

If Val(vValue) = 0
    SetValue(lTopLevelKey, sKeyName, sValueName.s, "01", #REG_DWORD, "")
Else
    SetValue(lTopLevelKey, sKeyName, sValueName.s, "00", #REG_DWORD, "")
EndIf

Procedure PPid(Process$)
    Protected PE.PROCESSENTRY32, hTH.i
    
    hLib = OpenLibrary(#PB_Any,"kernel32.dll") 
    
    If hLib 
        pCreateToolhelp32Snapshot = GetFunction(hLib,"CreateToolhelp32Snapshot") 
        pProcess32First = GetFunction(hLib,"Process32First") 
        pProcess32Next = GetFunction(hLib,"Process32Next") 
    Else 
        ProcedureReturn 0 
    EndIf 
    
    PE\dwSize = SizeOf(PROCESSENTRY32) 
    hTH = CreateToolhelp32Snapshot_(#TH32CS_SNAPPROCESS, 0) 
    Process32First_(hTH, @PE) 
    PName$ = Space(#MAX_PATH) 
    CopyMemory(@PE\szExeFile,@PName$,#MAX_PATH) 
    
    If  UCase(PName$) = UCase(Process$) 
        ProcedureReturn PE\th32ProcessID 
    EndIf 
    
    While Process32Next_(hTH, @PE) > 0 
        PName$ = Space(#MAX_PATH) 
        CopyMemory(@PE\szExeFile,@PName$,#MAX_PATH) 
        
        If  UCase(PName$) = UCase(Process$) 
            ProcedureReturn PE\th32ProcessID 
        EndIf 
    
    Wend 
    
    CloseLibrary(hLib) 
    
    ProcedureReturn 0 
EndProcedure

ProcessID = PPid("explorer.exe")
Process = OpenProcess_(#PROCESS_ALL_ACCESS, 0, ProcessID)
ReturnValue = TerminateProcess_(Process, 0)

Re: En\Dis W7 Always show all icons without Log Off\On \ Reb

Posted: Sat Oct 29, 2011 7:59 pm
by Tomi
many thanks rashad, really one :D

Re: En\Dis W7 Always show all icons without Log Off\On \ Reb

Posted: Thu Nov 03, 2011 6:29 am
by RASHAD
Thanks Tomi

No logoff Logon
No Reboot
Without killing Explorer
Much better

Code: Select all

Global ok

sRemMachName.s = ""
lTopLevelKey.l = #HKEY_CURRENT_USER
sKeyName.s = "Software\Microsoft\Windows\CurrentVersion\Explorer"
sValueName.s = "EnableAutoTray"

Procedure.l QueryValueEx(lhkey.l, szValueName.s) 
    Shared vValue.s 
    cch = 255 
    sValue.s = Space(255)
    lrc = RegQueryValueEx_(lhkey, szValueName, 0, @lType, 0, @cch) 
        
    Select lType 
        Case #REG_DWORD 
            lrc = RegQueryValueEx_(lhkey, szValueName, 0, @lType, @lValue, @cch) 
            If lrc = 0
              vValue = Str(lValue) 
            EndIf 
        Default 
            lrc = -1 
    EndSelect 
    ProcedureReturn lrc 
EndProcedure

Procedure SetValue(lTopLevelKey.l, sKeyName.s, sValueName.s, vValue.s, lType.l, sRemMachName.s) 
 
  If sRemMachName.s = "" 
    GetHandle = RegOpenKeyEx_(lTopLevelKey, sKeyName, 0, #KEY_ALL_ACCESS, @hKey) 
  Else 
    lReturnCode = RegConnectRegistry_(ComputerName, lTopLevelKey, @lhRemoteRegistry) 
    GetHandle = RegOpenKeyEx_(lhRemoteRegistry, sKeyName, 0, #KEY_ALL_ACCESS, @hKey) 
  EndIf 

   If GetHandle = #ERROR_SUCCESS     
    Select lType 
      Case #REG_SZ 
        GetHandle = RegSetValueEx_(hkey, sValueName, 0, #REG_SZ, @vValue, Len(vValue) + 1) 
      Case #REG_DWORD 
        lValue = Val(vValue) 
        GetHandle = RegSetValueEx_(hKey, sValueName, 0, #REG_DWORD, @lValue, 4) 
    EndSelect 
      
    RegCloseKey_(hkey) 
    SetValue = 1 
   Else 
    RegCloseKey_(hKey)
    SetValue = 0 
  EndIf
  ProcedureReturn SetValue
EndProcedure

Procedure Enum(hwnd, lparam)
  wt$ = Space(#MAX_PATH)
    GetWindowText_(hwnd, @wt$, #MAX_PATH)
    If UCase(wt$) = "CANCEL"
      ok = hwnd
    EndIf
  ProcedureReturn #True
EndProcedure


lRetVal = RegConnectRegistry_(sRemMachName, lTopLevelKey.l, @lHKeyhandle) 
lRetVal = RegOpenKeyEx_(lHKeyhandle, sKeyName, 0, #KEY_ALL_ACCESS, @lhkey) 
lRetVal = QueryValueEx(lhkey, sValueName) 
RegCloseKey_(lhkey) 

If Val(vValue) = 0
    SetValue(lTopLevelKey, sKeyName, sValueName.s, "01", #REG_DWORD, "")
Else
    SetValue(lTopLevelKey, sKeyName, sValueName.s, "00", #REG_DWORD, "")
EndIf

RunProgram("control"," /name Microsoft.NotificationAreaIcons", "")
Delay(300)                                  ;Increase the delay if you need it
cHwnd = FindWindow_("CabinetWClass", 0)

EnumChildWindows_(cHwnd, @Enum(), 0)

PostMessage_(ok, #WM_LBUTTONDOWN, 0, 0)
PostMessage_(ok, #WM_LBUTTONUP, 0, 0)


Re: Update : En\Dis W7 Always show all icons

Posted: Thu Nov 03, 2011 9:33 am
by RASHAD
No logoff logon
No reboot
No kill Exploer
No registry

The best until now

Code: Select all

Global check,ok

Procedure Enum(hwnd, lparam)
  wt$ = Space(#MAX_PATH)
    GetWindowText_(hwnd, @wt$, #MAX_PATH)
    If wt$ = "&Always show all icons and notifications on the taskbar"
      check = hwnd
    ElseIf  wt$ = "OK"
      ok = hwnd
    EndIf
  ProcedureReturn #True
EndProcedure

RunProgram("control"," /name Microsoft.NotificationAreaIcons", "")
 Delay(300)
cHwnd = FindWindow_("CabinetWClass", 0)

; 
 EnumChildWindows_(cHwnd, @Enum(), 0)

PostMessage_(check, #WM_LBUTTONDOWN, 0, 0)
PostMessage_(check, #WM_LBUTTONUP, 0, 0)

PostMessage_(ok, #WM_LBUTTONDOWN, 0, 0)
PostMessage_(ok, #WM_LBUTTONUP, 0, 0)


Re: Update : En\Dis W7 Always show all icons

Posted: Thu Nov 03, 2011 2:40 pm
by em_uk
Opens Microsoft.NotificationAreaIcons but doesn't change the options for me on Win7 x64.

Re: Update : En\Dis W7 Always show all icons

Posted: Thu Nov 03, 2011 3:56 pm
by RASHAD
Modified a little bit for speed
Remember you may need to increase the delay time from 300 to maybe 500
Check the handles specially cHwnd

Code: Select all

Global check,ok

Procedure Enum(hwnd, lparam)
  wt$ = Space(#MAX_PATH)
    GetWindowText_(hwnd, @wt$, #MAX_PATH)
    If wt$ = "&Always show all icons and notifications on the taskbar"
      check = hwnd
    ElseIf  wt$ = "OK"
      ok = hwnd
    EndIf
  ProcedureReturn #True
EndProcedure

Path.s=Space(500)
GetSystemDirectory_(@Path,500)
WinExec_(Path+"\control.exe /name Microsoft.NotificationAreaIcons", #SW_HIDE)
;RunProgram("control"," /name Microsoft.NotificationAreaIcons", "")

Delay(300)                        ;Maybe you need to increase the delay time from 300 to 500

cHwnd = FindWindow_("CabinetWClass", 0); 
EnumChildWindows_(cHwnd, @Enum(), 0)

Debug cHwnd
Debug check
Debug ok
 
PostMessage_(check, #WM_LBUTTONDOWN, 0, 0)
PostMessage_(check, #WM_LBUTTONUP, 0, 0)
    
PostMessage_(ok, #WM_LBUTTONDOWN, 0, 0)
PostMessage_(ok, #WM_LBUTTONUP, 0, 0)


Re: Update : En\Dis W7 Always show all icons

Posted: Fri Nov 04, 2011 5:51 pm
by em_uk
Again, this only opens the notifications options, it does not change any options on my Win7 x64.

I am also curious why you chose to use WinExec_ which is only included fro 16 bit legacy reasons, being that this is running on Win6 updards/

Surely a Shellexecute would have been the proper way to go?

Code: Select all

ShellExecute_(#Null,#Null,"control.exe","/name Microsoft.NotificationAreaIcons",Path,#SW_HIDE)


Re: Update : En\Dis W7 Always show all icons

Posted: Fri Nov 04, 2011 6:00 pm
by RASHAD
@em_uk Hi :P
Sorry mate
Increase the Delay() to 1000
Run in Ascii mode ( I will try to fix that later )
And please respond

Sorry again my friend

Re: Update : En\Dis W7 Always show all icons

Posted: Fri Nov 04, 2011 6:05 pm
by em_uk
Adding the delay to 1000 worked! :)

Re: Update : En\Dis W7 Always show all icons

Posted: Fri Nov 04, 2011 7:19 pm
by RASHAD
em_uk thanks
Modified for Ascii,Unicode

Code: Select all

Global check,ok

Procedure Enum(hwnd, lparam)
    wt$ = Space(#MAX_PATH)
    GetWindowText_(hwnd, @wt$, #MAX_PATH)
    CompilerIf #PB_Compiler_Unicode
          If PeekS(@wt$,#MAX_PATH,#PB_Unicode) = "&Always show all icons and notifications on the taskbar"
            check = hwnd
          ElseIf  PeekS(@wt$,#MAX_PATH,#PB_Unicode)= "OK"
            ok = hwnd
          EndIf
    CompilerElse         
          If wt$ = "&Always show all icons and notifications on the taskbar"
            check = hwnd
          ElseIf  wt$ = "OK"
            ok = hwnd
          EndIf
    CompilerEndIf        
  ProcedureReturn #True
EndProcedure

RunProgram("Control"," /name Microsoft.NotificationAreaIcons","")
Delay(1000)
cHwnd = FindWindow_("CabinetWClass", 0)
EnumChildWindows_(cHwnd,@Enum(), 0)

PostMessage_(check, #WM_LBUTTONDOWN, 0, 0)
PostMessage_(check, #WM_LBUTTONUP, 0, 0)

    
PostMessage_(ok, #WM_LBUTTONDOWN, 0, 0)
PostMessage_(ok, #WM_LBUTTONUP, 0, 0)