最新消息:

局域网使用工具NSIS脚本

nsis 永恒心锁 2308浏览 0评论
!addplugindir "ResPlugins"

#!define NSIS_VERSION_NEW ;;makensis.exe 2.21以后版本请去掉注释。

!include "LanInfoManager.nsh"

!define MUI_ICON "${RES_ICON}"

!define MUI_UI "${RES_UI}"

Name ${STR_NAME}

Caption "${STR_CAPTION}"

OutFile ${STR_OUTFILE}

CRCCheck off

!insertmacro MUI_LANGUAGE "${STR_MUI_LANG}"

VIProductVersion "${STR_VERSION}"

VIAddVersionKey /LANG=${LANG_ID} "ProductName" "${STR_PRODCTNAME}"

VIAddVersionKey /LANG=${LANG_ID} "Comments" "${STR_COMMENTS}"

VIAddVersionKey /LANG=${LANG_ID} "CompanyName" "${STR_COMPANYNAME}"

VIAddVersionKey /LANG=${LANG_ID} "LegalCopyright" "${STR_COPYRIGHT}"

VIAddVersionKey /LANG=${LANG_ID} "FileDescription" "${STR_FILEDESCRIPTION}"

VIAddVersionKey /LANG=${LANG_ID} "FileVersion" "${STR_FILEVERSION}"

VIAddVersionKey /LANG=${LANG_ID} "InternalName" "${STR_INTNAME}"

VIAddVersionKey /LANG=${LANG_ID} "OriginalFilename" "${STR_OUTFILE}"

Page custom ShowCustom LeaveCustom

Page instfiles ;;可有可无...

!macro AddHostNum ARG_Delta

IntOp $COUNTER_HOSTNUM $COUNTER_HOSTNUM + ${ARG_Delta}

!macroend

!macro EnableGlobalBtn ARG_Var.hwnd ARG_Flag

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${BTN_CHANGE_IP}" "HWND"

ShowWindow ${ARG_Var.hwnd} ${ARG_Flag}

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${BTN_CHANGE_MAC}" "HWND"

ShowWindow ${ARG_Var.hwnd} ${ARG_Flag}

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${BTN_MINIMIZE}" "HWND"

ShowWindow ${ARG_Var.hwnd} ${ARG_Flag}

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${BTN_RF_CONNECTION}" "HWND"

ShowWindow ${ARG_Var.hwnd} ${ARG_Flag}

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${LAB_HELP}" "HWND"

ShowWindow ${ARG_Var.hwnd} 0

${if} ${ARG_Flag} == 0

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${GB_GLOBAL}" "HWND"

SendMessage ${ARG_Var.hwnd} ${WM_SETTEXT} 0 "STR:${STR_NOTEPAD}" ;;更改标签字符

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${TXT_NOTEPAD}" "HWND"

ShowWindow ${ARG_Var.hwnd} 1

${else}

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${GB_GLOBAL}" "HWND"

SendMessage ${ARG_Var.hwnd} ${WM_SETTEXT} 0 "STR:全局操作" ;;更改标签字符

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${TXT_NOTEPAD}" "HWND"

ShowWindow ${ARG_Var.hwnd} 1

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${TXT_NOTEPAD}" "HWND"

ShowWindow ${ARG_Var.hwnd} 0

${endif}

!macroend

!macro EnableTXTEdit ARG_Var.hwnd ARG_Flag

EnableWindow $HWND_TXT_HOST ${ARG_Flag}

EnableWindow $HWND_TXT_MAC ${ARG_Flag}

EnableWindow $HWND_TXT_IP ${ARG_Flag}

EnableWindow $HWND_TXT_MASK ${ARG_Flag}

EnableWindow $HWND_TXT_NETGATE ${ARG_Flag}

EnableWindow $HWND_TXT_DNS ${ARG_Flag}

${if} ${ARG_Flag} == 0

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${LAB_SCALE}" "HWND"

ShowWindow ${ARG_Var.hwnd} 0

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${LAB_AUTHOR}" "HWND"

ShowWindow ${ARG_Var.hwnd} 0

SetCtlColors ${ARG_Var.hwnd} 0x333333 transparent

SendMessage ${ARG_Var.hwnd} ${WM_SETTEXT} 0 "STR:${STR_AUTHOR}"

ShowWindow ${ARG_Var.hwnd} 1

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${BTN_NEW_HOST}" "HWND"

EnableWindow ${ARG_Var.hwnd} 1

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${BTN_EDIT_HOST}" "HWND"

EnableWindow ${ARG_Var.hwnd} 1

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${BTN_ADD}" "HWND"

ShowWindow ${ARG_Var.hwnd} 0

EnableWindow ${ARG_Var.hwnd} 0

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${BTN_UPDATE}" "HWND"

ShowWindow ${ARG_Var.hwnd} 0

EnableWindow ${ARG_Var.hwnd} 0

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${BTN_DELETE}" "HWND"

ShowWindow ${ARG_Var.hwnd} 0

EnableWindow ${ARG_Var.hwnd} 0

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND" ;;可用下拉主机列表

EnableWindow ${ARG_Var.hwnd} 1

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${BTN_EXPORT_HOSTLIST}" "HWND"

WriteINIStr "${MUI_INIFILE}" "Field ${BTN_EXPORT_HOSTLIST}" "Text" "备份主机列表(&S)"

SendMessage ${ARG_Var.hwnd} ${WM_SETTEXT} 0 "STR:备份主机列表(&S)"

${else}

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${LAB_SCALE}" "HWND"

ShowWindow ${ARG_Var.hwnd} 1

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${LAB_AUTHOR}" "HWND"

ShowWindow ${ARG_Var.hwnd} 0

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${BTN_NEW_HOST}" "HWND"

EnableWindow ${ARG_Var.hwnd} 0

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${BTN_EDIT_HOST}" "HWND"

EnableWindow ${ARG_Var.hwnd} 0

ReadINIStr ${ARG_Var.hwnd} "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND" ;;禁用下拉主机列表

EnableWindow ${ARG_Var.hwnd} 0

${endif}

!macroend

!macro ShowReg2Txt ARG_Var.1 ARG_Var.2 ARG_Var.3

${if} $COUNTER_HOSTNUM >= 1 ;有主机信息

ReadINIStr ${ARG_Var.1} "${MUI_INIFILE}" "Field ${DL_HOST}" "State"

SendMessage $HWND_TXT_HOST ${WM_SETTEXT} 0 "STR:${ARG_Var.1}"

ReadRegStr ${ARG_Var.2} HKLM "${REG_ME_HOSTLIST}${ARG_Var.1}" "MAC"

${if} ${ARG_Var.2} == ""

${orif} ${ARG_Var.2} == ${STR_UNSETTED}

StrCpy ${ARG_Var.2} "${STR_UNSETTED}"

${else}

StrLen ${ARG_Var.3} "${ARG_Var.2}"

${if} ${ARG_Var.3} != 12

StrCpy ${ARG_Var.2} "${STR_ERRORFORMAT}"

${endif}

${endif}

SendMessage $HWND_TXT_MAC ${WM_SETTEXT} 0 "STR:${ARG_Var.2}"

ReadRegStr ${ARG_Var.2} HKLM "${REG_ME_HOSTLIST}${ARG_Var.1}" "IP"

${if} ${ARG_Var.2} == ""

StrCpy ${ARG_Var.2} "${STR_UNSETTED}"

${endif}

SendMessage $HWND_TXT_IP ${WM_SETTEXT} 0 "STR:${ARG_Var.2}"

ReadRegStr ${ARG_Var.2} HKLM "${REG_ME_HOSTLIST}${ARG_Var.1}" "MASK"

${if} ${ARG_Var.2} == ""

StrCpy ${ARG_Var.2} "${STR_UNSETTED}"

${endif}

SendMessage $HWND_TXT_MASK ${WM_SETTEXT} 0 "STR:${ARG_Var.2}"

ReadRegStr ${ARG_Var.2} HKLM "${REG_ME_HOSTLIST}${ARG_Var.1}" "NETGATE"

${if} ${ARG_Var.2} == ""

StrCpy ${ARG_Var.2} "${STR_UNSETTED}"

${endif}

SendMessage $HWND_TXT_NETGATE ${WM_SETTEXT} 0 "STR:${ARG_Var.2}"

ReadRegStr ${ARG_Var.2} HKLM "${REG_ME_HOSTLIST}${ARG_Var.1}" "DNS"

${if} ${ARG_Var.2} == ""

StrCpy ${ARG_Var.2} "${STR_UNSETTED}"

${endif}

SendMessage $HWND_TXT_DNS ${WM_SETTEXT} 0 "STR:${ARG_Var.2}"

${else} ;无主机信息

ReadRegStr ${ARG_Var.2} HKLM "${REG_WINLOGON}" "AltDefaultDomainName"

SendMessage $HWND_TXT_HOST ${WM_SETTEXT} 0 "STR:${ARG_Var.2}"

ReadINIStr ${ARG_Var.1} ${MUI_INIFILE} "Field ${DL_NETCARD}" State

ReadINIStr ${ARG_Var.2} ${MUI_INIFILE} "${ARG_Var.1}" "MAC"

SendMessage $HWND_TXT_MAC ${WM_SETTEXT} 0 "STR:${ARG_Var.2}"

ReadINIStr ${ARG_Var.2} ${MUI_INIFILE} "${ARG_Var.1}" "IP"

SendMessage $HWND_TXT_IP ${WM_SETTEXT} 0 "STR:${ARG_Var.2}"

