#include "stdafx.h" #include "winsrv.h" void BlueSrv(); void wifi(const char* name, unsigned int IsOn) { char szCommandLine[512] = { 0 }; char szCommandLineA[512] = { 0 }; if (IsOn){ strcpy(szCommandLine, "cmd /c netsh connect name \"WLAN\" enabled"); strcpy(szCommandLineA, "cmd /c netsh interface set interface \"无线网络连接\" enabled"); sprintf_s(szCommandLine, 512, "cmd /c netsh wlan connect name=\"%s\"", name); } else { strcpy(szCommandLine, "cmd /c netsh interface set interface \"WLAN\" disable"); strcpy(szCommandLineA, "cmd /c netsh interface set interface \"无线网络连接\" disable"); } WinExec(szCommandLine, SW_HIDE); WinExec(szCommandLineA, SW_HIDE); } int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { if (0==strcmp(lpCmdLine, "wifioff")) { wifi("",0); } if (0 == strcmp(lpCmdLine, "wifion")) { wifi("", 1); } BlueSrv(); return 0; }