• 欢迎访问奇跡の海网站,本站不上传任何资源,所有资源均来自于网络,欢迎加入奇跡の海~!奇跡の海-WordPress QQ群
  • 本站下载资源为网络上收集整理而来,并且以计算机技术研究交流为目的,版权归原作者所有,仅供大家参考,学习,不存在任何商业目的与商业用途.
  • 本站系统镜像均来自于官方原版,ed2k可视为P2P下载链接。所有操作系统默认均为试用版,如有正版密钥可以有效激活,本站不提供任何激活和相关服务。

AU3获取本机的IP和MAC地址及设置IP和DNS的源代码

AutoIT3 奇跡の海 2年前 (2017-04-29) 644次浏览 已收录 0个评论 扫描二维码

AU3获取本机的IP和MAC地址及设置IP和DNS的源代码

获取本机的IP和MAC地址的源代码

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
#include <inet.au3>
Global $g_idMemo, $g_hMainGUI, $g_hStatus
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=..\..\..\WINDOWS\system32\SHELL32.dll
#AutoIt3Wrapper_outfile=D:\bug log\getmacaddress.exe
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
Example()

Func Example()
        Local $hGUI
        Local $aParts[3] = [75, 150, -1]

        ; Create GUI
        $hGUI = GUICreate("(Example 1) StatusBar Create", 400, 300)

        ; defaults to 1 part, no text
        $g_hStatus = _GUICtrlStatusBar_Create($hGUI)
        _GUICtrlStatusBar_SetParts($g_hStatus, $aParts)

        ; Create memo control
        $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
        GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
        GUICtrlSendMsg($g_idMemo, $EM_SETREADONLY, True, 0)
        GUICtrlSetBkColor($g_idMemo, 0xFFFFFF)
        GUISetState(@SW_SHOW)

        MemoWrite(&quot;本人根据其他人的<a href="http://www.seaomc.com/archives/tag/dm" title="查看更多关于代码的文章" target="_blank">代码</a>改编&quot; &amp; @CRLF &amp; _
                        @Tab &amp; &quot;大家共同学习我的邮箱是hzr2006@163.com&quot; &amp; @CRLF)

        GUIRegisterMsg($WM_NOTIFY, &quot;WM_NOTIFY&quot;)

        ; Get border sizes
        MemoWrite(&quot;本机IP地址.: &quot; &amp; @IPAddress1)
        MemoWrite(&quot;本机的网卡地址 &quot; &amp; _GetMAC ())
        ;MemoWrite(&quot;Width between rectangles : &quot; &amp; _GUICtrlStatusBar_GetBordersRect($g_hStatus))

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUISetState(@SW_ENABLE, $g_hMainGUI)
        GUIDelete($hGUI)
EndFunc   ;==&gt;Example

; Write message to memo
Func MemoWrite($sMessage = &quot;&quot;)
        GUICtrlSetData($g_idMemo, $sMessage &amp; @CRLF, 1)
