mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-23 15:25:01 +00:00
*** empty log message ***
This commit is contained in:
106
common/WriteEnv.nsh
Normal file
106
common/WriteEnv.nsh
Normal file
@@ -0,0 +1,106 @@
|
||||
!include WinMessages.nsh
|
||||
|
||||
!ifdef ALL_USERS
|
||||
!define WriteEnvStr_RegKey \
|
||||
'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
|
||||
!else
|
||||
!define WriteEnvStr_RegKey 'HKCU "Environment"'
|
||||
!endif
|
||||
|
||||
#
|
||||
# WriteEnvStr - Writes an environment variable
|
||||
# Note: Win9x systems requires reboot
|
||||
#
|
||||
# Example:
|
||||
# Push "HOMEDIR" # name
|
||||
# Push "C:\New Home Dir\" # value
|
||||
# Call WriteEnvStr
|
||||
#
|
||||
Function WriteEnvStr
|
||||
Exch $1 ; $1 has environment variable value
|
||||
Exch
|
||||
Exch $0 ; $0 has environment variable name
|
||||
Push $2
|
||||
|
||||
Call IsNT
|
||||
Pop $2
|
||||
StrCmp $2 1 WriteEnvStr_NT
|
||||
; Not on NT
|
||||
StrCpy $2 $WINDIR 2 ; Copy drive of windows (c:)
|
||||
FileOpen $2 "$2\autoexec.bat" a
|
||||
FileSeek $2 0 END
|
||||
FileWrite $2 "$\r$\nSET $0=$1$\r$\n"
|
||||
FileClose $2
|
||||
SetRebootFlag true
|
||||
Goto WriteEnvStr_done
|
||||
|
||||
WriteEnvStr_NT:
|
||||
WriteRegStr ${WriteEnvStr_RegKey} $0 $1
|
||||
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} \
|
||||
0 "STR:Environment" /TIMEOUT=5000
|
||||
|
||||
WriteEnvStr_done:
|
||||
Pop $2
|
||||
Pop $1
|
||||
Pop $0
|
||||
FunctionEnd
|
||||
|
||||
#
|
||||
# un.DeleteEnvStr - Removes an environment variable
|
||||
# Note: Win9x systems requires reboot
|
||||
#
|
||||
# Example:
|
||||
# Push "HOMEDIR" # name
|
||||
# Call un.DeleteEnvStr
|
||||
#
|
||||
Function un.DeleteEnvStr
|
||||
Exch $0 ; $0 now has the name of the variable
|
||||
Push $1
|
||||
Push $2
|
||||
Push $3
|
||||
Push $4
|
||||
Push $5
|
||||
|
||||
Call un.IsNT
|
||||
Pop $1
|
||||
StrCmp $1 1 DeleteEnvStr_NT
|
||||
; Not on NT
|
||||
StrCpy $1 $WINDIR 2
|
||||
FileOpen $1 "$1\autoexec.bat" r
|
||||
GetTempFileName $4
|
||||
FileOpen $2 $4 w
|
||||
StrCpy $0 "SET $0="
|
||||
SetRebootFlag true
|
||||
|
||||
DeleteEnvStr_dosLoop:
|
||||
FileRead $1 $3
|
||||
StrLen $5 $0
|
||||
StrCpy $5 $3 $5
|
||||
StrCmp $5 $0 DeleteEnvStr_dosLoop
|
||||
StrCmp $5 "" DeleteEnvStr_dosLoopEnd
|
||||
FileWrite $2 $3
|
||||
Goto DeleteEnvStr_dosLoop
|
||||
|
||||
DeleteEnvStr_dosLoopEnd:
|
||||
FileClose $2
|
||||
FileClose $1
|
||||
StrCpy $1 $WINDIR 2
|
||||
Delete "$1\autoexec.bat"
|
||||
CopyFiles /SILENT $4 "$1\autoexec.bat"
|
||||
Delete $4
|
||||
Goto DeleteEnvStr_done
|
||||
|
||||
DeleteEnvStr_NT:
|
||||
DeleteRegValue ${WriteEnvStr_RegKey} $0
|
||||
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} \
|
||||
0 "STR:Environment" /TIMEOUT=5000
|
||||
|
||||
DeleteEnvStr_done:
|
||||
Pop $5
|
||||
Pop $4
|
||||
Pop $3
|
||||
Pop $2
|
||||
Pop $1
|
||||
Pop $0
|
||||
FunctionEnd
|
||||
|
||||
39
common/isnt.nsh
Normal file
39
common/isnt.nsh
Normal file
@@ -0,0 +1,39 @@
|
||||
;====================================================
|
||||
; IsNT - Returns 1 if the current system is NT, 0
|
||||
; otherwise.
|
||||
; Output: head of the stack
|
||||
;====================================================
|
||||
Function IsNT
|
||||
Push $0
|
||||
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
|
||||
StrCmp $0 "" 0 IsNT_yes
|
||||
; we are not NT.
|
||||
Pop $0
|
||||
Push 0
|
||||
Return
|
||||
|
||||
IsNT_yes:
|
||||
; NT!!!
|
||||
Pop $0
|
||||
Push 1
|
||||
FunctionEnd
|
||||
|
||||
;====================================================
|
||||
; IsNT - Returns 1 if the current system is NT, 0
|
||||
; otherwise.
|
||||
; Output: head of the stack
|
||||
;====================================================
|
||||
Function un.IsNT
|
||||
Push $0
|
||||
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
|
||||
StrCmp $0 "" 0 unIsNT_yes
|
||||
; we are not NT.
|
||||
Pop $0
|
||||
Push 0
|
||||
Return
|
||||
|
||||
unIsNT_yes:
|
||||
; NT!!!
|
||||
Pop $0
|
||||
Push 1
|
||||
FunctionEnd
|
||||
200
common/path.nsh
Normal file
200
common/path.nsh
Normal file
@@ -0,0 +1,200 @@
|
||||
!verbose 3
|
||||
!include "WinMessages.NSH"
|
||||
!verbose 4
|
||||
|
||||
;====================================================
|
||||
; AddToPath - Adds the given dir to the search path.
|
||||
; Input - head of the stack
|
||||
; Note - Win9x systems requires reboot
|
||||
;====================================================
|
||||
Function AddToPath
|
||||
Exch $0
|
||||
Push $1
|
||||
|
||||
Call IsNT
|
||||
Pop $1
|
||||
StrCmp $1 1 AddToPath_NT
|
||||
; Not on NT
|
||||
StrCpy $1 $WINDIR 2
|
||||
FileOpen $1 "$1\autoexec.bat" a
|
||||
FileSeek $1 0 END
|
||||
GetFullPathName /SHORT $0 $0
|
||||
FileWrite $1 "$\r$\nSET PATH=%PATH%;$0$\r$\n"
|
||||
FileClose $1
|
||||
Goto AddToPath_done
|
||||
|
||||
AddToPath_NT:
|
||||
ReadRegStr $1 HKCU "Environment" "PATH"
|
||||
StrCmp $1 "" AddToPath_NTdoIt
|
||||
StrCpy $0 "$1;$0"
|
||||
Goto AddToPath_NTdoIt
|
||||
AddToPath_NTdoIt:
|
||||
WriteRegStr HKCU "Environment" "PATH" $0
|
||||
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
||||
|
||||
AddToPath_done:
|
||||
Pop $1
|
||||
Pop $0
|
||||
FunctionEnd
|
||||
|
||||
;====================================================
|
||||
; RemoveFromPath - Remove a given dir from the path
|
||||
; Input: head of the stack
|
||||
;====================================================
|
||||
Function un.RemoveFromPath
|
||||
Exch $0
|
||||
Push $1
|
||||
Push $2
|
||||
Push $3
|
||||
Push $4
|
||||
|
||||
Call un.IsNT
|
||||
Pop $1
|
||||
StrCmp $1 1 unRemoveFromPath_NT
|
||||
; Not on NT
|
||||
StrCpy $1 $WINDIR 2
|
||||
FileOpen $1 "$1\autoexec.bat" r
|
||||
GetTempFileName $4
|
||||
FileOpen $2 $4 w
|
||||
GetFullPathName /SHORT $0 $0
|
||||
StrCpy $0 "SET PATH=%PATH%;$0"
|
||||
SetRebootFlag true
|
||||
Goto unRemoveFromPath_dosLoop
|
||||
|
||||
unRemoveFromPath_dosLoop:
|
||||
FileRead $1 $3
|
||||
StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoop
|
||||
StrCmp $3 "$0$\n" unRemoveFromPath_dosLoop
|
||||
StrCmp $3 "$0" unRemoveFromPath_dosLoop
|
||||
StrCmp $3 "" unRemoveFromPath_dosLoopEnd
|
||||
FileWrite $2 $3
|
||||
Goto unRemoveFromPath_dosLoop
|
||||
|
||||
unRemoveFromPath_dosLoopEnd:
|
||||
FileClose $2
|
||||
FileClose $1
|
||||
StrCpy $1 $WINDIR 2
|
||||
Delete "$1\autoexec.bat"
|
||||
CopyFiles /SILENT $4 "$1\autoexec.bat"
|
||||
Delete $4
|
||||
Goto unRemoveFromPath_done
|
||||
|
||||
unRemoveFromPath_NT:
|
||||
StrLen $2 $0
|
||||
ReadRegStr $1 HKCU "Environment" "PATH"
|
||||
Push $1
|
||||
Push $0
|
||||
Call un.StrStr ; Find $0 in $1
|
||||
Pop $0 ; pos of our dir
|
||||
IntCmp $0 -1 unRemoveFromPath_done
|
||||
; else, it is in path
|
||||
StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
|
||||
IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
|
||||
IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
|
||||
StrLen $0 $1
|
||||
StrCpy $1 $1 $0 $2
|
||||
StrCpy $3 "$3$1"
|
||||
|
||||
WriteRegStr HKCU "Environment" "PATH" $3
|
||||
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
||||
|
||||
unRemoveFromPath_done:
|
||||
Pop $4
|
||||
Pop $3
|
||||
Pop $2
|
||||
Pop $1
|
||||
Pop $0
|
||||
FunctionEnd
|
||||
|
||||
;====================================================
|
||||
; StrStr - Finds a given string in another given string.
|
||||
; Returns -1 if not found and the pos if found.
|
||||
; Input: head of the stack - string to find
|
||||
; second in the stack - string to find in
|
||||
; Output: head of the stack
|
||||
;====================================================
|
||||
Function StrStr
|
||||
Push $0
|
||||
Exch
|
||||
Pop $0 ; $0 now have the string to find
|
||||
Push $1
|
||||
Exch 2
|
||||
Pop $1 ; $1 now have the string to find in
|
||||
Exch
|
||||
Push $2
|
||||
Push $3
|
||||
Push $4
|
||||
Push $5
|
||||
|
||||
StrCpy $2 -1
|
||||
StrLen $3 $0
|
||||
StrLen $4 $1
|
||||
IntOp $4 $4 - $3
|
||||
|
||||
StrStr_loop:
|
||||
IntOp $2 $2 + 1
|
||||
IntCmp $2 $4 0 0 StrStrReturn_notFound
|
||||
StrCpy $5 $1 $3 $2
|
||||
StrCmp $5 $0 StrStr_done StrStr_loop
|
||||
|
||||
StrStrReturn_notFound:
|
||||
StrCpy $2 -1
|
||||
|
||||
StrStr_done:
|
||||
Pop $5
|
||||
Pop $4
|
||||
Pop $3
|
||||
Exch $2
|
||||
Exch 2
|
||||
Pop $0
|
||||
Pop $1
|
||||
FunctionEnd
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Uninstall sutff
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
;====================================================
|
||||
; StrStr - Finds a given string in another given string.
|
||||
; Returns -1 if not found and the pos if found.
|
||||
; Input: head of the stack - string to find
|
||||
; second in the stack - string to find in
|
||||
; Output: head of the stack
|
||||
;====================================================
|
||||
Function un.StrStr
|
||||
Push $0
|
||||
Exch
|
||||
Pop $0 ; $0 now have the string to find
|
||||
Push $1
|
||||
Exch 2
|
||||
Pop $1 ; $1 now have the string to find in
|
||||
Exch
|
||||
Push $2
|
||||
Push $3
|
||||
Push $4
|
||||
Push $5
|
||||
|
||||
StrCpy $2 -1
|
||||
StrLen $3 $0
|
||||
StrLen $4 $1
|
||||
IntOp $4 $4 - $3
|
||||
|
||||
unStrStr_loop:
|
||||
IntOp $2 $2 + 1
|
||||
IntCmp $2 $4 0 0 unStrStrReturn_notFound
|
||||
StrCpy $5 $1 $3 $2
|
||||
StrCmp $5 $0 unStrStr_done unStrStr_loop
|
||||
|
||||
unStrStrReturn_notFound:
|
||||
StrCpy $2 -1
|
||||
|
||||
unStrStr_done:
|
||||
Pop $5
|
||||
Pop $4
|
||||
Pop $3
|
||||
Exch $2
|
||||
Exch 2
|
||||
Pop $0
|
||||
Pop $1
|
||||
FunctionEnd
|
||||
Reference in New Issue
Block a user