Disabling the Explorer navigation bar

Everything else that doesn't fall into one of the other PB categories.
AZJIO
Addict
Addict
Posts: 1298
Joined: Sun May 14, 2017 1:48 am

Disabling the Explorer navigation bar

Post by AZJIO »

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Toggle tree display\command]
@="\"C:\\nopan\\toggle_pan.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\Toggle tree display\command]
@="\"C:\\nopan\\toggle_pan.exe\" \"%V\""
specify your paths in the registry.

Code: Select all

EnableExplicit

; https://www.purebasic.fr/english/viewtopic.php?f=12&t=56204
XIncludeFile "Registry.pbi"
UseModule Registry


Define flgNav.b
Define Pos.b
Define Param$
Define RegValue.RegValue
RegValue\TYPE = #REG_BINARY


Define Key$ = "\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings\Sizer"


Param$ = ProgramParameter()
If FileSize(Param$) = -2
	If Right(Param$, 1) <> #PS$
		Param$ + #PS$
	EndIf
Else
	Param$ = ""
EndIf

RegValue.RegValue
RegValue\TYPE = #REG_BINARY

ReadValue(#HKEY_CURRENT_USER, Key$, "PageSpaceControlSizer", #False, RegValue)
If RegValue\SIZE >= 5
	flgNav = PeekB(RegValue\BINARY + 4)
	If flgNav
		PokeB(RegValue\BINARY + 4, 0)
	Else
		PokeB(RegValue\BINARY + 4, 1)
	EndIf
	WriteValue(#HKEY_CURRENT_USER, Key$, "PageSpaceControlSizer", "", #REG_BINARY, #False, RegValue)
Else
	End
EndIf

ClearStructure(RegValue, RegValue)


Procedure.s ProcessNameFromHwnd(hWnd)
	Protected PID, psapi_dll, Path$, GetModuleFileNameEx, hProcess
	psapi_dll = OpenLibrary(#PB_Any, "psapi.dll")
	If psapi_dll
		GetModuleFileNameEx = GetFunction(psapi_dll, "GetModuleFileNameExW")
		If GetModuleFileNameEx
			If GetWindowThreadProcessId_(hWnd, @PID)
				hProcess = OpenProcess_(#PROCESS_QUERY_INFORMATION | #PROCESS_VM_READ, #Null, PID)
				If hProcess
					Path$ = Space(#MAX_PATH)
					If Not CallFunctionFast(GetModuleFileNameEx, hProcess, #Null, @Path$, #MAX_PATH)
						Path$ = ""
					EndIf
					CloseHandle_(hProcess)
				EndIf
			EndIf
		EndIf
		CloseLibrary(psapi_dll)
	EndIf
	ProcedureReturn Path$
EndProcedure

Define hWnd, Text$, k
Global hWnd_Find, classText.s = Space(256)


Procedure enumChildren1(hwnd, k)
	If hwnd
		GetClassName_(hwnd, @classText, 256)
		If GetDlgCtrlID_(hwnd) = 1001 And classText = "ToolbarWindow32"
			hWnd_Find = hwnd
			ProcedureReturn 0
		EndIf
		ProcedureReturn 1
	EndIf
	ProcedureReturn 0
EndProcedure

If Asc(Param$)
	RunProgram("explorer", Param$, "")
Else
	hWnd = FindWindowEx_(0, 0, "CabinetWClass", 0)
	If hWnd ;And Right(ProcessNameFromHwnd(hWnd), 13) = "\explorer.exe"
		EnumChildWindows_(hWnd, @enumChildren1(), k)
		If hWnd_Find
			Text$ = Space(256)
			SendMessage_(hWnd_Find, #WM_GETTEXT, 256, @Text$)
		EndIf
	EndIf
	
	; RunProgram("explorer", "/Select, " + Mid(Text$, 8), "")
	Pos = FindString(Text$, "\")
	If Pos
		Text$ = Mid(Text$, Pos - 2)
; 		Debug Text$
		If FileSize(Text$) = -2
			RunProgram("explorer", Text$, "")
		EndIf
	EndIf
EndIf