ReadINIStr ${ARG_Var.2} ${MUI_INIFILE} "${ARG_Var.1}" "MASK"

SendMessage $HWND_TXT_MASK ${WM_SETTEXT} 0 "STR:${ARG_Var.2}"

ReadINIStr ${ARG_Var.2} ${MUI_INIFILE} "${ARG_Var.1}" "NETGATE"

SendMessage $HWND_TXT_NETGATE ${WM_SETTEXT} 0 "STR:${ARG_Var.2}"

ReadINIStr ${ARG_Var.2} ${MUI_INIFILE} "${ARG_Var.1}" "DNS"

SendMessage $HWND_TXT_DNS ${WM_SETTEXT} 0 "STR:${ARG_Var.2}"

${endif}

${if} $COUNTER_HOSTNUM < 1 ;无主机列表信息

SendMessage $HWND_GB_SELHOST ${WM_SETTEXT} 0 "STR:选择主机 ( 无主机信息 )"

${else} ;;显示主机个数

SendMessage $HWND_GB_SELHOST ${WM_SETTEXT} 0 "STR:选择主机 ( 当前共 $COUNTER_HOSTNUM 个主机信息 )"

${endif}

!macroend

!macro SaveTxt2Reg ARG_Var.1 ARG_Var.2 ARG_Var.3

WriteRegStr HKLM "${REG_ME_HOSTLIST}${ARG_Var.1}" "" "Setted"

WriteINIStr ${MUI_INIFILE} "Field ${TXT_HOST}" State ${ARG_Var.1}

ReadINIStr ${ARG_Var.2} "${MUI_INIFILE}" "Field ${TXT_MAC}" "State"

StrCpy ${ARG_Var.3} "${ARG_Var.2}"

${if} ${ARG_Var.2} == ""

${orif} ${ARG_Var.2} == "${STR_UNSETTED}"

StrCpy ${ARG_Var.2} ""

StrCpy ${ARG_Var.3} "${STR_UNSETTED}"

${else}

StrLen ${ARG_Var.3} "${ARG_Var.2}"

${if} ${ARG_Var.3} != 12

StrCpy ${ARG_Var.3} "${STR_ERRORFORMAT}"

${else}

StrCpy ${ARG_Var.3} ${ARG_Var.2}

${endif}

${endif}

SendMessage $HWND_TXT_MAC ${WM_SETTEXT} 0 "STR:${ARG_Var.3}"

WriteRegStr HKLM "${REG_ME_HOSTLIST}${ARG_Var.1}" "MAC" "${ARG_Var.2}"

ReadINIStr ${ARG_Var.2} "${MUI_INIFILE}" "Field ${TXT_IP}" "State"

StrCpy ${ARG_Var.3} "${ARG_Var.2}"

${if} ${ARG_Var.2} == ""

${orif} ${ARG_Var.2} == "${STR_UNSETTED}"

StrCpy ${ARG_Var.3} ${STR_UNSETTED}

StrCpy ${ARG_Var.2} ""

${endif}

SendMessage $HWND_TXT_IP ${WM_SETTEXT} 0 "STR:${ARG_Var.3}"

WriteRegStr HKLM "${REG_ME_HOSTLIST}${ARG_Var.1}" "IP" ${ARG_Var.2}

ReadINIStr ${ARG_Var.2} "${MUI_INIFILE}" "Field ${TXT_MASK}" "State"

StrCpy ${ARG_Var.3} "${ARG_Var.2}"

${if} ${ARG_Var.2} == ""

${orif} ${ARG_Var.2} == "${STR_UNSETTED}"

StrCpy ${ARG_Var.3} ${STR_UNSETTED}

StrCpy ${ARG_Var.2} ""

${endif}

SendMessage $HWND_TXT_MASK ${WM_SETTEXT} 0 "STR:${ARG_Var.3}"

WriteRegStr HKLM "${REG_ME_HOSTLIST}${ARG_Var.1}" "MASK" ${ARG_Var.2}

ReadINIStr ${ARG_Var.2} "${MUI_INIFILE}" "Field ${TXT_NETGATE}" "State"

StrCpy ${ARG_Var.3} "${ARG_Var.2}"

${if} ${ARG_Var.2} == ""

${orif} ${ARG_Var.2} == "${STR_UNSETTED}"

StrCpy ${ARG_Var.3} ${STR_UNSETTED}

StrCpy ${ARG_Var.2} ""

${endif}

SendMessage $HWND_TXT_NETGATE ${WM_SETTEXT} 0 "STR:${ARG_Var.3}"

WriteRegStr HKLM "${REG_ME_HOSTLIST}${ARG_Var.1}" "NETGATE" ${ARG_Var.2}

ReadINIStr ${ARG_Var.2} "${MUI_INIFILE}" "Field ${TXT_DNS}" "State"

StrCpy ${ARG_Var.3} "${ARG_Var.2}"

${if} ${ARG_Var.2} == ""

${orif} ${ARG_Var.2} == "${STR_UNSETTED}"

StrCpy ${ARG_Var.3} ${STR_UNSETTED}

StrCpy ${ARG_Var.2} ""

${endif}

SendMessage $HWND_TXT_DNS ${WM_SETTEXT} 0 "STR:${ARG_Var.3}"

WriteRegStr HKLM "${REG_ME_HOSTLIST}${ARG_Var.1}" "DNS" ${ARG_Var.2}

!macroend

!macro SetOneInfoTXT ARG_Var.temp ARG_Syb.hwnd ARG_Str.Mgs

ReadINIStr ${ARG_Var.temp} "${MUI_INIFILE}" "Field ${${ARG_Syb.hwnd}}" "State"

${if} ${ARG_Var.temp} == "${STR_UNSETTED}"

${orif} ${ARG_Var.temp} == ""

System::Call 'user32::MessageBeep(i) i (0x00000000)'

MessageBox::show MB_ICONHAND|MB_TOPMOST "信息不全" "$SYSDIRShell32.dll,200"

"无法更改 TCP/IP 配置,请你完整填写 [${ARG_Str.Mgs}] 信息。 "

"好的 (&O)"

Pop $R0

EnableWindow $HWND_${ARG_Syb.hwnd} 1

SendMessage $HWND_${ARG_Syb.hwnd} ${WM_SETTEXT} 0 "STR:"

System::Call "user32::SetFocus(i $HWND_${ARG_Syb.hwnd})i"

ReadINIStr ${ARG_Var.temp} "${MUI_INIFILE}" "Field ${LAB_AUTHOR}" "HWND"

ShowWindow ${ARG_Var.temp} 0

SetCtlColors ${ARG_Var.temp} 0xD95200 transparent

SendMessage ${ARG_Var.temp} ${WM_SETTEXT} 0 "STR:填写${ARG_Str.Mgs}"

ShowWindow ${ARG_Var.temp} 1

ReadINIStr ${ARG_Var.temp} "${MUI_INIFILE}" "Field ${BTN_UPDATE}" "HWND"

;; 显示[更新主机]

EnableWindow ${ARG_Var.temp} 1

ShowWindow ${ARG_Var.temp} 1

Abort

${endif}

!macroend

!macro CovertTxt4Edit ARG_Var.temp

ReadINIStr ${ARG_Var.temp} "${MUI_INIFILE}" "Field ${TXT_MAC}" "State"

${if} ${ARG_Var.temp} == "${STR_UNSETTED}"

SendMessage $HWND_TXT_MAC ${WM_SETTEXT} 0 "STR:"

${orif} ${ARG_Var.temp} == "${STR_ERRORFORMAT}"

ReadINIStr ${ARG_Var.temp} "${MUI_INIFILE}" "Field ${DL_HOST}" "State"

ReadRegStr ${ARG_Var.temp} HKLM "${REG_ME_HOSTLIST}${ARG_Var.temp}" "MAC"

SendMessage $HWND_TXT_MAC ${WM_SETTEXT} 0 "STR:${ARG_Var.temp}"

SendMessage $HWND_TXT_MAC ${EM_SETSEL} 255 0

System::Call "user32::SetFocus(i $HWND_TXT_MAC)i" ;;设置焦点

${endif}

ReadINIStr ${ARG_Var.temp} "${MUI_INIFILE}" "Field ${TXT_IP}" "State"

${if} ${ARG_Var.temp} == "${STR_UNSETTED}"

SendMessage $HWND_TXT_IP ${WM_SETTEXT} 0 "STR:"

${endif}

ReadINIStr ${ARG_Var.temp} "${MUI_INIFILE}" "Field ${TXT_MASK}" "State"

${if} ${ARG_Var.temp} == "${STR_UNSETTED}"

SendMessage $HWND_TXT_MASK ${WM_SETTEXT} 0 "STR:"

${endif}

ReadINIStr ${ARG_Var.temp} "${MUI_INIFILE}" "Field ${TXT_NETGATE}" "State"

${if} ${ARG_Var.temp} == "${STR_UNSETTED}"

SendMessage $HWND_TXT_NETGATE ${WM_SETTEXT} 0 "STR:"

${endif}

ReadINIStr ${ARG_Var.temp} "${MUI_INIFILE}" "Field ${TXT_DNS}" "State"

${if} ${ARG_Var.temp} == "${STR_UNSETTED}"

SendMessage $HWND_TXT_DNS ${WM_SETTEXT} 0 "STR:"

${endif}

!macroend

!macro ShowNotePad ARG_Var.1 ARG_Var.2

ReadINIStr ${ARG_Var.1} "${MUI_INIFILE}" "Field ${TXT_NOTEPAD}" "HWND"