EndFunc   ;==&gt;MemoWrite

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg, $wParam
        Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR

        $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
        $hWndFrom = HWnd(DllStructGetData($tNMHDR, &quot;hWndFrom&quot;))
        $iIDFrom = DllStructGetData($tNMHDR, &quot;IDFrom&quot;)
        $iCode = DllStructGetData($tNMHDR, &quot;Code&quot;)
        Local $tInfo
        Switch $hWndFrom
                Case $g_hStatus
                        Switch $iCode
                                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                                        $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                                        $hWndFrom = HWnd(DllStructGetData($tInfo, &quot;hWndFrom&quot;))
                                        $iIDFrom = DllStructGetData($tInfo, &quot;IDFrom&quot;)
                                        $iCode = DllStructGetData($tInfo, &quot;Code&quot;)
                                        _DebugPrint(&quot;$NM_CLICK&quot; &amp; @CRLF &amp; &quot;--&gt; hWndFrom:&quot; &amp; @TAB &amp; $hWndFrom &amp; @CRLF &amp; _
                                                        &quot;--&gt;IDFrom:&quot; &amp; @TAB &amp; $iIDFrom &amp; @CRLF &amp; _
                                                        &quot;--&gt;Code:&quot; &amp; @TAB &amp; $iCode &amp; @CRLF &amp; _
                                                        &quot;--&gt;ItemSpec:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;ItemSpec&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;ItemData:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;ItemData&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;X:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;X&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;Y:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;Y&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;HitInfo:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;HitInfo&quot;))
                                        Return True ; indicate that the mouse click was handled and suppress default processing by the system
                                        ; Return FALSE ;to allow default processing of the click.
                                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                                        $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                                        $hWndFrom = HWnd(DllStructGetData($tInfo, &quot;hWndFrom&quot;))
                                        $iIDFrom = DllStructGetData($tInfo, &quot;IDFrom&quot;)
                                        $iCode = DllStructGetData($tInfo, &quot;Code&quot;)
                                        _DebugPrint(&quot;$NM_DBLCLK&quot; &amp; @CRLF &amp; &quot;--&gt; hWndFrom:&quot; &amp; @TAB &amp; $hWndFrom &amp; @CRLF &amp; _
                                                        &quot;--&gt;IDFrom:&quot; &amp; @TAB &amp; $iIDFrom &amp; @CRLF &amp; _
                                                        &quot;--&gt;Code:&quot; &amp; @TAB &amp; $iCode &amp; @CRLF &amp; _
                                                        &quot;--&gt;ItemSpec:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;ItemSpec&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;ItemData:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;ItemData&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;X:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;X&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;Y:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;Y&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;HitInfo:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;HitInfo&quot;))
                                        Return True ; indicate that the mouse click was handled and suppress default processing by the system
                                        ; Return FALSE ;to allow default processing of the click.
                                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                                        $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                                        $hWndFrom = HWnd(DllStructGetData($tInfo, &quot;hWndFrom&quot;))
                                        $iIDFrom = DllStructGetData($tInfo, &quot;IDFrom&quot;)
                                        $iCode = DllStructGetData($tInfo, &quot;Code&quot;)
                                        _DebugPrint(&quot;$NM_RCLICK&quot; &amp; @CRLF &amp; &quot;--&gt; hWndFrom:&quot; &amp; @TAB &amp; $hWndFrom &amp; @CRLF &amp; _
                                                        &quot;--&gt;IDFrom:&quot; &amp; @TAB &amp; $iIDFrom &amp; @CRLF &amp; _
                                                        &quot;--&gt;Code:&quot; &amp; @TAB &amp; $iCode &amp; @CRLF &amp; _
                                                        &quot;--&gt;ItemSpec:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;ItemSpec&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;ItemData:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;ItemData&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;X:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;X&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;Y:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;Y&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;HitInfo:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;HitInfo&quot;))
                                        Return True ; indicate that the mouse click was handled and suppress default processing by the system
                                        ; Return FALSE ;to allow default processing of the click.
                                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                                        $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                                        $hWndFrom = HWnd(DllStructGetData($tInfo, &quot;hWndFrom&quot;))
                                        $iIDFrom = DllStructGetData($tInfo, &quot;IDFrom&quot;)
                                        $iCode = DllStructGetData($tInfo, &quot;Code&quot;)
                                        _DebugPrint(&quot;$NM_RDBLCLK&quot; &amp; @CRLF &amp; &quot;--&gt; hWndFrom:&quot; &amp; @TAB &amp; $hWndFrom &amp; @CRLF &amp; _
                                                        &quot;--&gt;IDFrom:&quot; &amp; @TAB &amp; $iIDFrom &amp; @CRLF &amp; _
                                                        &quot;--&gt;Code:&quot; &amp; @TAB &amp; $iCode &amp; @CRLF &amp; _
                                                        &quot;--&gt;ItemSpec:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;ItemSpec&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;ItemData:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;ItemData&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;X:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;X&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;Y:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;Y&quot;) &amp; @CRLF &amp; _
                                                        &quot;--&gt;HitInfo:&quot; &amp; @TAB &amp; DllStructGetData($tInfo, &quot;HitInfo&quot;))
                                        Return True ; indicate that the mouse click was handled and suppress default processing by the system
                                        ; Return FALSE ;to allow default processing of the click.
                                Case $SBN_SIMPLEMODECHANGE ; Simple mode changes
                                        _DebugPrint(&quot;$SBN_SIMPLEMODECHANGE&quot; &amp; @CRLF &amp; &quot;--&gt; hWndFrom:&quot; &amp; @TAB &amp; $hWndFrom &amp; @CRLF &amp; _
                                                        &quot;--&gt;IDFrom:&quot; &amp; @TAB &amp; $iIDFrom &amp; @CRLF &amp; _
                                                        &quot;--&gt;Code:&quot; &amp; @TAB &amp; $iCode)
                                        ; No return value
                        EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
