VC修改mac地址的方法
来源:互联网 发布:中国乐队 知乎 编辑:程序博客网 时间:2024/06/06 15:51
Windows10注册表修改网卡mac地址:
https://jingyan.baidu.com/article/84b4f56598958b60f6da32bd.html
xp 设置 修改网卡mack地址
https://jingyan.baidu.com/article/48a420579a90f1a924250484.html
vc++ 中如何读取和修改MAC的地址
读取mac地址方法:
CString GetMacByCmd(){//command buf sizeconst long lBufSize = 4096;//command line stringchar szFetCmd[] = "ipconfig /all";//Search stringstring str4Search = "Physical Address. . . . . . . . . : ";CString strRet = _T("");BOOL bRet;SECURITY_ATTRIBUTES sa; HANDLE hReadPipe,hWritePipe;//Initsa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; //Create pipebRet = CreatePipe(&hReadPipe, &hWritePipe, &sa, 0);if(FALSE == bRet){return strRet;}//Get infomationSTARTUPINFO si;PROCESS_INFORMATION pi;si.cb = sizeof(STARTUPINFO); GetStartupInfo(&si);si.hStdError = hWritePipe; si.hStdOutput = hWritePipe; si.wShowWindow = SW_HIDE; //Hide command windowssi.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;//Create command processbRet = CreateProcess (NULL, szFetCmd, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi );char szBuffer[lBufSize + 1];string strBuffer;if (TRUE == bRet) { WaitForSingleObject (pi.hProcess, INFINITE); //Read infomationunsigned long count;memset(szBuffer, 0x00, sizeof(szBuffer));bRet = ReadFile(hReadPipe, szBuffer, lBufSize, &count, 0);if(TRUE == bRet){strBuffer = szBuffer;long ipos;ipos = strBuffer.find(str4Search);//Get adress infomationstrBuffer = strBuffer.substr(ipos+str4Search.length());ipos = strBuffer.find("\n");strBuffer = strBuffer.substr(0, ipos);strRet.Format("%s", strBuffer.c_str()); //remove“00-50-EB-0F-27-82”'-' get 0050EB0F2782strRet.Remove('-');strRet = strRet.Left(strRet.GetLength() - 2 );}}//close handleCloseHandle(hWritePipe);CloseHandle(pi.hProcess); CloseHandle(pi.hThread); CloseHandle(hReadPipe);return strRet;}
VC获得正在使用的网卡的MAC地址PIP_ADAPTER_INFO pAdapterInfo;PIP_ADAPTER_INFO pAdapter = NULL;DWORD dwRetVal = 0;UINT i;/* variables used to print DHCP time info */struct tm newtime;char buffer[32];errno_t error;ULONG ulOutBufLen = sizeof (IP_ADAPTER_INFO);pAdapterInfo = (IP_ADAPTER_INFO *) MALLOC(sizeof (IP_ADAPTER_INFO));if (pAdapterInfo == NULL) {printf("Error allocating memory needed to call GetAdaptersinfo\n");return 1;}// Make an initial call to GetAdaptersInfo to get// the necessary size into the ulOutBufLen variableif (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {FREE(pAdapterInfo);pAdapterInfo = (IP_ADAPTER_INFO *) MALLOC(ulOutBufLen);if (pAdapterInfo == NULL) {printf("Error allocating memory needed to call GetAdaptersinfo\n");return 1;}}if ((dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen)) == NO_ERROR) {pAdapter = pAdapterInfo;while (pAdapter) {if (pAdapter->DhcpEnabled) {/*printf("\t Lease Obtained: ");/* Display local timeerror = _localtime32_s(&newtime, (__time32_t*) &pAdapter->LeaseObtained);if (error)printf("Invalid Argument to _localtime32_s\n");else {// Convert to an ASCII representation error = asctime_s(buffer, 32, &newtime);if (error)printf("Invalid Argument to asctime_s\n");elseasctime_s returns the string terminated by \n\0printf("%s", buffer);}*/if( pAdapter->LeaseObtained > 10 ){for (i = 0; i < pAdapter->AddressLength; i++) {if (i == (pAdapter->AddressLength - 1))printf("%.2X\n", (int) pAdapter->Address[i]);elseprintf("%.2X-", (int) pAdapter->Address[i]);}}} pAdapter = pAdapter->Next;printf("\n");}} else {printf("GetAdaptersInfo failed with error: %d\n", dwRetVal);}if (pAdapterInfo)FREE(pAdapterInfo);
修改IP、DNS、MAC工具VC源码实现
http://blog.csdn.net/cjf_iceking/article/details/7667522
阅读全文
0 0
- VC修改mac地址的方法
- 修改mac地址的方法
- VC 物理MAC地址的获取方法
- 修改MAC地址的方法 破解MAC地址绑定
- Mac地址修改方法
- 如何修改MAC地址的方法
- Linux修改MAC地址的方法
- vmware修改MAC地址的方法
- 修改网卡MAC地址的两个方法
- linux下修改mac地址的方法
- MAC地址的修改
- 修改 Mac 的 MAC 地址
- 注册表修改MAC地址方法
- 修改MAC地址有两种方法
- linux修改mac地址方法
- VC获取MAC地址的4种方法
- VC获取MAC地址的4种方法
- VC获取MAC地址的4种方法
- noip2017游记
- CNN目标检测(一):Faster RCNN详解
- Safari中的印象笔记剪切插件默认要我登陆evernote账号但我只有印象笔记的账号啊!没关系一步教你解决!
- IDEA设置字体大小
- 百度地图、高德地图、谷歌地图离线瓦片下载研究(一)
- VC修改mac地址的方法
- Java 如何获取控制台日志输出的信息? WriterAppender 可以实现? 配置文件如何配置
- World Wind Android——基本的Android教程(一)
- echarts x轴显示格式blog
- 获取Builder C++或Dephi的消息框TMessageForm内
- java面试题总结:java的接口类和抽象类的特点
- 编程语言——C++的对象模型
- EasyUI DataGrid 单元格合并(或者说一条数据拆分成多条)
- 源码分析 There is no getter for property named '*' in 'class java.lang.String