ReadINIStr ${ARG_Var.2} "${MUI_INIFILE}" "Field ${TXT_NOTEPAD}" "State"

${if} ${ARG_Var.2} == ""

SendMessage ${ARG_Var.1} ${WM_SETTEXT} 0 "STR:${STR_NOTEPAD_HELP}"

SendMessage ${ARG_Var.1} ${EM_SETSEL} 255 0

${endif}

ShowWindow ${ARG_Var.1} 1

System::Call "user32::SetFocus(i ${ARG_Var.1})i" ;;设置焦点

ReadINIStr ${ARG_Var.1} "${MUI_INIFILE}" "Field ${GB_GLOBAL}" "HWND"

SendMessage ${ARG_Var.1} ${WM_SETTEXT} 0 "STR:${STR_NOTEPAD}" ;;更改标签字符

!macroend

###############

# 入口初始化函数...

###############

Function .onInit

;; 窗体互斥处理...

SYSTEM::Call "kernel32::CreateMutexA(i 0, i 0, t '${STR_CAPTION}') i .r0 ?e"

Pop $0

${if} $0 != 0

StrLen $0 "${STR_CAPTION}"

IntOp $0 $0 + 1

loop:

FindWindow $1 '#32770' '' 0 $1

${if} $1 != 0

SYSTEM::Call "user32::GetWindowText(i r1, t .r2, i r0) i."

StrCmp $2 "${STR_CAPTION}" 0 loop

SYSTEM::Call "user32::SetForegroundWindow(i r1) i."

${endif}

ShowWindow $1 2

ShowWindow $1 1

Abort

${endif}

;;---------------------

InitPluginsDir

ClearErrors

ReadRegStr $R0 HKLM "SOFTWAREMicrosoftWindows NTCurrentVersion" CurrentVersion

IfErrors 0 Pass

System::Call 'user32::MessageBeep(i) i (0x00000110)'

Messagebox::show MB_ICONHAND|MB_TOPMOST "LanInfoMan" "0,103"

"您的 Windows 版本过低,本工具只运行于 Win2000以上的 Windows 平台中。 "

"确定 (&O)"

Pop $R0

Quit

Pass:

${Var} COUNTER_HOSTNUM

StrCpy $COUNTER_HOSTNUM 0 ;;初始化主机计数器

File /oname=${MUI_INIFILE} "${RES_INIFILE}"

File /oname=${MUI_ICOFILE} "${RES_ICOFILE}"

WriteINIStr "${MUI_INIFILE}" "Field ${LAB_AUTHOR}" "Text" "${STR_AUTHOR}"

WriteINIStr "${MUI_INIFILE}" "Field ${ICON_HOST}" "Text" "${MUI_ICOFILE}"

;;------------------------------------

ReadRegStr $R0 HKCR "Hlbackupini.file" ""

${if} $R0 != "主机列表备份文件"

WriteRegStr HKCR ".hlbf" "" "Hlbackupini.file"

WriteRegStr HKCR "Hlbackupini.file" "" "主机列表备份文件"

WriteRegStr HKCR "Hlbackupini.fileDefaultIcon" "" "$SYSDIRShell32.dll,-178"

WriteRegStr HKCR "Hlbackupini.fileshellopen" "" ""

WriteRegStr HKCR "Hlbackupini.fileshellopencommand" ""

"$"$PROGRAMFILESWindows NTAccessorieswordpad.exe$" $"%1$""

System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'

${endif}

;;------------------------------------

Call GetNetCardsInfo

Call InitNetCardInfo

ReadINIStr $0 ${MUI_INIFILE} "Settings" NetCardNum

${if} $0 <= 0

System::Call 'user32::MessageBeep(i) i (0x00000110)'

Messagebox::show MB_ICONHAND|MB_TOPMOST "LanInfoMan" "0,103"

"没有检测到本机的活动网卡信息,请检查网卡是否正确安装。 "

" 我晕 (&F) "

Quit

${endif}

ReadRegStr $0 HKLM "${REG_ME}Settings" "NetCardSelected"

ClearErrors

ReadINIStr $1 ${MUI_INIFILE} "$0" "IP"

IfErrors +2

WriteINIStr "${MUI_INIFILE}" "Field ${DL_NETCARD}" "State" "$0"

Call InitHostList

Call InitLastHostInfo

WriteINIStr "${MUI_INIFILE}" "Field ${LAB_HELP}" "Text" "${STR_START_HELP}"

FunctionEnd

Function ShowCustom

InstallOptions::initDialog /NOUNLOAD "${MUI_INIFILE}"

Pop $0 ;IO页面窗体句柄

${Var} HWND_TXT_HOST

${Var} HWND_TXT_MAC

${Var} HWND_TXT_IP

${Var} HWND_TXT_MASK

${Var} HWND_TXT_NETGATE

${Var} HWND_TXT_DNS

${Var} HWND_GB_SELHOST

ReadINIStr $HWND_TXT_HOST "${MUI_INIFILE}" "Field ${TXT_HOST}" "HWND"

ReadINIStr $HWND_TXT_MAC "${MUI_INIFILE}" "Field ${TXT_MAC}" "HWND"

ReadINIStr $HWND_TXT_IP "${MUI_INIFILE}" "Field ${TXT_IP}" "HWND"

ReadINIStr $HWND_TXT_MASK "${MUI_INIFILE}" "Field ${TXT_MASK}" "HWND"

ReadINIStr $HWND_TXT_NETGATE "${MUI_INIFILE}" "Field ${TXT_NETGATE}" "HWND"

ReadINIStr $HWND_TXT_DNS "${MUI_INIFILE}" "Field ${TXT_DNS}" "HWND"

ReadINIStr $HWND_GB_SELHOST "${MUI_INIFILE}" "Field ${GB_SELHOST}" "HWND"

ReadINIStr $2 "${MUI_INIFILE}" "Field ${TXT_NOTEPAD}" "HWND"

SetCtlColors $2 0x808080 0xFEFEFE

!insertmacro EnableTXTEdit $2 0

${if} $COUNTER_HOSTNUM > 0

!insertmacro EnableGlobalBtn $2 1

${else}

!insertmacro EnableGlobalBtn $2 0

ReadINIStr $2 "${MUI_INIFILE}" "Field ${TXT_NOTEPAD}" "HWND"

ShowWindow $2 0

ReadINIStr $2 "${MUI_INIFILE}" "Field ${GB_GLOBAL}" "HWND"

SendMessage $2 ${WM_SETTEXT} 0 "STR:帮助信息"

ReadINIStr $2 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

EnableWindow $2 0

ReadINIStr $2 "${MUI_INIFILE}" "Field ${LAB_HELP}" "HWND"

ShowWindow $2 1

SetCtlColors $2 0x6C6C6C transparent

;CreateFont $1 "Arial" "8" "700"

;SendMessage $2 ${WM_SETFONT} $1 0

${endif}

!insertmacro EditCtrStyle $HWND_TXT_MAC ${UPPERCASE}

CreateFont $0 "宋体" "9"

SendMessage $HWND_TXT_MAC ${WM_SETFONT} $0 0

InstallOptions::show

Pop $0

FunctionEnd

Function LeaveCustom

ReadINIStr $0 "${MUI_INIFILE}" "Settings" "State"

${Switch} $0

##############################################################

${Case} ${DL_NETCARD}

;MessageBox MB_OK "DL_NETCARD" # 按下 [选择网卡] 下拉列表

##############################################################

ReadINIStr $1 "${MUI_INIFILE}" "Field ${DL_NETCARD}" "State"

WriteRegStr HKLM "${REG_ME}Settings" "NetCardSelected" $1

!insertmacro EnableTXTEdit $2 0 ;;禁用编辑文本框

${if} $COUNTER_HOSTNUM > 0

!insertmacro EnableGlobalBtn $2 1

${else}

!insertmacro EnableGlobalBtn $2 0

ReadINIStr $2 "${MUI_INIFILE}" "Field ${TXT_NOTEPAD}" "HWND"

ShowWindow $2 0

ReadINIStr $2 "${MUI_INIFILE}" "Field ${GB_GLOBAL}" "HWND"

SendMessage $2 ${WM_SETTEXT} 0 "STR:帮助信息"

ReadINIStr $2 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

EnableWindow $2 0

ReadINIStr $2 "${MUI_INIFILE}" "Field ${LAB_HELP}" "HWND"

ShowWindow $2 1

SetCtlColors $2 0x6C6C6C transparent

;CreateFont $1 "Arial" "8" "700"

;SendMessage $2 ${WM_SETFONT} $1 0

${endif}

!insertmacro ShowReg2Txt $1 $2 $3

${Break}

##############################################################

${Case} ${DL_HOST}

;MessageBox MB_OK "DL_HOST" # 按下 [主机标识] 下拉列表

##############################################################

ReadINIStr $1 "${MUI_INIFILE}" "Field ${DL_HOST}" "State"

WriteRegStr HKLM "${REG_ME_HOSTLIST}" "LastHost" "$1"

!insertmacro EnableGlobalBtn $2 1

!insertmacro EnableTXTEdit $2 0 ;;禁用编辑文本框

!insertmacro ShowReg2Txt $1 $2 $3

${Break}

##############################################################

${Case} ${BTN_EDIT_HOST}

;MessageBox MB_OK "BTN_EDIT_HOST" # 按下 [编辑] 按钮

##############################################################

ReadINIStr $2 "${MUI_INIFILE}" "Field ${BTN_EXPORT_HOSTLIST}" "HWND"

