zoukankan      html  css  js  c++  java
  • 转:WinCE6.0 不重启修改IP地址

    采用修改注册表的方式实现:

    在应用程序中修改IP地址的方式:

     1 //////////////////////////////////////////////////////////////////////////
     2 // Set IP Address, Mask and Gateway 
     3 // Through the registry entry:
     4 // [HKEY_LOCAL_MACHINE/Comm/DM9CE1/Parms/TcpIp]
     5 // IpAddress, String
     6 // SubnetMask, String
     7 // DefaultGateway, String
     8 //////////////////////////////////////////////////////////////////////////
     9 SYSTEMUTILITY_API BOOL SysUtil_IPConfig(LPCWSTR m_StrIPAddress, LPCWSTR m_StrIPMask, LPCWSTR m_StrGate)
    10 {
    11     long lResult = 0;
    12 
    13     HANDLE hIPCEvent = CreateEvent(NULL, TRUE, FALSE, NULL); ;
    14     LPCTSTR    strSubKeyName = _T("Comm//DM9CE1//Parms//TcpIp");
    15     LPCTSTR strAdapterName = _T("DM9CE1");
    16     LPCTSTR strIP = _T("IpAddress");
    17     LPCTSTR strMask = _T("SubnetMask");
    18     LPCTSTR strGate = _T("DefaultGateway");
    19     LPCTSTR strDHCP = _T("EnableDHCP");
    20     DWORD dwValue = 0;
    21 
    22     DWORD dwStatus = NotifyAddrChange(&hIPCEvent, NULL);
    23     if(dwStatus != NO_ERROR)
    24         return FALSE;
    25 
    26     // Change IP Settings
    27     HKEY hKey;
    28     DWORD dwStrLen = 0;
    29     if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, strSubKeyName, 0, 0, &hKey) == ERROR_SUCCESS)
    30     {
    31         dwStrLen = wcslen(m_StrIPAddress) * sizeof(WCHAR);
    32         lResult = RegSetValueEx(hKey, strIP, 0, REG_SZ, (LPBYTE)m_StrIPAddress, dwStrLen);
    33         if(lResult != ERROR_SUCCESS)
    34             return FALSE;
    35 
    36         dwStrLen = wcslen(m_StrIPMask) * sizeof(WCHAR);
    37         lResult = RegSetValueEx(hKey, strMask, 0, REG_SZ, (LPBYTE)m_StrIPMask, dwStrLen);
    38         if(lResult != ERROR_SUCCESS)
    39             return FALSE;
    40 
    41         dwStrLen = wcslen(m_StrGate) * sizeof(WCHAR);
    42         lResult = RegSetValueEx(hKey, strGate, 0, REG_SZ, (LPBYTE)m_StrGate, dwStrLen);
    43         if(lResult != ERROR_SUCCESS)
    44             return FALSE;
    45 
    46         dwStrLen = sizeof(dwValue);
    47         lResult = RegSetValueEx(hKey, strDHCP, 0, REG_DWORD, (LPBYTE)&dwValue, dwStrLen); 
    48         if(lResult != ERROR_SUCCESS)
    49             return FALSE;
    50 
    51         RegCloseKey(hKey);
    52     }
    53 
    54     // Rebind NDIS
    55     if(!RebindNdisAdapter(strAdapterName))
    56         return FALSE;
    57 
    58     // Waiting until they are applied
    59     if(WaitForSingleObject(hIPCEvent, WAIT_TIMEOUT_10S) != WAIT_OBJECT_0)
    60         return FALSE;
    61 
    62     CloseHandle(hIPCEvent);
    63 
    64     return TRUE;
    65 }
  • 相关阅读:
    走进DOM:HTML DOM
    iOS 去掉UITableView风格为group时候的最顶部的空白距离
    Codeforces 394D Physical Education and Buns 胡搞
    查询出每一个雇员的姓名,工资,部门名称,工资在公司的等级及其领导的姓名,领导的工资,以及领导所相应的等级
    CCBAnimationManager
    sendto 和 recvfrom 函数
    三张图让你高速明确activity与fragment生命周期的异同点
    EWS 流通知订阅邮件
    [EWS]如何: 通过使用 Exchange 中的 EWS 流有关邮箱事件的通知
    async、await正确姿势
  • 原文地址:https://www.cnblogs.com/killer-xc/p/6692237.html
Copyright © 2011-2022 走看看