共用方式為


WZCEnumInterfaces 函式

[WZCEnumInterfaces 自 Windows Vista 和 Windows Server 2008 起不再支援。 請改用 WlanEnumInterfaces 函 式。 如需詳細資訊,請參閱 關於原生 Wifi API。]

WZCEnumInterfaces函式會列舉無線零設定服務所管理的所有無線區域網路 介面。

語法

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

參數

pSrvAddr [in]

字串的指標,包含執行此函式的電腦名稱稱。 如果此參數為 Null,則會在本機電腦上列舉無線零設定服務。

如果指定的 pSrvAddr 參數是遠端電腦,則遠端電腦必須支援遠端 RPC 呼叫。

pIntfs [out]

INTFS_KEY_TABLE結構的指標,其中包含所有介面的索引鍵資訊資料表。

傳回值

如果函式成功,傳回值會ERROR_SUCCESS。

如果函式失敗,傳回值可能是下列其中一個傳回碼。

傳回碼 Description
ERROR_ARENA_TRASHED
儲存控制區塊已終結。 如果無線零設定服務尚未初始化內建物件,就會傳回此錯誤。
RPC_S_UNKNOWN_IF
介面未知。
如果未啟動無線零設定服務,就會傳回此錯誤。
RPC_X_Null_REF_POINTER
Null 參考指標已傳遞至存根。
如果 pIntfs 參數為 Null,就會傳回此錯誤。
ERROR_NOT_ENOUGH_MEMORY
沒有足夠的記憶體可用來處理此要求,並配置查詢結果的記憶體。
RPC_STATUS
各種錯誤碼。

 

備註

呼叫WZCEnumInterfaces函式之前,pIntf所指向之INTFS_KEY_TABLE結構的dwNumIntfs成員必須設定為 0。 此外, pIntfs 成員必須設定為 Null

針對其他無線零組態函式的後續呼叫,應用程式必須提供 WZCEnumInterfaces 函式所傳回的相關重要資訊,來識別其運作的介面。

如果 WZCEnumInterfaces 傳回ERROR_SUCCESS,呼叫端應該呼叫 LocalFree ,以釋放為不再需要此資訊之後,為傳回的資料配置的內部緩衝區。

注意

Windows SDK 中無法使用 Wzcsapi.h 標頭檔與 Wzcsapi.lib 匯入程式庫檔案。

 

範例

下列範例會列舉無線零組態服務所管理本機電腦上的無線區域網路 介面,並列印每個介面的介面 GUID 值。

注意

此範例會在 Windows Vista 和更新版本上失敗。

 

#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;
}

規格需求

需求
最低支援的用戶端
具有 SP2 的 Windows XP [僅限傳統型應用程式]
最低支援的伺服器
Windows Server 2003 [僅限傳統型應用程式]
用戶端支援結束
Windows XP 與 SP3
伺服器終止支援
Windows Server 2003
標頭
Wzcsapi.h
程式庫
Wzcsapi.lib
DLL
Wzcsapi.dll

另請參閱

INTFS_KEY_TABLE

INTF_KEY_ENTRY

WZCEapolGetInterfaceParams

WZCQueryInterface

WZCRefreshInterface