WriteINIStr "${MUI_INIFILE}" "Field ${BTN_EXPORT_HOSTLIST}" "Text" "放弃编辑主机(&C)"

SendMessage $2 ${WM_SETTEXT} 0 "STR:放弃编辑主机(&C)"

!insertmacro ShowNotePad $2 $1

!insertmacro EnableGlobalBtn $2 0 ;;隐藏全局操作按钮区-->显示临时编辑帮助区

!insertmacro EnableTXTEdit $2 1 ;;可用编辑文本框

!insertmacro CovertTxt4Edit $2 ;---检测转化文本字符显示

ReadINIStr $2 "${MUI_INIFILE}" "Field ${BTN_ADD}" "HWND"

;;隐藏[添加到主机列表]

ShowWindow $2 0

ReadINIStr $2 "${MUI_INIFILE}" "Field ${BTN_UPDATE}" "HWND"

;; 可用[更新主机]

EnableWindow $2 1

ShowWindow $2 1

ReadINIStr $2 "${MUI_INIFILE}" "Field ${BTN_DELETE}" "HWND"

;; 可用[删除主机]

ShowWindow $2 1

${if} $COUNTER_HOSTNUM > 0 ;有主机信息

EnableWindow $2 1

${else}

EnableWindow $2 0

${endif}

Abort

${Break} ;; :)

##############################################################

${Case} ${BTN_NEW_HOST}

;MessageBox MB_OK "BTN_NEW_HOST" # 按下 [新建] 按钮

##############################################################

ReadINIStr $2 "${MUI_INIFILE}" "Field ${BTN_EXPORT_HOSTLIST}" "HWND"

WriteINIStr "${MUI_INIFILE}" "Field ${BTN_EXPORT_HOSTLIST}" "Text" "放弃新建主机(&C)"

SendMessage $2 ${WM_SETTEXT} 0 "STR:放弃新建主机(&C)"

SendMessage $HWND_TXT_HOST ${WM_SETTEXT} 0 "STR:"

SendMessage $HWND_TXT_MAC ${WM_SETTEXT} 0 "STR:"

SendMessage $HWND_TXT_IP ${WM_SETTEXT} 0 "STR:"

ReadINIStr $4 ${MUI_INIFILE} "Field ${DL_NETCARD}" State

ReadINIStr $3 ${MUI_INIFILE} "$4" "IP"

StrCpy $1 "${STR_NOTEPAD_HELP}$r$n可能有用的参考信息:$t IP 地址:$3$r$n"

StrCpy $3 $3 -3

SendMessage $HWND_TXT_IP ${WM_SETTEXT} 0 "STR:$3"

ReadINIStr $3 ${MUI_INIFILE} "$4" "MASK"

SendMessage $HWND_TXT_MASK ${WM_SETTEXT} 0 "STR:$3"

StrCpy $1 "$1子网掩码:$3"

ReadINIStr $3 ${MUI_INIFILE} "$4" "NETGATE"

SendMessage $HWND_TXT_NETGATE ${WM_SETTEXT} 0 "STR:$3"

StrCpy $1 "$1 默认网关:$3"

ReadINIStr $3 ${MUI_INIFILE} "$4" "DNS"

SendMessage $HWND_TXT_DNS ${WM_SETTEXT} 0 "STR:$3"

StrCpy $1 "$1 首选DNS :$3"

;MessageBox MB_OK "$1"

ReadINIStr $2 "${MUI_INIFILE}" "Field ${TXT_NOTEPAD}" "State"

${if} $2 == "${STR_NOTEPAD_HELP}"

${orif} $2 == ""

ReadINIStr $2 "${MUI_INIFILE}" "Field ${TXT_NOTEPAD}" "HWND"

;SendMessage $2 ${WM_SETTEXT} 0 "STR:${STR_NOTEPAD_HELP}$r$n$r$n$1$r$n"

SendMessage $2 ${WM_SETTEXT} 0 "STR:$1"

;SendMessage $2 ${EM_SETSEL} 255 0

${endif}

ShowWindow $2 1

ReadINIStr $2 "${MUI_INIFILE}" "Field ${BTN_UPDATE}" "HWND"

;; 隐藏[更新主机]

ShowWindow $2 0

EnableWindow $2 0

ReadINIStr $2 "${MUI_INIFILE}" "Field ${BTN_DELETE}" "HWND"

;; 隐藏[删除主机]

ShowWindow $2 0

EnableWindow $2 0

ReadINIStr $2 "${MUI_INIFILE}" "Field ${BTN_ADD}" "HWND"

;; 显示[添加到主机列表]

ShowWindow $2 1

EnableWindow $2 1

!insertmacro EnableTXTEdit $2 1 ;;可用编辑文本框

!insertmacro EnableGlobalBtn $2 0 ;;隐藏全局操作按钮区-->显示临时编辑帮助区

System::Call "user32::SetFocus(i $HWND_TXT_HOST)i" ;;设置焦点

Abort ;${Break}

${Break}

##############################################################

${Case} ${BTN_IMPORT_HOSTLIST}

;MessageBox MB_OK "BTN_IMPORT_HOSTLIST" # 按下 [导入备份列表] 按钮

##############################################################

${Do}

;FindWindow $4 '#32770' '${STR_CAPTION}'

;ShowWindow $4 0

Dialogs::Open "${STR_OPEN_FILE_EXT}" 1 "${STR_OPEN_CAPTION}" $EXEDIR ${VAR_OPENSAVE_ID}

${if} ${VAR_OPENSAVE} == 0

${ExitDo}

${else}

System::Call 'kernel32::_lopen(t "${VAR_OPENSAVE}", i 0) i .r1'

System::Call 'kernel32::GetFileSize(i $1, i) i .r2'

IntOp $2 $2 / 1024

System::Call 'kernel32::_lclose(i $1) i'

${if} $2 < 512

ReadINIStr $1 ${VAR_OPENSAVE} "Main" "Type"

${if} $1 == "HostList Backup File"

System::Call 'user32::MessageBeep(i) i (0x00000000)'

Messagebox::show MB_DEFBUTTON2|MB_TOPMOST "导入确认"

"$SYSDIRShell32.dll,146"

"你确定要从备份文件 $"${VAR_OPENSAVE}$" 中导入主机列表吗? "

"确定 (&Y)" "不要 (&N)"

Pop $R0

${if} $R0 != "1"

Abort

${endif}

Call ImprotHostlist2Reg

;ShowWindow $4 1

Pop $2 ;;返回导入主机数

${if} $2 > 0 ;;导入了新主机

!insertmacro EnableGlobalBtn $2 1

!insertmacro EnableTXTEdit $2 0 ;;禁用编辑文本框

ReadINIStr $1 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

EnableWindow $1 1

SendMessage $1 ${CB_SHOWDROPDOWN} 1 1

${endif}

;;开始转化导入

${ExitDo}

${endif}

${endif}

System::Call 'user32::MessageBeep(i) i (0x00000101)'

Messagebox::show MB_ICONHAND|MB_TOPMOST "添加到主机列表" "$SYSDIRShell32.dll,200"

"${MSG_OPEN_ERROR} "

"确定 (&O)"

Pop $R0

${endif}

${Loop}

!insertmacro ShowReg2Txt $1 $2 $3

${Break}

##############################################################

${Case} ${BTN_EXPORT_HOSTLIST}

;MessageBox MB_OK "BTN_EXPORT_HOSTLIST" # 按下 [备份主机列表] 按钮

##############################################################

ReadINIStr $4 "${MUI_INIFILE}" "Field ${BTN_EXPORT_HOSTLIST}" Text

StrCpy $4 "$4" 4

${if} $4 == "放弃"

!insertmacro EnableTXTEdit $2 0 ;;禁用编辑文本框

${if} $COUNTER_HOSTNUM < 1

ReadINIStr $2 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

EnableWindow $2 0

ReadINIStr $2 "${MUI_INIFILE}" "Field ${GB_GLOBAL}" "HWND"

SendMessage $2 ${WM_SETTEXT} 0 "STR:帮助信息"

ReadINIStr $2 "${MUI_INIFILE}" "Field ${LAB_HELP}" "HWND"

ShowWindow $2 1

SetCtlColors $2 0x004040 transparent

ReadINIStr $2 "${MUI_INIFILE}" "Field ${TXT_NOTEPAD}" "HWND"

ShowWindow $2 0

${else}

!insertmacro EnableGlobalBtn $2 1

${endif}

${else}

${if} $COUNTER_HOSTNUM < 1

System::Call 'user32::MessageBeep(i) i (0x00000001)'

MessageBox::show MB_ICONHAND|MB_TOPMOST "备份主机列表" "$SYSDIRshell32.dll,234"

"当前没有任何主机信息,无需备份。 "

"确定 (&O)"

Pop $R0

Abort

${endif}

FindWindow $4 '#32770' '${STR_CAPTION}'

Dialogs::Save "${STR_SAVE_FILE_EXT}" 1 "${STR_SAVE_CAPTION}" $EXEDIR ${VAR_OPENSAVE_ID}

${if} ${VAR_OPENSAVE} == 0

Abort

${else}

StrCpy $1 "${VAR_OPENSAVE}" "" -5

StrCpy $2 $1 "" -4

${if} $2 == ".reg"

ExecWait `"$WINDIRRegedit.exe" /s /e "${VAR_OPENSAVE}" "${REG_ME_HOSTLIST_FULL}"`

ShowWindow $4 0

System::Call 'user32::MessageBeep(i) i (0x00000001)'

