Victor_VG
Tracker Mod | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору /* ************************************************************** * ProcLib - procedure library for NSIS v2.9 * ************************************************************** This library writing is VictorVG @ VikSoft.Ru, Russia, Moscow. Writes is 12:20 02 Mar 2006, last updated at 06 May 2010 at 09:55 */ !include "nsProcess.nsh" !include "TextReplace.nsh" !include "WordFunc.nsh" !include "Registry.nsh" !verbose 3 !verbose push !ifndef _PROCLIB_VERBOSE !define _PROCLIB_VERBOSE 3 !endif !verbose ${_PROCLIB_VERBOSE} !define PROCLIB_VERBOSE `!insertmacro _PROCLIB_VERBOSE` !define SIDtU `!insertmacro StdInstDtU` !define SIDtG `!insertmacro StdInstDtG` !define SIDtI `!insertmacro StdInstDtI` !define SIDtS `!insertmacro StdInstDtS` !define TermProc `!insertmacro TermProc` !define TrmPrc `!insertmacro TrmPrcc` !define ErrDec `!insertmacro ErrDetCall` !define PrDet `!insertmacro PrDetCall` !define RplSet `!insertmacro ReplSeting` !define MinVer `!insertmacro MinOSVer` !define RngVer `!insertmacro RngOSVer` !define PrcReg `!insertmacro PrcFndReg` !define WriteEnvStr `!insertmacro WrtEnvStr` !verbose pop /* ; Standard function templates for write new user defended functions. ; !ifmacrondef CallMacroName ; Call'g macro !macro CallMacroName [_PARAM1 ... _PARAMn] ; any code Call CallFunctions ; any code !macroend !endif !ifndef CallFunctName !define CallFunctName `!insertmacro CallMacroName` Function CallFunctions ; internal function ; Function code FunctionEnd !endif */ !macro StdInstDtU /* Standart installer running detector for Update. $R1 == errolevel code is: If standart installer not running $R1 == 0, then $R1 == 1 */ Push $R0 ${nsProcess::FindProcess} "setup.exe" $R0 StrCmp $R0 0 +8 ${nsProcess::FindProcess} "install.exe" $R0 StrCmp $R0 0 +6 ${nsProcess::FindProcess} "upgrade.exe" $R0 IntCmp $R0 0 +4 ${nsProcess::FindProcess} "msiexec.exe" $R0 StrCmp $R0 0 +1 +4 StrCpy $R1 1 Goto +5 StrCmp $R0 603 +1 +4 StrCpy $R1 0 Goto +2 StrCpy $R1 $R0 Pop $R0 ${nsProcess::Unload} !macroEnd !macro StdInstDtG /* Standart installer running detector for Upgrade. $R1 == errolevel code is: If standart installer not running $R1 == 0, then $R1 == 1 */ Push $R0 ${nsProcess::FindProcess} "setup.exe" $R0 StrCmp $R0 0 +8 ${nsProcess::FindProcess} "update.exe" $R0 StrCmp $R0 0 +6 ${nsProcess::FindProcess} "install.exe" $R0 IntCmp $R0 0 +4 ${nsProcess::FindProcess} "msiexec.exe" $R0 StrCmp $R0 0 +1 +4 StrCpy $R1 1 Goto +5 StrCmp $R0 603 +1 +4 StrCpy $R1 0 Goto +2 StrCpy $R1 $R0 Pop $R0 ${nsProcess::Unload} !macroEnd !macro StdInstDtS /* Standart installer running detector for Setup. $R1 == errolevel code is: If standart installer not running $R1 == 0, then $R1 == 1 */ Push $R0 ${nsProcess::FindProcess} "install.exe" $R0 StrCmp $R0 0 +8 ${nsProcess::FindProcess} "update.exe" $R0 StrCmp $R0 0 +6 ${nsProcess::FindProcess} "upgrade.exe" $R0 IntCmp $R0 0 +4 ${nsProcess::FindProcess} "msiexec.exe" $R0 StrCmp $R0 0 +1 +4 StrCpy $R1 1 Goto +5 StrCmp $R0 603 +1 +4 StrCpy $R1 0 Goto +2 StrCpy $R1 $R0 Pop $R0 ${nsProcess::Unload} !macroEnd !macro StdInstDtI /* Standart installer running detector for Install. $R1 == errolevel code is: If standart installer not running $R1 == 0, then $R1 == 1 */ Push $R0 ${nsProcess::FindProcess} "setup.exe" $R0 StrCmp $R0 0 +8 ${nsProcess::FindProcess} "update.exe" $R0 StrCmp $R0 0 +6 ${nsProcess::FindProcess} "upgrade.exe" $R0 IntCmp $R0 0 +4 ${nsProcess::FindProcess} "msiexec.exe" $R0 StrCmp $R0 0 +1 +4 StrCpy $R1 1 Goto +5 StrCmp $R0 603 +1 +4 StrCpy $R1 0 Goto +2 StrCpy $R1 $R0 Pop $R0 ${nsProcess::Unload} !macroEnd !macro StdInstDtA /* Standart installer running detector for any name. Output varuiables $R1 == errolevel code is: If any standart installer not running $R1 == 0, then $R1 == 1 */ Push $R0 ${nsProcess::FindProcess} "install.exe" $R0 StrCmp $R0 0 +15 StrCmp $R0 603 +16 +20 ${nsProcess::FindProcess} "setup.exe" $R0 StrCmp $R0 0 +12 StrCmp $R0 603 +13 +17 ${nsProcess::FindProcess} "update.exe" $R0 StrCmp $R0 0 +9 StrCmp $R0 603 +10 +14 ${nsProcess::FindProcess} "upgrade.exe" $R0 IntCmp $R0 0 +6 StrCmp $R0 603 +7 +11 ${nsProcess::FindProcess} "msiexec.exe" $R0 StrCmp $R0 0 +2 StrCmp $R0 603 +4 +8 StrCpy $R1 1 Goto +2 StrCpy $R1 0 ${nsProcess::Unload} Goto +2 ${ErrDec} $R0 Pop $R0 !macroEnd !macro TermProc _PROCNAME _TXTFILE /* This macros is finde indicated process and kill it if running. If needed, macros output error code on display. See ${NSISDIR}\Docs\nsProcess\readme.txt for details. Parameters: _PROCNAME full process name include extensions _TXTFILE full diagnostics messages list file name include extensions */ Push $0 ${nsProcess::FindProcess} _PROCNAME $0 StrCmp $0 603 +16 IntCmp $0 604 +11 +1 +11 StrCpy $0 0 ${nsProcess::KillProcess} _PROCNAME $0 IntCmp $0 603 +12 +1 +8 IntCmp $0 0 +11 StrCmp $0 602 +6 +1 StrCmp $LANGUAGE 1049 +2 MessageBox MB_ICONSTOP|MB_OK "Your don't have permission to terminate process _PROCNAME. Error code 601." IDOK +2 MessageBox MB_ICONSTOP|MB_OK "У Вас нет прав для удаления процесса _PROCNAME. Код ошибки 601." IDOK +1 Quit StrCmp $LANGUAGE 1049 +2 MessageBox MB_ICONSTOP|MB_OK "System error $0. Setup terminated. See _TXTFILE for error code details." IDOK +2 MessageBox MB_ICONSTOP|MB_OK "Системная ошибка $0. Установка прервана. Расшифровку кодов ошибок смотрите в _TXTFILE." IDOK +1 Quit ${nsProcess::Unload} Pop $0 !macroend !macro TrmPrcc _PRCS /* This macros is finde indicated process and kill it if running. If needed, macros output error messages on display. Input parameters: _PRCS full process name include extensions. */ Push $0 ${nsProcess::FindProcess} ${_PRCS} $0 StrCmp $0 0 +2 StrCmp $0 603 +9 +12 StrCmp $LANGUAGE 1049 +2 MessageBox MB_ICONQUESTION|MB_YESNO 'Waring! Process ${_PRCS} already runing.$\nPress "Yes" for terminate it or "No" for quit.' IDYES +4 IDNO +2 MessageBox MB_ICONQUESTION|MB_YESNO 'Внимание! Процесс ${_PRCS} запущен.$\nНажмите "Да" для его завершения или "Нет" для выхода.' IDYES +2 IDNO +1 Quit ${nsProcess::KillProcess} ${_PRCS} $0 StrCmp $0 0 +2 StrCmp $0 603 +1 +5 ${nsProcess::Unload} Pop $0 Goto +65 StrCmp $0 601 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Your do not have permission to terminate process" Goto +2 StrCpy $1 "У Вас нет права прекращения процессов" Goto +55 StrCmp $1 602 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Not all processes terminated successfully" Goto +2 StrCpy $1 "Не все процесы завершены успешно" Goto +49 StrCmp $0 604 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to identify system type" Goto +2 StrCpy $1 "Не удалось определить тип системы" Goto +43 StrCmp $0 605 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unsupported OS" Goto +2 StrCpy $1 "Не поддерживаемая ОС" Goto +37 StrCmp $0 606 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to load NTDLL.DLL" Goto +2 StrCpy $1 "Ошибка загрузки NTDLL.DLL" Goto +31 StrCmp $0 607 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to get procedure address from NTDLL.DLL" Goto +2 StrCpy $1 "Ошибка вызова процедуры из NTDLL.DLL" Goto +25 StrCmp $0 608 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "NtQuerySystemInformation failed" Goto +2 StrCpy $1 "Ошибка вызова NtQuerySystemInformation" Goto +19 StrCmp $0 609 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to load KERNEL32.DLL" Goto +2 StrCpy $1 "Ошибка загрузки KERNEL32.DLL" Goto +13 StrCmp $0 610 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to get procedure address from KERNEL32.DLL" Goto +2 StrCpy $1 "Ошибка вызова процедуры из KERNEL32.DLL" Goto +7 StrCmp $0 611 +1 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "CreateToolhelp32Snapshot failed" Goto +2 StrCpy $1 "Ошибка вызова CreateToolhelp32Snapshot" StrCmp $LANGUAGE 1049 +2 +1 MessageBox MB_OK|MB_ICONEXCLAMATION "Waring! System error status is $0, $1 setup can't continue." IDOK +2 MessageBox MB_OK|MB_ICONEXCLAMATION "Внимание! Возникла системная ошибка $0, $1 установка прекращена." IDOK +1 Quit !macroend !macro ErrDetCall _ERRCODE /* ${ErrDec} function for nsProcess error code decode and user alarm. If Error Code detected this function generated user alarm and terminated terminated current installation. Usage ${ErrDec} $var $var - input variable contaned analasing code. */ StrCpy $0 ${_ERRCODE} StrCmp $0 601 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Your do not have permission to terminate process" Goto +2 StrCpy $1 "У Вас нет права прекращения процессов" Goto +55 StrCmp $1 602 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Not all processes terminated successfully" Goto +2 StrCpy $1 "Не все процесы завершены успешно" Goto +49 StrCmp $0 604 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to identify system type" Goto +2 StrCpy $1 "Не удалось определить тип системы" Goto +43 StrCmp $0 605 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unsupported OS" Goto +2 StrCpy $1 "Не поддерживаемая ОС" Goto +37 StrCmp $0 606 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to load NTDLL.DLL" Goto +2 StrCpy $1 "Ошибка загрузки NTDLL.DLL" Goto +31 StrCmp $0 607 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to get procedure address from NTDLL.DLL" Goto +2 StrCpy $1 "Ошибка вызова процедуры из NTDLL.DLL" Goto +25 StrCmp $0 608 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "NtQuerySystemInformation failed" Goto +2 StrCpy $1 "Ошибка вызова NtQuerySystemInformation" Goto +19 StrCmp $0 609 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to load KERNEL32.DLL" Goto +2 StrCpy $1 "Ошибка загрузки KERNEL32.DLL" Goto +13 StrCmp $0 610 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to get procedure address from KERNEL32.DLL" Goto +2 StrCpy $1 "Ошибка вызова процедуры из KERNEL32.DLL" Goto +7 StrCmp $0 611 +1 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "CreateToolhelp32Snapshot failed" Goto +2 StrCpy $1 "Ошибка вызова CreateToolhelp32Snapshot" StrCmp $LANGUAGE 1049 +2 +1 MessageBox MB_OK|MB_ICONEXCLAMATION "Waring! System error status is - $0, $1 setup can't continue." IDOK +2 MessageBox MB_OK|MB_ICONEXCLAMATION "Внимание! Возникла системная ошибка - $0, $1 установка прекращена." IDOK +1 Quit !MacroEnd /* Function ${PrDet}. Detector if process is ruining. Usage: ${PrDet} _ProcName _ReturnCode _ProcName = full process name include extension _ReturnCode = is "0" if process not running or "1" if process running or Error Code if detected any system error. All Error Code equivalents ${nsProcess:FindProcess} error code list. */ !macro PrDetCall _PRCNM _Erorl ${nsProcess::FindProcess} ${_PRCNM} $0 IntCmp $0 603 +4 +1 +6 StrCpy ${_Erorl} 1 Goto +5 StrCpy ${_Erorl} 0 Goto +2 StrCpy ${_Erorl} $0 !macroend !macro ReplSeting _KEY _SKEY _VALUE _REGFI _REGFO _STR _ERR /* This macro is replace value in saved .REG-file using existing Registry value. If macro detected error, then Error flags is set On, and returned error code. Parameters: _KEY HKCU|HKLM|HKCR... - root Registry key for find setting _SKEY subkey for find setting _VALUE value for find setting _REGFI - input .REG-file _REGFO - output .REG-file _STR - replaced string value _ERR - variable for output error Examples: ${RplSet} HKCU "Software\Mysoft\ModuleDir\MyModule" "Value" "$INSTDIR\configdir\default.reg" "$INSTDIR\configdir\default.reg" "C:\\Program Files\\MyPogram\\SubDir\\ModuleDir\\Module.exe" $1 or ${RplSet} HKLM "Software\MyProg" "InstallDir" "$INSTDIR\configdir\default.reg" "$INSTDIR\configdir\default.reg" "C:\\Program Files\\MyProgram" $1 */ Push $0 ReadRegStr $0 ${_KEY} "${_SKEY}" "${_VALUE}" ${WordReplace} "$0" "\" "\\" "+" $0 ${textreplace::ReplaceInFile} "${_REGFI}" "${_REGFO}" "${_STR}" "$0" "/PO=0" ${_ERR} IntCmp ${_ERR} "-1" +1 +1 +4 SetErrors Goto +4 ClearErrors StrCpy "${_ERR}" 0 Pop $0 !macroend !macro MinOSVer _minver _retn /* This macro detected OS version, compared to _mimver and retuned "1" if OS version equivalents or highest then _minver, or "0" if less in to users variables _retn Parameters: _minver - minimal version, two digits, example 51 _retn - user variables for returned results, exclude registers $0 and $1 Rescriptions: Your can't use register $0 and $1 as _retn variables Examples: ; added on to script header: ... !include "ProcLib.nsh" var s1 ... Section "Code" ... ${MinOSVer} 51 $s1 ... SectionEnd */ Push $0 Push $1 StrCpy ${_retn} 0 nsisos::osversion StrCmp $0 "" +1 +2 StrCpy $0 0 StrCmp $1 "" +1 +2 StrCpy $1 0 StrCpy $0 $0$1 IntCmp $0 ${_minver} +1 +2 StrCpy ${_retn} 1 Pop $0 Pop $1 !macroend !macro RngOSVer _minver _maxver _retn /* This macro gets the operating system version and service pack number, checks whether it is in the range _minver and _maxver, and if the version of the system with installed service pack number, located in the specified range, it returns "1" in the variable _retn, in other cases it returns "0". Parameters: _minver - min version and service pack number, always free digits, example 510 _minver - max version and service pack number, always free digits, example 513 _retn - user variables for returned results, exclude registers $0 and $1 Notes: if any digit not existing You mast replace this symbol use "0" digit. Rescriptions: Your can't use register $0 - $1 as _retn variables Examples: !include "ProcLib.nsh" var s1 ... Section "Code" ... ${RngOSVer} 500 619 $s1 ... SectionEnd */ Push $0 Push $1 StrCpy ${_retn} 0 Version::GetWindowsVersion Pop $0 StrCmp $0 "" +1 +2 StrCpy $0 0 Pop $1 StrCmp $1 "" +1 +2 StrCpy $1 0 StrCpy $0 $0$1 Pop $1 Pop $1 Pop $1 StrCmp $1 "" +1 +2 StrCpy $1 0 StrCpy $1 $1 1 -1 StrCpy $0 $0$1 IntCmp $0 ${_maxver} +1 +1 +4 IntCmp $0 ${_minver} +1 +2 StrCpy ${_retn} 1 Pop $0 Pop $1 !macroend !macro PrcFndReg _rkey1 _key1 _value1 _rkey2 _key2 _value2 _ofset _mode _retn /* This function detected and terminate any process use path saved in to Registry. _rkey1 - Registry root key to checked programm full path _key1 - Registry key to checked programm full path _value1 - Registry value to checked programm full path _rkey2 - Registry root key to checked programm path _key2 - Registry key to checked programm path _value2 - Registry value to checked programm path _ofset - additional ofset if needed, if ofset can't needed mast be is 0 _mode - calling mode: if T - find and terminate process, else - only find _retn - process detect code: if process currenly running is "running", else is "success" Rescriptions: Thsis macros used and restored registers $0, $1, $2, $3 and Your cann't use it as parameters. Examples: PrcFndReg HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinGimp-2.0_is1" \ "DisplayIcon" HKLM \ "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinGimp-2.0_is1" \ "InstallLocation" 0 $4 */ Push $3 Push $2 Push $1 Push $0 ReadRegStr $3 ${_rkey1} ${_key1} ${_value1} ReadRegStr $1 ${_rkey2} ${_key2} ${_value2} StrLen $2 $1 IntOp $2 $2 + ${_ofset} StrCpy $3 $3 "" $2 StrCpy ${_retn} "running" ${nsProcess::FindProcess} $3 $2 IntCmp $2 604 +14 +1 +14 StrCmp $2 0 +2 StrCpy ${_retn} "success" StrCmp ${_mode} "T" +1 +6 StrCmp ${_retn} "success" +5 ${nsProcess::KillProcess} $3 $2 IntCmp $2 603 +1 +1 +8 StrCpy ${_retn} "success" Pop $0 Pop $1 Pop $2 Pop $3 Goto +65 StrCmp $2 601 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Your do not have permission to terminate process" Goto +2 StrCpy $1 "У Вас нет права прекращения процессов" Goto +55 StrCmp $1 602 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Not all processes terminated successfully" Goto +2 StrCpy $1 "Не все процесы завершены успешно" Goto +49 StrCmp $2 604 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to identify system type" Goto +2 StrCpy $1 "Не удалось определить тип системы" Goto +43 StrCmp $2 605 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unsupported OS" Goto +2 StrCpy $1 "Не поддерживаемая ОС" Goto +37 StrCmp $2 606 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to load NTDLL.DLL" Goto +2 StrCpy $1 "Ошибка загрузки NTDLL.DLL" Goto +31 StrCmp $2 607 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to get procedure address from NTDLL.DLL" Goto +2 StrCpy $1 "Ошибка вызова процедуры из NTDLL.DLL" Goto +25 StrCmp $2 608 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "NtQuerySystemInformation failed" Goto +2 StrCpy $1 "Ошибка вызова NtQuerySystemInformation" Goto +19 StrCmp $2 609 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to load KERNEL32.DLL" Goto +2 StrCpy $1 "Ошибка загрузки KERNEL32.DLL" Goto +13 StrCmp $2 610 +1 +7 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "Unable to get procedure address from KERNEL32.DLL" Goto +2 StrCpy $1 "Ошибка вызова процедуры из KERNEL32.DLL" Goto +7 StrCmp $2 611 +1 StrCmp $LANGUAGE 1049 +4 StrCpy $1 "CreateToolhelp32Snapshot failed" Goto +2 StrCpy $1 "Ошибка вызова CreateToolhelp32Snapshot" StrCmp $LANGUAGE 1049 +2 +1 MessageBox MB_OK|MB_ICONEXCLAMATION "Waring! System error status is - $2, $1 setup can't continue." IDOK +2 MessageBox MB_OK|MB_ICONEXCLAMATION "Внимание! Возникла системная ошибка - $2, $1 установка прекращена." IDOK +1 Quit !macroend !macro WrtEnvStr _HKR _Key _ValueName _Value _Sep /* This function detected existing enveronment variables and appen it or create new enveronment variables record if needed. Parameters: _HKR - Registry root key for variable _Key - Registry key for variable _ValueName - Registry value for variable _Value - variable value _Sep - value separator. If _Sep not used, then _Sep mast be defined as "". Examples: WrtEnvStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "CYGWIN" "nodosfilewarning" " " */ Push $1 Push $0 ClearErrors ReadEnvStr $0 ${_ValueName} StrCmp $0 "" +1 +4 WriteRegStr ${_HKR} "${_Key}" "${_ValueName}" "${_Value}" Goto +5 ${WordFind} $0 "${_ValueName}" "#" $1 StrCmp $1 0 +1 +2 ${registry::WriteExtra} "${_HKR}\${_Key}" "${_ValueName}" "${_Sep}${_Value}" $1 Pop $0 Pop $1 !macroend | Всего записей: 33266 | Зарегистр. 31-07-2002 | Отправлено: 13:12 29-05-2010 | Исправлено: Victor_VG, 13:18 29-05-2010 |
|