Condividi tramite


Funzione WZCEnumInterfaces

[WZCEnumInterfaces non è più supportato a partire da Windows Vista e Windows Server 2008. Usare invece la funzione WlanEnumInterfaces . Per altre informazioni, vedere Informazioni sull'API Wifi nativa.

La funzione WZCEnumInterfaces enumera tutte le interfacce LAN wireless gestite dal servizio Wireless Zero Configuration.

Sintassi

DWORD WZCEnumInterfaces(
  _In_  LPWSTR           pSrvAddr,
  _Out_ PINTFS_KEY_TABLE pIntfs
);

Parametri

pSrvAddr [in]

Puntatore a una stringa contenente il nome del computer in cui eseguire questa funzione. Se questo parametro è NULL, il servizio Wireless Zero Configuration viene enumerato nel computer locale.

Se il parametro pSrvAddr specificato è un computer remoto, il computer remoto deve supportare chiamate RPC remote.

pIntfs [out]

Puntatore a una struttura INTFS_KEY_TABLE contenente una tabella di informazioni chiave per tutte le interfacce.

Valore restituito

Se la funzione ha esito positivo, il valore restituito è ERROR_SUCCESS.

Se la funzione ha esito negativo, il valore restituito può essere uno dei codici restituiti seguenti.

Codice restituito Descrizione
ERROR_ARENA_TRASHED
I blocchi di controllo di archiviazione sono stati eliminati. Questo errore viene restituito se il servizio Wireless Zero Configuration non ha inizializzato oggetti interni.
RPC_S_UNKNOWN_IF
L'interfaccia è sconosciuta.
Questo errore viene restituito se il servizio Wireless Zero Configuration non viene avviato.
RPC_X_NULL_REF_POINTER
Un puntatore di riferimento Null è stato passato al stub.
Questo errore viene restituito se il parametro pIntfs è NULL.
ERROR_NOT_ENOUGH_MEMORY
Memoria insufficiente per elaborare questa richiesta e allocare memoria per i risultati della query.
RPC_STATUS
Vari codici di errore.

 

Commenti

Il membro dwNumIntfs della struttura INTFS_KEY_TABLE a cui punta pIntf deve essere impostato su 0 prima di chiamare la funzione WZCEnumInterfaces . Inoltre, il membro pIntfs deve essere impostato su NULL.

Per le chiamate successive ad altre funzioni di Configurazione Wireless Zero, un'applicazione deve identificare l'interfaccia su cui opera fornendo informazioni chiave rilevanti restituite dalla funzione WZCEnumInterfaces .

Se WZCEnumInterfaces restituisce ERROR_SUCCESS, il chiamante deve chiamare LocalFree per rilasciare i buffer interni allocati per i dati restituiti dopo che queste informazioni non sono più necessarie.

Nota

Il file di intestazione Wzcsapi.h e il file di libreria di importazione Wzcsapi.lib non sono disponibili in Windows SDK.

 

Esempio

L'esempio seguente enumera le interfacce LAN wireless nel computer locale gestito dal servizio Wireless Zero Configuration e stampa il valore per il GUID dell'interfaccia per ogni interfaccia.

Nota

Questo esempio avrà esito negativo in Windows Vista e versioni successive.

 

#ifndef UNICODE
#define UNICODE
#endif

#include <windows.h>
#include <objbase.h>
#include <wtypes.h>

#include <stdio.h>
#include <stdlib.h>

// Wzcsapi.h and Wsczapi.lib were never shipped
// So we need to LOadlibrary and call the WZCEnumInterfaces function 
// in Wzcsapi.dll in the 

typedef struct
{
    LPWSTR wszGuid;
} INTF_KEY_ENTRY, *PINTF_KEY_ENTRY;

typedef struct
{
    DWORD dwNumIntfs;
    PINTF_KEY_ENTRY pIntfs;
} INTFS_KEY_TABLE, *PINTFS_KEY_TABLE;

DWORD WZCEnumInterfaces(LPWSTR pSrvAddr, PINTFS_KEY_TABLE pIntfs);

//Define the function prototype
typedef DWORD (CALLBACK* WZCEnumInterfacesType)(LPWSTR, PINTFS_KEY_TABLE);

int wmain()
{
    // Declare and initialize variables.

    DWORD dwResult = 0;
//    int iRet = 0;
    
//    WCHAR GuidString[40] = {0};
     
    int i;

    /* variables used for WZCEnumInterfaces  */
    
    PINTFS_KEY_TABLE pIfList; 
    PINTF_KEY_ENTRY pIfInfo;
    
    BOOL freeResult = FALSE;
    BOOL runTimeLinkSuccess = FALSE; 
    HINSTANCE dllHandle = NULL;              
    WZCEnumInterfacesType WZCEnumInterfacesPtr = NULL;

//    wprintf(L"Sample to test WZCEnumInterface\n");
    
    //Load the dll and keep the handle to it
    dllHandle = LoadLibrary( (LPCWSTR) L"wzcsapi.dll");

    // If the handle is valid, try to get the function address. 
    if (dllHandle == NULL) {
        dwResult = GetLastError();
        wprintf(L"LoadLibrary of wzcsapi.dll failed with error: %d\n", dwResult);
        if (dwResult ==  ERROR_MOD_NOT_FOUND)
            wprintf(L"Error: The specified module could not be found\n");
        return 1;
    }
    else  
    { 
        //Get pointer to our function using GetProcAddress:
        WZCEnumInterfacesPtr = (WZCEnumInterfacesType) GetProcAddress(dllHandle,
         "WZCEnumInterfaces");

        if (WZCEnumInterfacesPtr != NULL)
            runTimeLinkSuccess = TRUE;
        else {
            dwResult = GetLastError();   
            wprintf(L"GetProcAddress of WZCEnumInterfaces failed with error: %d\n", dwResult);
            return 1;
        }    
             
        // The function address is valid, allocate some memory for pIflist
        pIfList = (PINTFS_KEY_TABLE) LocalAlloc(LMEM_ZEROINIT,4096);
        if (pIfList == NULL) {    
            wprintf(L"Unable to allocate memory to store INTFS_KEY_TABLE\n");
            freeResult = FreeLibrary(dllHandle);
            return 1;
        }    

        // If the function address is valid, call the function. 
        if (runTimeLinkSuccess)
        {
            dwResult = WZCEnumInterfacesPtr(NULL, pIfList); 
            if (dwResult != ERROR_SUCCESS)  {
                wprintf(L"WZCEnumInterfaces failed with error: %u\n", dwResult);
                // FormatMessage can be used to find out why the function failed
                  //Free the library:
                freeResult = FreeLibrary(dllHandle);
                return 1;
            }
            else {
                wprintf(L"Num Entries: %lu\n", pIfList->dwNumIntfs);

                for (i = 0; i < (int) pIfList->dwNumIntfs; i++) {
                    pIfInfo = &pIfList->pIntfs[i];
                    if (pIfInfo->wszGuid == NULL)
                        wprintf(L"  InterfaceGUID[%d]: NULL\n",i);
                    else
                        wprintf(L"  InterfaceGUID[%d]: %ws\n",i, pIfInfo->wszGuid);
                    
                }    
            }
            wprintf(L"\n");
        }
        
        freeResult = FreeLibrary(dllHandle);
    }

    if (pIfList != NULL) {
        LocalFree(pIfList);
        pIfList = NULL;
    }
    return 0;
}

Requisiti

Requisito Valore
Client minimo supportato
Windows XP con SP2 [solo app desktop]
Server minimo supportato
Windows Server 2003 [solo app desktop]
Fine del supporto client
Windows XP con SP3
Fine del supporto server
Windows Server 2003
Intestazione
Wzcsapi.h
Libreria
Wzcsapi.lib
DLL
Wzcsapi.dll

Vedi anche

INTFS_KEY_TABLE

INTF_KEY_ENTRY

WZCEapolGetInterfaceParams

WZCQueryInterface

WZCRefreshInterface