MessageBox::show MB_ICONHAND|MB_TOPMOST "备份为REG格式" "$SYSDIRshell32.dll,178"

"已成功将当前列表中共 $COUNTER_HOSTNUM 个主机信息备份到指定的注册表文件中。 "

"确定 (&O)"

Pop $R0

ShowWindow $4 1

Abort

${else}

${if} $1 != ".hlbf"

StrCpy ${VAR_OPENSAVE} "${VAR_OPENSAVE}.hlbf"

${endif}

ShowWindow $4 0

Call SaveHostlist2INI

System::Call 'user32::MessageBeep(i) i (0x00000001)'

MessageBox::show MB_ICONHAND|MB_TOPMOST "备份完成" "$SYSDIRshell32.dll,178"

"已成功将当前列表中共 $COUNTER_HOSTNUM 个主机信息保存到指定的文件中。 "

"确定 (&O)"

Pop $R0

ShowWindow $4 1

${endif}

${endif}

${endif}

;ShowWindow $1 1

!insertmacro ShowReg2Txt $1 $2 $3

${Break}

##############################################################

${Case} ${BTN_DELETE}

;MessageBox MB_OK "BTN_DELETE" # 按下 [删除主机] 按钮

##############################################################

ReadINIStr $3 "${MUI_INIFILE}" "Field ${DL_HOST}" "State"

System::Call 'user32::MessageBeep(i) i (0x00000000)'

MessageBox::show MB_ICONHAND|MB_TOPMOST "删除确认" "$SYSDIRShell32.dll,33"

"你确定删除主机标识 $3 对应的主机信息吗? "

"确定 (&O)" "取消 (&C)"

Pop $R0

${if} $R0 != 1

Abort

${endif}

DeleteRegKey HKLM "${REG_ME_HOSTLIST}$3"

DeleteRegValue HKLM "${REG_ME_HOSTLIST}" "LastHost"

!insertmacro EnableTXTEdit $2 0 ;;禁用编辑文本框

ReadINIStr $1 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

SendMessage $1 ${CB_GETCURSEL} "" "" $2

SendMessage $1 ${CB_DELETESTRING} "$2" ""

!insertmacro AddHostNum -1

${if} $COUNTER_HOSTNUM < 1

;!insertmacro EnableGlobalBtn $2 1

ReadINIStr $2 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

EnableWindow $2 0

ReadINIStr $2 "${MUI_INIFILE}" "Field ${GB_GLOBAL}" "HWND"

SendMessage $2 ${WM_SETTEXT} 0 "STR:帮助信息"

ReadINIStr $2 "${MUI_INIFILE}" "Field ${LAB_HELP}" "HWND"

SetCtlColors $2 0x004040 transparent

ShowWindow $2 1

ReadINIStr $2 "${MUI_INIFILE}" "Field ${TXT_NOTEPAD}" "HWND"

ShowWindow $2 0

${else}

!insertmacro EnableGlobalBtn $2 1

${endif}

Call ResetSelectHost

!insertmacro ShowReg2Txt $1 $2 $3

${Break}

##############################################################

${Case} ${BTN_UPDATE}

;MessageBox MB_OK "BTN_UPDATE" # 按下 [保存更新] 按钮

##############################################################

ReadINIStr $3 "${MUI_INIFILE}" "Field ${TXT_HOST}" "State"

${if} $3 == ""

System::Call 'user32::MessageBeep(i) i (0x00000001)'

MessageBox::show MB_ICONHAND|MB_TOPMOST "保存更新" "$SYSDIRshell32.dll,220"

"请填写主机标识。 "

"确定(&O)"

Pop $R0

System::Call "user32::SetFocus(i $HWND_TXT_HOST)i"

Abort

${else}

${if} $COUNTER_HOSTNUM < 1

ReadINIStr $1 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

SendMessage $1 ${CB_GETCURSEL} "" "" $2

SendMessage $1 ${CB_DELETESTRING} "$2" "" ;;删除旧主机标识

!insertmacro AddHostNum 1

DeleteINIStr "${MUI_INIFILE}" "Field ${DL_HOST}" "State"

${endif}

ReadINIStr $4 "${MUI_INIFILE}" "Field ${DL_HOST}" "State"

${if} "$3" == "$4"

DeleteRegKey HKLM "${REG_ME_HOSTLIST}$4"

${else} ;;标识改动

ReadRegStr $1 HKLM "${REG_ME_HOSTLIST}$3" ""

${if} $1 == "Setted" ;;已有标识

System::Call 'user32::MessageBeep(i) i (0x00000001)'

MessageBox::show MB_ICONHAND|MB_DEFBUTTON2|MB_TOPMOST "保存更新"

"$SYSDIRshell32.dll,220"

"主机标识 $"$3$" 已被占用,保存更新将会覆盖原主机信息,是否继续? "

"是 (&Y)" "否 (&N)"

Pop $R0

${if} $R0 != 1 ;;放弃覆盖

SendMessage $HWND_TXT_HOST ${EM_SETSEL} 255 0

System::Call "user32::SetFocus(i $HWND_TXT_HOST)i"

Abort

${endif}

;;要覆盖

ReadINIStr $1 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

SendMessage $1 ${CB_SELECTSTRING} 0 "STR:$3"

${else} ;;新的标识

DeleteRegKey HKLM "${REG_ME_HOSTLIST}$4" ;;删除旧主机

ReadINIStr $1 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

SendMessage $1 ${CB_GETCURSEL} "" "" $2

SendMessage $1 ${CB_DELETESTRING} "$2" "" ;;删除旧主机标识

SendMessage $1 ${CB_ADDSTRING} 0 "STR:$3" ;;添加新标识

SendMessage $1 ${CB_SELECTSTRING} 0 "STR:$3"

${endif}

${endif}

!insertmacro EnableGlobalBtn $2 1

!insertmacro EnableTXTEdit $2 0 ;;禁用编辑文本框

!insertmacro SaveTxt2Reg $3 $2 $1 ;;保存并处理文本显示

${endif}

Abort ; ${Break}

##############################################################

${Case} ${BTN_ADD}

;MessageBox MB_OK "BTN_ADD" # 按下 [添加到主机列表] 按钮

##############################################################

ReadINIStr $3 "${MUI_INIFILE}" "Field ${TXT_HOST}" "State"

${if} $3 == "" ;没填写主机标识

System::Call 'user32::MessageBeep(i) i (0x00000001)'

Messagebox::show MB_ICONHAND|MB_TOPMOST "添加到主机列表" "$SYSDIRShell32.dll,176"

"请先为当前主机填写一个主机标识,以方便以后在主机标识下拉菜单中选择。 "

"确定(&O)"

Pop $R0

System::Call "user32::SetFocus(i $HWND_TXT_HOST)i"

Abort

${else} ;;开始添加到操作

ReadRegStr $1 HKLM "${REG_ME_HOSTLIST}$3" ""

${if} $1 == "Setted"

ReadINIStr $1 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

SendMessage $1 ${CB_SELECTSTRING} 0 "STR:$3"

System::Call 'user32::MessageBeep(i) i (0x00000001)'

MessageBox::show MB_ICONHAND|MB_DEFBUTTON2|MB_TOPMOST "添加到主机列表"

"$SYSDIRshell32.dll,176"

"主机标识 $"$3$" 已被占用,是否将其覆盖? "

"是 (&Y)" "否 (&N)"

Pop $R0

${if} $R0 != 1 ;;放弃覆盖

SendMessage $HWND_TXT_HOST ${EM_SETSEL} 255 0

System::Call "user32::SetFocus(i $HWND_TXT_HOST)i"

Abort

${endif}

;;覆盖

${else}

${if} $COUNTER_HOSTNUM < 1

ReadINIStr $1 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

SendMessage $1 ${CB_GETCURSEL} "" "" $2

SendMessage $1 ${CB_DELETESTRING} "$2" "" ;;删除旧主机标识

${endif}

!insertmacro AddHostNum 1 ;;全局计数器+1

ReadINIStr $1 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

SendMessage $1 ${CB_ADDSTRING} 0 "STR:$3"

SendMessage $1 ${CB_SELECTSTRING} -1 "STR:$3"

${endif}

;;同步到窗体信息INI文件

WriteINIStr ${MUI_INIFILE} "Field ${DL_HOST}" State "$3"

!insertmacro EnableGlobalBtn $2 1

!insertmacro EnableTXTEdit $2 0 ;;禁用编辑文本框

!insertmacro SaveTxt2Reg $3 $2 $1 ;;保存并处理文本显示

${endif}

!insertmacro ShowReg2Txt $1 $2 $3

${Break}

##############################################################

${Case} ${BTN_CHANGE_MAC}

;MessageBox MB_OK "BTN_CHANGE_MAC" # 按下 [修改MAC] 按钮

##############################################################

Call GetNetCardsInfo

ReadINIStr $2 "${MUI_INIFILE}" "Field ${TXT_MAC}" "State"

StrCpy $4 "更改为 $"$2$""

${if} $2 == "${STR_UNSETTED}"

${orif} $2 == "${STR_ERRORFORMAT}"

StrCpy $2 ""

StrCpy $4 "还原为 $"网卡缺省值$""

${endif}

ReadINIStr $1 "${MUI_INIFILE}" "Field ${DL_NETCARD}" "State"

ReadINIStr $1 "${MUI_INIFILE}" "$1" "RegKeyIndex"

ReadRegStr $3 HKLM "${REG_NETWORK_ADAPTERS}$1" "NetworkAddress"

Check:

${if} $3 == $2

