Last active
March 23, 2016 09:49
-
-
Save wgm89/7afdd53c8ce4b6858f09 to your computer and use it in GitHub Desktop.
windows c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ##开机自启动脚本 | |
| #include <windows.h> | |
| #include <stdio.h> | |
| int main() | |
| { | |
| HKEY hRoot = HKEY_LOCAL_MACHINE; | |
| char *szSubKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"; | |
| char *szModule = "D:\\software\\eclipse\\eclipse.exe"; | |
| HKEY hKey; | |
| DWORD dwDisposition = REG_OPENED_EXISTING_KEY; | |
| LONG lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, | |
| KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition); | |
| if(lRet != ERROR_SUCCESS) | |
| { | |
| printf("failed to find !\n"); | |
| return -1; | |
| } | |
| lRet = RegSetValueEx(hKey, "eclipse", 0, REG_SZ, (BYTE *)szModule, strlen(szModule)); | |
| RegCloseKey(hKey); | |
| if(lRet != ERROR_SUCCESS) | |
| { | |
| printf("failed to reg !\n"); | |
| return -1; | |
| } | |
| return 0; | |
| } | |
| //Windows C 获取mac地址 | |
| #include <stdlib.h> | |
| #include <Winsock2.h> | |
| #include <Iptypes.h> | |
| #include <iphlpapi.h> | |
| #include <stdio.h> | |
| static void PrintMACaddress(unsigned char MACData[]) | |
| { | |
| printf("MAC Address: %02X-%02X-%02X-%02X-%02X-%02X\n", | |
| MACData[0], MACData[1],MACData[2],MACData[3],MACData[4],MACData[5]); | |
| } | |
| static void GetMacAddress(void) | |
| { | |
| IP_ADAPTER_INFO AdapterInfo[16]; | |
| DWORD dwBuflen = sizeof(AdapterInfo); | |
| DWORD dwStatus = GetAdaptersInfo(AdapterInfo, &dwBuflen); | |
| PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; | |
| do{ | |
| PrintMACaddress(pAdapterInfo->Address); | |
| pAdapterInfo = pAdapterInfo->Next; | |
| }while(pAdapterInfo); | |
| } | |
| int main() | |
| { | |
| GetMacAddress(); | |
| system("pause"); | |
| return 0; | |
| } | |
| gcc mac.c -o mac -l iphlpapi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment