Exemple #1
0
static void WlanDeleteProfile_test(void)
{
    DWORD ret;

    /* invalid pReserved */
    ret = WlanDeleteProfile((HANDLE) -1, &InterfaceGuid, L"test", (PVOID) 1);
    ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");

    /* invalid InterfaceGuid */
    ret = WlanDeleteProfile((HANDLE) -1, NULL, L"test", NULL);
    ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");

    /* invalid strProfileName */
    ret = WlanDeleteProfile((HANDLE) -1, &InterfaceGuid, NULL, NULL);
    ok(ret == ERROR_INVALID_PARAMETER, "expected failure\n");
}
Exemple #2
0
/*
 * Remove all profiles on an interface
 */
DWORD RemoveIfaceProfiles (HANDLE h, 
                           const GUID *iface,
                           const WLANKEY *profiles,
                           const WLANKEY *keep){
	WLAN_PROFILE_INFO_LIST *profile_list = NULL;
	DWORD status;
	int i;
	int j;
	int k;

	status = WlanGetProfileList(h, iface, NULL, &profile_list);
	if (status == ERROR_SUCCESS && profile_list != NULL){
		for (i = 0; status == ERROR_SUCCESS && i < profile_list->dwNumberOfItems; i++){
			WLAN_PROFILE_INFO *profile = (WLAN_PROFILE_INFO *)(profile_list->ProfileInfo + i);
			if (profile != NULL){
				wchar_t ssid[256];
				GetProfileSSID(h, iface, profile->strProfileName, ssid);

				if (keep != NULL){
					int keep_profile = 0;
					for (j = 0; keep[j].ssid[0] != 0; j++){
						const wchar_t *profilename;
						if ((GetVersion() & 0xFF) >= 0x06){ // Windows Vista and above
							profilename = keep[j].displayname;
						} else {
							profilename = keep[j].ssid;
						}

						if (!wcscmp(profile->strProfileName, profilename)){
							keep_profile = 1;
							break;
						}
					}
					if (keep_profile){
						continue;
					}
				}

				j = 0;
				do {
					if (profiles == NULL || !wcscmp(ssid, profiles[j].ssid)){
						status = WlanDeleteProfile(h, iface, profile->strProfileName, NULL);
						fwprintf (stderr, L"    Removing profile \"%ls\"\n", profile->strProfileName);
						break;
					}
				} while (profiles != NULL && profiles[++j].ssid[0] != 0);
			}
		}

		WlanFreeMemory(profile_list);
	}

	return status;
}