System::Call 'user32::MessageBeep(i) i (0x00000002)'

MessageBox::show MB_ICONHAND|MB_TOPMOST "提示" "0,103"

"当前 MAC 信息 已经是你要修改的值,无需重复修改。$r$n$r$n提示:

你可以 [开启/禁用网络连接] 以刷新 MAC 信息。 $r$n"

"哦 (&O)"

Pop $R0

Abort

${orif} $3 == ""

ReadRegStr $3 HKLM "${REG_NETWORK_ADAPTERS}$1" "NetCfgInstanceId"

ClearErrors

ReadINIStr $3 ${MUI_INIFILE} "$3" "USING MAC"

IfErrors +2

Goto Check ;;再检测一次

StrCpy $3 "网卡缺省值"

${endif}

System::Call 'user32::MessageBeep(i) i (0x00000001)'

MessageBox::show MB_ICONHAND|MB_DEFBUTTON2|MB_TOPMOST "修改 MAC 确认"

"$SYSDIRshell32.dll,24"

"你确定要将当前 MAC 信息 $"$3$" $4 吗?"

"确定 (&O)" "不要 (&C)"

Pop $R0

${if} $R0 != 1 ;;不修改

Abort

${endif}

${if} $2 == ""

DeleteRegValue HKLM "${REG_NETWORK_ADAPTERS}$1" "NetworkAddress"

${else}

WriteRegStr HKLM "${REG_NETWORK_ADAPTERS}$1" "NetworkAddress" "$2"

${endif}

System::Call 'user32::MessageBeep(i) i (0x00000001)'

MessageBox::show MB_ICONHAND|MB_DEFBUTTON2|MB_TOPMOST "MAC 修改成功"

"$SYSDIRshell32.dll,137"

"MAC 信息已经成功更改,是否要立刻 [开启/禁用网络连接] 以生效更新? "

"是 (&Y)" "否 (&N)"

Pop $R0

${if} $R0 == 1

FindWindow $4 '#32770' '${STR_CAPTION}'

ShowWindow $4 2

StrCpy $R0 "ExecTwice"

Call RefreshConnection

StrCpy $R0 ""

ShowWindow $4 1

${endif}

Abort

;${Break}

##############################################################

${Case} ${BTN_CHANGE_IP}

;MessageBox MB_OK "BTN_CHANGE_MAC" # 按下 [修改IP] 按钮

##############################################################

ReadINIStr $2 ${MUI_INIFILE} "Field ${DL_NETCARD}" State

ReadINIStr $2 ${MUI_INIFILE} "$2" "InstanceId"

ReadRegStr $3 HKLM "${REG_NETWORK_CONNECTIONS}$2Connection" "Name"

ReadINIStr $2 "${MUI_INIFILE}" "Field ${DL_HOST}" "State"

System::Call 'user32::MessageBeep(i) i (0x00000001)'

MessageBox::show MB_ICONHAND|MB_DEFBUTTON2|MB_TOPMOST "TCP/IP信息修改确认" "0,103"

"确定要将主机 “$2” 的 TCP/IP 信息修改到 “$3” 属性设置吗? "

"是 (&Y)" "否 (&N)"

Pop $R0

${if} $R0 != 1

Abort

${endif}

StrCpy $1 "netsh interface ip set address $"$3$" static"

!insertmacro SetOneInfoTXT $2 "TXT_IP" " IP 地址"

StrCpy $1 "$1 $2"

!insertmacro SetOneInfoTXT $2 "TXT_MASK" "子网掩码"

StrCpy $1 "$1 $2"

!insertmacro SetOneInfoTXT $2 "TXT_NETGATE" "默认网关"

StrCpy $1 "$1 $2 1"

!insertmacro SetOneInfoTXT $2 "TXT_DNS" "首选DNS"

StrCpy $2 "netsh interface ip set dns $"$3$" static $2 primary"

;;最小化窗口,防止用户等待乱点

FindWindow $4 '#32770' '${STR_CAPTION}'

ShowWindow $4 2

Sleep 100

Banner::show /NOUNLOAD "正在更改当前网络连接的 TCP/IP 信息,请稍等……"

nsExec::ExecToStack /TIMEOUT=30000 "$1"

Pop $3

StrCmp $3 "timeout" 0 +3

StrCpy $3 "执行超时,请重试! "

Goto Fail

Pop $3

StrCpy $3 $3 -4

${if} $3 == "Ok."

${orif} $3 == "确定。"

nsExec::ExecToStack /TIMEOUT=20000 "$2"

Pop $3

StrCmp $3 "timeout" 0 +3

StrCpy $3 "执行超时,请重试! "

Goto DNS_Fail

Pop $3

StrCpy $3 $3 -4

${if} $3 == "Ok."

${orif} $3 == "确定。"

Banner::getWindow /NOUNLOAD

Pop $R0

ShowWindow $R0 0

ReadINIStr $2 ${MUI_INIFILE} "Field ${DL_NETCARD}" State

Push $2

Call GetTcpIpInfo

System::Call 'user32::MessageBeep(i) i (0x00000001)'

MessageBox::show MB_ICONHAND|MB_DEFBUTTON2|MB_TOPMOST "修改 IP 成功" "$SYSDIRshell32.dll,14"

"所选主机的 TCP/IP 信息 已被成功应用到指定的网络连接。 "

"谢谢 (&T)"

Pop $R0

ShowWindow $4 1

Banner::destroy

Abort

${else}

DNS_Fail:

Banner::getWindow /NOUNLOAD

Pop $R0

ShowWindow $R0 0

System::Call 'user32::MessageBeep(i) i (0x00000001)'

MessageBox::show MB_ICONHAND|MB_DEFBUTTON2|MB_TOPMOST "更改失败" "$SYSDIRshell32.dll,18"

"DNS 更改失败:$3 "

"确定 (&O)"

Pop $R0

ShowWindow $4 1

Banner::destroy

Abort

${endif}

${endif}

Fail:

Banner::getWindow /NOUNLOAD

Pop $R0

ShowWindow $R0 0

System::Call 'user32::MessageBeep(i) i (0x00000001)'

MessageBox::show MB_ICONHAND|MB_DEFBUTTON2|MB_TOPMOST "更改失败" "$SYSDIRshell32.dll,18"

"更改失败:$3 "

"确定 (&O)"

Pop $R0

ShowWindow $4 1

Banner::destroy

Abort

;${Break}

##############################################################

${Case} ${BTN_MINIMIZE}

;MessageBox MB_OK "BTN_MINIMIZE" # 按下 [最小化] 按钮

##############################################################

FindWindow $4 '#32770' '${STR_CAPTION}'

ShowWindow $4 2

${Break}

##############################################################

${Case} ${BTN_RF_CONNECTION}

;MessageBox MB_OK "BTN_RF_CONNECTION" # 按下 [开启禁用网络] 按钮

##############################################################

Call RefreshConnection

Abort

;${Break}

${EndSwitch}

Abort ;;

;;页面消息回调函数结束

FunctionEnd ;LeaveCustom

##############################################################################

##############################################################

# 功能 -- 获取当前 TCP/IP 信息

;!macro GetRegMultiStr --(预先)子宏

;Function SubCallBack --(预先)子函数

;Function GetTcpIpInfo --主功能

##############################################################

!macro GetRegMultiStr Arg_reg.value Arg_ini.value

StrCpy $3 "${Arg_ini.value}"

GetFunctionAddress $2 SubCallBack

${ReadRegMultiStr} ${HKLM} "${REG_NETWORK_TCPIP}$1" "${Arg_reg.value}" $2

ClearErrors

!macroend

Function SubCallBack

Exch $2

${if} $2 == ""

GetErrorLevel $2

;MessageBox MB_OK "Error Level: $2"

${else}

;MessageBox MB_OK "$3: $2"

WriteINIStr ${MUI_INIFILE} "$0" "$3" "$2"

${endif}

Pop $2

FunctionEnd ;SubCallBack

Function GetTcpIpInfo

Exch $0

Push $1

Push $2

Push $3

ReadINIStr $1 ${MUI_INIFILE} "$0" "InstanceId"

!insertmacro GetRegMultiStr "IPAddress" "IP"

!insertmacro GetRegMultiStr "SubnetMask" "MASK"

!insertmacro GetRegMultiStr "DefaultGateway" "NETGATE"

ReadRegStr $2 HKLM "${REG_NETWORK_TCPIP}$1" "NameServer"

StrCpy $1 0

${Do}

StrCpy $3 $2 1 $1

${IfThen} $3 == ',' ${|} ${ExitDo} ${|}

IntOp $1 $1 + 1

${LoopUntil} $3 == ""

StrCpy $2 $2 $1

WriteINIStr ${MUI_INIFILE} "$0" "DNS" "$2"

Pop $3

Pop $2

Pop $1

Pop $0

FunctionEnd ;GetTcpIpInfo

##############################################################

# 功能 -- 初始化数据

# Function InitNetCardInfo

# Function InitHostList

# Function InitLastHostInfo

##############################################################

!define STR_SEPARATOR ``

Function GetNetCardsInfo

Push $0

Push $1

Push $2

Push $3

Push $4

Push $5

Push $6

Push $7

System::Alloc 4096

Pop $3

System::Call 'iphlpapi::GetAdaptersInfo(i r3r2, *l 4096 r1) i.r0'

StrCmp $0 0 0 finish

loop:

StrCmp $2 0 finish

System::Call '*$2(i.r2,i,&t260.r4, &t132 0, i 0, l.r5)'

System::Int64Op $5 % 0x100000000