EndFunc   ;==&gt;WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
        ConsoleWrite( _
                        &quot;!===========================================================&quot; &amp; @CRLF &amp; _
                        &quot;+======================================================&quot; &amp; @CRLF &amp; _
                        &quot;--&gt;Line(&quot; &amp; StringFormat(&quot;%04d&quot;, $sLine) &amp; &quot;):&quot; &amp; @TAB &amp; $s_Text &amp; @CRLF &amp; _
                        &quot;+======================================================&quot; &amp; @CRLF)
EndFunc   ;==&gt;_DebugPrint

Func _GetMAC ()
  Local $MAC,$MACSize
  Local $ii,$ss,$rr,$iIP

  $MAC = DllStructCreate(&quot;byte[6]&quot;)
  $MACSize = DllStructCreate(&quot;int&quot;)

  DllStructSetData($MACSize,1,6)
  $rr = DllCall (&quot;Ws2_32.dll&quot;, &quot;int&quot;, &quot;inet_addr&quot;, &quot;str&quot;, $iIP)
  $iIP = $rr[0]
  $r = DllCall (&quot;iphlpapi.dll&quot;, &quot;int&quot;, &quot;SendARP&quot;,&quot;int&quot;, $iIP,&quot;int&quot;, 0,&quot;ptr&quot;, DllStructGetPtr($MAC),&quot;ptr&quot;, DllStructGetPtr($MACSize))
  $ss    = &quot;&quot;
  For $ii = 0 To 5
      If $ii Then $ss = $ss &amp; &quot;:&quot;
      $ss = $ss &amp; Hex(DllStructGetData($MAC,1,$ii+1),2)
  Next
  Return $ss
EndFunc

设置IP和DNS的源代码

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <File.au3>
#include <date.au3>
Opt("GUIOnEventMode", 1)

$G_bCreate = False;
$G_Config = @WorkingDir & "\config.ini"
$G_Name= ""
$hDlg = GUICreate("修改IP",481,236)
Dim $G_arrCurInfo[8]
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
guictrlcreatelabel("选择",10,10)
$G_hComb =  GUICtrlCreateCombo("",50,5,300,30)
;GUICtrlSetStyle($G_hComb, 0x0800)
GUICtrlSetOnEvent(-1, "ComboEvent")
InitCombox()
Const $C_Height = 20
$iY =  20+20
$G_check1  = GUICtrlCreateCheckbox("自动获取IP",10,$iY,120,20)
GUICtrlSetStyle($G_check1,$BS_CHECKBOX )
GUICtrlSetState($G_check1,$GUI_DISABLE)

版权声明:本站所有文章和资源使用CC BY-NC-SA 4.0协议授权发布 , 转载应当以相同方式注明文章来自“SeaOMC.COM->AU3获取本机的IP和MAC地址及设置IP和DNS的源代码!在下边可以分享本文哦!
喜欢 (0)
[]
分享 (0)
奇跡の海
关于作者:
一个WordPress菜鸟!
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址