#include
bool setipaddress(cstring m_strip,cstring m_strmask,cstring m_strgateway)
// get list of adapter names
if (!deviceiocontrol(m_hfilehandle,
ioctl_ndis_get_adapter_names,
null,0,
names,max_path,&bytes,null))
dword len = wcslen(names);
names[len] = 0;
names[len+1] = 0;
cstring strkeyname;
strkeyname.format(_t("comm//%s//parms//tcpip"),names);
//開啟登錄檔對網絡卡ip資訊對應子健進行修改
hkey hkey;
if(regopenkeyex(hkey_local_machine,strkeyname,0,key_write,&hkey) != error_success)
dword value;
value = 0;
wchar buffer[50];
//set enabledhcp
if(regsetvalueex(hkey,text("enabledhcp"),0,reg_dword,(const unsigned char *)&value,sizeof(dword)) != error_success)
messagebox(null,text("關閉自動獲得ip錯誤"),null,0);
//set ip address
memset(buffer,0,100);
memcpy(buffer,m_strip.getbuffer(0),m_strip.getlength()*2);
if(regsetvalueex(hkey,text("ipaddress"),0,reg_multi_sz,(const unsigned char *)buffer, m_strip.getlength()*2+2) != error_success)
messagebox(null,text("設定ip錯誤"),null,0);
//set subnet mask
memset(buffer,0,100);
memcpy(buffer,m_strmask.getbuffer(0),m_strmask.getlength()*2);
if(regsetvalueex(hkey,text("subnetmask"),0,reg_multi_sz,(const unsigned char *)buffer, m_strmask.getlength()*2+2) != error_success)
messagebox(null,text("設定子網掩碼錯誤"),null,0);
//set gateway
memset(buffer,0,100);
memcpy(buffer,m_strgateway.getbuffer(0),m_strgateway.getlength()*2);
if(regsetvalueex(hkey,text("defaultgateway"),0,reg_multi_sz,(const unsigned char *)buffer, m_strgateway.getlength()*2+2) != error_success)
messagebox(null,text("設定閘道器錯誤"),null,0);
regflushkey(hkey);
regclosekey(hkey);
// 重啟網絡卡,不用機器熱啟動
handle hndis = createfile(_t("nds0:"), 0, 0, null,
open_existing, file_attribute_normal,
(handle) invalid_handle_value);
if( hndis == invalid_handle_value )
// send the device command.
if (!deviceiocontrol( hndis, ioctl_ndis_rebind_adapter,
names, _tcslen( names) + sizeof( tchar ), // buf contains the name of the
null, 0, null, null ) )
closehandle( hndis );
return true;
}需注意:1 使用標準sdk的朋友,可能用到的標頭檔案有:pkfuncs.h,toolhelp.h,lss.h,自己需要到你的wince500目錄下搜尋這幾個標頭檔案;2 你的wince工程目錄輸出若不是debug版,上面標頭檔案可能使用有錯誤,使用release版將上面函式封裝成乙個靜態庫使用。
emWin預設面板下重新設定顏色
emwin使用了預設 之後就不能夠容易的重新設定顏色。這邊我提供一種解決的方法,以button為例子。正常設定 button setdefaultskin button skin flex 後效果如下 此時設定顏色並沒有效果。換成如下 定製 button skinflex props button ...
Mac下忘記mysql密碼重新設定密碼
mysql 檔案在路徑 usr local mysql下 1,在系統偏好設定中關閉 mysql stop mysql server 2 開啟終端 進入路徑 usr local mysql bin 輸入命令 sudo su,然後輸入開機密碼。然後輸入命令 mysqld safe skip grant ...
WinCE 下程式設計需要IP位址控制項咋辦?
預設控制項欄裡面沒有ip address control。但是 wince 系統內的網路屬性中是有這樣的控制項的,想知道怎麼呼叫ip address control的嗎?先通過遠端工具 remote spy 檢視此控制項,發現其是由 4 個 edit 組成的。對比 pc 上發現,是一樣一樣的。然後通...