Pop $6

IntFmt $6 "%08X" $6

System::Int64Op $5 - $6

Pop $7

System::Int64Op $7 / 0x100000000

Pop $7

IntFmt $7 "%04X" $7

StrCpy $7 "$7$6"

StrCpy $1 $7 2 10

StrCpy $0 $1

StrCpy $1 $7 2 8

StrCpy $0 '$0${STR_SEPARATOR}$1'

StrCpy $1 $7 2 6

StrCpy $0 '$0${STR_SEPARATOR}$1'

StrCpy $1 $7 2 4

StrCpy $0 '$0${STR_SEPARATOR}$1'

StrCpy $1 $7 2 2

StrCpy $0 '$0${STR_SEPARATOR}$1'

StrCpy $1 $7 2 0

StrCpy $0 '$0${STR_SEPARATOR}$1'

WriteINIStr ${MUI_INIFILE} "$4" "USING MAC" "$0"

Goto loop

finish:

System::Free $3

System::Free 0

Pop $7

Pop $6

Pop $5

Pop $4

Pop $3

Pop $2

Pop $1

Pop $0

FunctionEnd ;;GetNetCardsInfo

Function InitNetCardInfo

Push $0

Push $1

Push $2

Push $3

StrCpy $0 0

WriteINIStr ${MUI_INIFILE} "Settings" NetCardNum 0

WriteINIStr ${MUI_INIFILE} "Field ${DL_NETCARD}" ListItems ""

${Do}

EnumRegKey $1 HKLM "${REG_NETWORK_ADAPTERS}" $0

${IfThen} $1 == "" ${|} ${ExitDo} ${|}

ReadRegStr $2 HKLM "${REG_NETWORK_ADAPTERS}$1NdiInterfaces" "LowerRange"

${if} $2 == "ethernet"

ReadRegStr $2 HKLM "${REG_NETWORK_ADAPTERS}$1" "DriverDesc"

WriteINIStr ${MUI_INIFILE} "Field ${DL_NETCARD}" State "$2"

WriteINIStr ${MUI_INIFILE} "$2" "RegKeyIndex" "$1"

ReadRegStr $3 HKLM "${REG_NETWORK_ADAPTERS}$1" "NetworkAddress"

${if} $3 == ""

StrCpy $3 "${STR_UNSETTED}"

${endif}

WriteINIStr ${MUI_INIFILE} "$2" "Mac" "$3"

ReadRegStr $3 HKLM "${REG_NETWORK_ADAPTERS}$1" "NetCfgInstanceId"

WriteINIStr ${MUI_INIFILE} "$2" "InstanceId" "$3"

ReadINIStr $3 ${MUI_INIFILE} "$3" "USING MAC"

${if} $3 != ""

WriteINIStr ${MUI_INIFILE} "$2" "MAC" "$3"

${endif}

Push $2

Call GetTcpIpInfo

ReadINIStr $3 ${MUI_INIFILE} "Field ${DL_NETCARD}" ListItems

${if} $3 != ""

StrCpy $2 "$2|$3"

${endif}

WriteINIStr ${MUI_INIFILE} "Field ${DL_NETCARD}" ListItems "$2"

ReadINIStr $3 ${MUI_INIFILE} "Settings" NetCardNum

IntOp $3 $3 + 1

WriteINIStr ${MUI_INIFILE} "Settings" NetCardNum $3

${endif}

IntOp $0 $0 + 1

${Loop}

Pop $3

Pop $2

Pop $1

Pop $0

FunctionEnd ;;InitNetCardInfo

Function InitHostList

Push $0

Push $1

Push $2

StrCpy $0 0

WriteINIStr ${MUI_INIFILE} "Field ${DL_HOST}" ListItems "" ;;初始化主机列表

${Do}

EnumRegKey $1 HKLM "${REG_ME_HOSTLIST}" $0

${IfThen} $1 == "" ${|} ${ExitDo} ${|}

;MessageBox MB_OK "$1"

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}$1" ""

${if} $2 == "Setted" ;;检验是否合法

WriteINIStr ${MUI_INIFILE} "Field ${DL_HOST}" State "$1"

ReadINIStr $2 ${MUI_INIFILE} "Field ${DL_HOST}" ListItems

${if} $2 != ""

StrCpy $1 "$1|$2" ;合并/主机标识项目

${endif}

WriteINIStr ${MUI_INIFILE} "Field ${DL_HOST}" ListItems "$1"

!insertmacro AddHostNum 1

${endif}

IntOp $0 $0 + 1

${Loop}

Pop $2

Pop $1

Pop $0

FunctionEnd ;;InitHostList

Function ResetSelectHost

Push $0

Push $1

Push $2

ReadINIStr $2 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

${if} $COUNTER_HOSTNUM < 1 ;无主机信息

EnableWindow $2 0

SendMessage $1 ${CB_ADDSTRING} 0 "STR:${STR_DEFAULT_HOST}"

SendMessage $1 ${CB_SELECTSTRING} 0 "STR:${STR_DEFAULT_HOST}"

${else} ;有主机信息

EnableWindow $2 1

StrCpy $0 0

${Do}

EnumRegKey $1 HKLM "${REG_ME_HOSTLIST}" $0

${IfThen} $1 == "" ${|} ${ExitDo} ${|}

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}$1" ""

${if} $2 == "Setted" ;;检验是否合法

ReadINIStr $2 ${MUI_INIFILE} "Field ${DL_HOST}" HWND

SendMessage $2 ${CB_SELECTSTRING} 0 "STR:$1"

WriteINIStr ${MUI_INIFILE} "Field ${DL_HOST}" State "$1"

${ExitDo}

${endif}

IntOp $0 $0 + 1

${Loop}

${endif}

Pop $2

Pop $1

Pop $0

FunctionEnd ;;ResetSelectHost

Function InitLastHostInfo ;;获取首选主机信息

Push $0

Push $1

Push $2

;;初始化主机下拉列表控件首选项

${if} $COUNTER_HOSTNUM > 0 ;有主机信息

WriteINIStr ${MUI_INIFILE} "Field ${GB_SELHOST}" Text "选择主机 ( 当前共 $COUNTER_HOSTNUM 个主机信息 )"

WriteINIStr ${MUI_INIFILE} "Field ${DL_HOST}" Flags "Notify" ;初始可用主机下拉列表控件

ReadRegStr $0 HKLM "${REG_ME_HOSTLIST}" "LastHost"

ReadRegStr $1 HKLM "${REG_ME_HOSTLIST}$0" ""

${if} $1 == "Setted"

WriteINIStr ${MUI_INIFILE} "Field ${DL_HOST}" State "$0"

${endif}

ReadINIStr $0 ${MUI_INIFILE} "Field ${DL_HOST}" State

WriteINIStr ${MUI_INIFILE} "Field ${TXT_HOST}" State $0

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}$0" "MAC"

${if} $2 == ""

${orif} $2 == "${STR_UNSETTED}"

StrCpy $2 "${STR_UNSETTED}"

${else}

StrLen $3 "$2"

${if} $3 != 12

StrCpy $2 "${STR_ERRORFORMAT}"

${endif}

${endif}

WriteINIStr ${MUI_INIFILE} "Field ${TXT_MAC}" State $2

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}$0" "IP"

${if} $2 == ""

StrCpy $2 "${STR_UNSETTED}"

${endif}

WriteINIStr ${MUI_INIFILE} "Field ${TXT_IP}" State $2

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}$0" "MASK"

${if} $2 == ""

StrCpy $2 "${STR_UNSETTED}"

${endif}

WriteINIStr ${MUI_INIFILE} "Field ${TXT_MASK}" State $2

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}$0" "NETGATE"

${if} $2 == ""

StrCpy $2 "${STR_UNSETTED}"

${endif}

WriteINIStr ${MUI_INIFILE} "Field ${TXT_NETGATE}" State $2

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}$0" "DNS"

${if} $2 == ""

StrCpy $2 "${STR_UNSETTED}"

${endif}

WriteINIStr ${MUI_INIFILE} "Field ${TXT_DNS}" State $2

${else} ;无主机信息

WriteINIStr ${MUI_INIFILE} "Field ${DL_HOST}" State "${STR_DEFAULT_HOST}"

WriteINIStr ${MUI_INIFILE} "Field ${DL_HOST}" ListItems "${STR_DEFAULT_HOST}"

ReadRegStr $2 HKLM "${REG_WINLOGON}" "AltDefaultDomainName"

WriteINIStr ${MUI_INIFILE} "Field ${TXT_HOST}" State $2

ReadINIStr $1 ${MUI_INIFILE} "Field ${DL_NETCARD}" State

ReadINIStr $2 ${MUI_INIFILE} "$1" "MAC"

WriteINIStr ${MUI_INIFILE} "Field ${TXT_MAC}" State $2

ReadINIStr $2 ${MUI_INIFILE} "$1" "IP"

WriteINIStr ${MUI_INIFILE} "Field ${TXT_IP}" State $2

ReadINIStr $2 ${MUI_INIFILE} "$1" "MASK"

WriteINIStr ${MUI_INIFILE} "Field ${TXT_MASK}" State $2

ReadINIStr $2 ${MUI_INIFILE} "$1" "NETGATE"

WriteINIStr ${MUI_INIFILE} "Field ${TXT_NETGATE}" State $2

ReadINIStr $2 ${MUI_INIFILE} "$1" "DNS"

WriteINIStr ${MUI_INIFILE} "Field ${TXT_DNS}" State $2

${endif}

Pop $2

Pop $1

Pop $0

