64,649
社区成员
发帖
与我相关
我的任务
分享
trProfileXml1="<?xml version=\"1.0\"?><WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\"><name>TP-LINK_SHJARI</name><SSIDConfig><SSID><name>TP-LINK_SHJARI</name></SSID></SSIDConfig><connectionType>ESS</connectionType><connectionMode>auto</connectionMode><MSM><security><authEncryption><authentication>WPAPSK</authentication><encryption>TKIP</encryption><useOneX>false</useOneX></authEncryption><sharedKey><keyType>passPhrase</keyType><protected>false</protected><keyMaterial>12345678</keyMaterial></sharedKey></security></MSM></WLANProfile>";
nXMLLenght = MultiByteToWideChar(CP_ACP, 0, trProfileXml1.c_str(), -1, wscProfileXML, 2048);
MultiByteToWideChar(CP_ACP, 0, trProfileXml1.c_str(), NULL, wscProfileXML, nXMLLenght);
dwResoult = WlanSetProfile(hClient, &pInterface->InterfaceGuid,0x00, wscProfileXML, NULL, FALSE, NULL, &dwReasonCode);
if(ERROR_SUCCESS != dwResoult)
{
switch (dwResoult)
{
case ERROR_INVALID_PARAMETER:
wprintf(L"Para is NULL\n");
break;
case ERROR_INVALID_HANDLE:
wprintf(L"Failed to INVALID HANDLE \n");
break;
case ERROR_NOT_ENOUGH_MEMORY:
wprintf(L"Failed to allocate memory \n");
break;
case ERROR_BAD_PROFILE:
wprintf(L"The profile specified by strProfileXml is not valid \n");
break;
case ERROR_ALREADY_EXISTS: //现在进入这里了,不知道怎么解决
wprintf(L"strProfileXml specifies a network that already exists \n");
break;
case ERROR_ACCESS_DENIED:
wprintf(L"The caller does not set the profile. \n");
break;
default:
dwResoult = GetLastError();
wprintf(L"WlanSetProfile Fail: %wd\n", dwResoult);
break;
}
}