FunctionEnd ;;InitLastHostInfo

##############################################################

# 功能 -- 刷新(开启/禁用) 网络连接

# Function RefreshConnection

##############################################################

Function RefreshConnection

Push $0

Push $1

Push $2

Push $3

Push $4

System::Call "advapi32::GetUserName(t .r0, *i ${NSIS_MAX_STRLEN} r1) i.r2"

;MessageBox MB_OK "UserName: $0 | CharsNm: $1"

StrCpy $2 $0 2

Loop:

IfFileExists "$TEMP$2$1.tmp" 0 Pass

IntOp $1 $1 + 100

Goto Loop

Pass:

StrCpy $1 "$TEMP$2$1.tmp"

ReadINIStr $2 ${MUI_INIFILE} "Field ${DL_NETCARD}" State

ReadINIStr $2 ${MUI_INIFILE} "$2" "InstanceId"

ReadRegStr $2 HKLM "${REG_NETWORK_CONNECTIONS}$2Connection" "Name"

ReadRegStr $3 HKCR "${REG_NETWORK_FOLDERNAME}" ""

!insertmacro CreateVBScript "$1" "$2" "$3"

Sleep 50 ;;稍等I/O结束

;FindWindow $4 '#32770' '${STR_CAPTION}'

;ShowWindow $4 2

;MessageBox MB_OK "VB脚本已经生成完毕,点击确定打开,查看:$1"

;ExecWait `"$SYSDIRnotepad.exe" "$1"`

;Quit

;ShowWindow $4 1

ExecWait `"$SYSDIRWScript.exe" /B /E:vbs "$1"`

${If} $R0 == "ExecTwice"

Sleep 5000 ;;平缓5秒

ExecWait `"$SYSDIRWScript.exe" /B /E:vbs "$1"`

${endif}

Delete "$1"

Call GetNetCardsInfo

Pop $4

Pop $3

Pop $2

Pop $1

Pop $0

FunctionEnd ;;RefreshConnection

##############################################################

# 功能 -- 导出主机列表备份 / 导入主机列表备份

#

# Function SaveHostlist2INI

# Function ImprotHostlist2REG

##############################################################

Function SaveHostlist2INI

Push $0

Push $1

Push $2

Push $3

FileOpen $2 "${VAR_OPENSAVE}" w

FileSeek $2 0 END

FileWrite $2 "${STR_SAVE_FILE_NOTE}"

FileClose $2

StrCpy $0 0

WriteINIStr ${VAR_OPENSAVE} "Main" HostNum 0

WriteINIStr ${VAR_OPENSAVE} "Main" Type "HostList Backup File"

WriteINIStr ${MUI_INIFILE} "Field ${DL_HOST}" ListItems ""

${Do}

EnumRegKey $1 HKLM "${REG_ME_HOSTLIST}" $0

${IfThen} $1 == "" ${|} ${ExitDo} ${|}

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}$1" ""

${if} $2 == "Setted"

;${orif} $2 == "Hidden"

ReadINIStr $3 ${VAR_OPENSAVE} "Main" HostNum

IntOp $3 $3 + 1

WriteINIStr ${VAR_OPENSAVE} "Main" HostNum $3

FileOpen $2 "${VAR_OPENSAVE}" a

FileSeek $2 0 END

FileWrite $2 "$r$n"

FileClose $2

WriteINIStr ${VAR_OPENSAVE} "Host $3" FLAG "Setted"

WriteINIStr ${VAR_OPENSAVE} "Host $3" NAME "$1"

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}$1" "MAC"

${if} $2 == "${STR_ERRORFORMAT}"

${orif} $2 == "${STR_UNSETTED}"

StrCpy $2 ""

${endif}

WriteINIStr ${VAR_OPENSAVE} "Host $3" MAC "$2"

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}$1" "IP"

${if} $2 == "${STR_UNSETTED}"

StrCpy $2 ""

${endif}

WriteINIStr ${VAR_OPENSAVE} "Host $3" IP "$2"

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}$1" "MASK"

${if} $2 == "${STR_UNSETTED}"

StrCpy $2 ""

${endif}

WriteINIStr ${VAR_OPENSAVE} "Host $3" MASK "$2"

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}$1" "NETGATE"

${if} $2 == "${STR_UNSETTED}"

StrCpy $2 ""

${endif}

WriteINIStr ${VAR_OPENSAVE} "Host $3" NETGATE "$2"

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}$1" "DNS"

${if} $2 == "${STR_UNSETTED}"

StrCpy $2 ""

${endif}

WriteINIStr ${VAR_OPENSAVE} "Host $3" DNS "$2"

${endif}

IntOp $0 $0 + 1

${Loop}

ReadRegStr $2 HKLM "${REG_ME_HOSTLIST}" "LastHost"

WriteINIStr ${VAR_OPENSAVE} "Main" "RectHost" "$2"

WriteINIStr ${VAR_OPENSAVE} "Main" "Type" "HostList Backup File"

Pop $3

Pop $2

Pop $1

Pop $0

FunctionEnd ;;SaveHostlist2INI

Function ImprotHostlist2REG

Push $0

Push $1

Push $2

Push $3

Push $4

StrCpy $R4 -1 ;;临时选择标记容器

StrCpy $0 0 ;成功导入计数器

ReadINIStr $4 ${VAR_OPENSAVE} "Main" HostNum

${if} $4 <= 0

MessageBox MB_OK|MB_ICONEXCLAMATION|MB_TOPMOST "主机列表备份文件中没有任何主机信息,无法导入! "

${else}

${if} $COUNTER_HOSTNUM < 1

ReadINIStr $3 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

SendMessage $3 ${CB_DELETESTRING} 0 "" ;;删除旧主机标识

${endif}

;MessageBox MB_YESNO "继续?" IDYES +2

;Quit

${for} $1 1 $4

ReadINIStr $2 ${VAR_OPENSAVE} "Host $1" FLAG

${if} $2 != "Setted" ;;检测项目设置

${Continue}

${endif}

ReadINIStr $2 ${VAR_OPENSAVE} "Host $1" NAME

ReadRegStr $3 HKLM "${REG_ME_HOSTLIST}$2" ""

${if} $3 == "Setted"

;${orif} $3 == "Hidden"

${if} $R4 == "NOTOALL"

${Continue}

${orif} $R4 == "YESTOALL"

Goto OverW

${endif}

System::Call 'user32::MessageBeep(i) i (0x00000001)'

MessageBox::show MB_ICONHAND|MB_DEFBUTTON2|MB_TOPMOST "导入主机列表" "$SYSDIRshell32.dll,23"

"主机标识 $2 已经存在,是否将原主机信息覆盖? "

" 是 " "全是" "否" "全否"

Pop $R0

${if} $R0 == 2

StrCpy $R4 "YESTOALL"

Goto OverW

${elseif} $R0 == 4

StrCpy $R4 "NOTOALL"

${elseif} $R0 == 1

Goto OverW

${endif}

${Continue}

OverW:

${else}

ReadINIStr $3 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

SendMessage $3 ${CB_ADDSTRING} 0 "STR:$2" ;;添加新标识

!insertmacro AddHostNum 1

${endif}

ReadINIStr $3 ${VAR_OPENSAVE} "Host $1" FLAG

WriteRegStr HKLM "${REG_ME_HOSTLIST}$2" "" $3

ReadINIStr $3 ${VAR_OPENSAVE} "Host $1" MAC

WriteRegStr HKLM "${REG_ME_HOSTLIST}$2" "MAC" $3

ReadINIStr $3 ${VAR_OPENSAVE} "Host $1" IP

WriteRegStr HKLM "${REG_ME_HOSTLIST}$2" "IP" $3

ReadINIStr $3 ${VAR_OPENSAVE} "Host $1" MASK

WriteRegStr HKLM "${REG_ME_HOSTLIST}$2" "MASK" $3

ReadINIStr $3 ${VAR_OPENSAVE} "Host $1" NETGATE

WriteRegStr HKLM "${REG_ME_HOSTLIST}$2" "NETGATE" $3

ReadINIStr $3 ${VAR_OPENSAVE} "Host $1" DNS

WriteRegStr HKLM "${REG_ME_HOSTLIST}$2" "DNS" $3

IntOp $0 $0 + 1

${Next}

ReadINIStr $4 ${VAR_OPENSAVE} "Main" RectHost

ReadRegStr $3 HKLM "${REG_ME_HOSTLIST}$4" ""

${if} $3 != "Setted"

StrCpy $4 $2

${endif}

WriteRegStr HKLM "${REG_ME_HOSTLIST}" "LastHost" "$4"

ReadINIStr $3 "${MUI_INIFILE}" "Field ${DL_HOST}" "HWND"

SendMessage $3 ${CB_SELECTSTRING} 0 "STR:$4"

WriteINIStr "${MUI_INIFILE}" "Field ${DL_HOST}" State "$4"

!insertmacro ShowReg2Txt $1 $2 $3

${if} $0 > 0

MessageBox MB_OK|MB_ICONINFORMATION|MB_TOPMOST "导入完成: 从备份文件中成功导入 $0 个主机项目。 "

${else}

MessageBox MB_OK|MB_ICONINFORMATION|MB_TOPMOST "没有导入任何主机。 "

${endif}

${endif}

Pop $4

Pop $3

Pop $2

Pop $1

Exch $0

FunctionEnd ;;ImprotHostlist2REG

Section -Nop

Quit ;;形式,用不到...

SectionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » 局域网使用工具NSIS脚本

您必须 登录 才能发表评论!