RasEnumAutodialAddressesA 함수(ras.h)

RasEnumAutodialAddresses 함수는 AutoDial 매핑 데이터베이스의 모든 주소 목록을 반환합니다.

구문

DWORD RasEnumAutodialAddressesA(
  [in, out] LPSTR   *lppRasAutodialAddresses,
  [in, out] LPDWORD lpdwcbRasAutodialAddresses,
  [out]     LPDWORD lpdwcRasAutodialAddresses
);

매개 변수

[in, out] lppRasAutodialAddresses

버퍼 끝에 있는 문자열 자체의 스토리지에 대한 추가 공간이 있는 문자열 포인터 배열에 대한 포인터입니다.

출력 시 각 문자열은 AutoDial 매핑 데이터베이스의 주소 이름을 받습니다.

입력 시 lppAddressesNULL이면 RasEnumAutodialAddresseslpdwcbAddresseslpdwcAddresses 매개 변수를 설정하여 데이터베이스의 필요한 크기, 바이트 및 주소 항목 수를 나타냅니다.

[in, out] lpdwcbRasAutodialAddresses

입력 시 lpRasEnumAutodialAddressespAddresses 매개 변수로 지정된 버퍼의 크기(바이트)를 포함하는 변수에 대한 포인터입니다.

참고  

필요한 버퍼 크기를 확인하려면 lppAddressesNULL로 설정된 RasEnumAutodialAddresses를 호출합니다. lpdwcbAddresses에서 가리키는 변수를 0으로 설정해야 합니다. 함수는 lpdwcbAddresses 에서 필요한 버퍼 크기와 ERROR_BUFFER_TOO_SMALL 오류 코드를 반환합니다.

 

[out] lpdwcRasAutodialAddresses

lppAddresses 버퍼에 반환된 주소 문자열 수를 수신하는 변수에 대한 포인터입니다.

반환 값

함수가 성공하면 반환 값이 ERROR_SUCCESS.

함수가 실패하면 반환 값은 다음 오류 코드 중 하나이거나 라우팅 및 원격 액세스 오류 코드 또는 Winerror.h의 값입니다.

의미
ERROR_INVALID_PARAMETER
lpdwcbAddresses 또는 lpdwcAddresses 매개 변수에 대해 NULL 전달되었습니다.
ERROR_BUFFER_TOO_SMALL
lppAddresses 버퍼는 NULL이고 lpdwcbAddresses는 0이었습니다. 함수는 lpdwcbAddresses가 가리키는 변수에 필요한 버퍼 크기를 반환합니다.

설명

다음 코드 샘플 코드는 RasEnumAutodialAddresses 를 사용하여 Autodial 매핑 데이터베이스를 열거합니다.

#include <windows.h>
#include <stdio.h>
#include "ras.h"
#include "raserror.h"
#include <tchar.h>

DWORD __cdecl wmain(){

    DWORD dwBytes = 0;
    DWORD dwRet = ERROR_SUCCESS;
    DWORD dwAddresses = 0;
    LPTSTR * lppAddresses = NULL;
    LPCTSTR lpEntryAddress = L"www.microsoft.com";

    // Allocate memory for a new Autodial address to add to the mapping database
    LPRASAUTODIALENTRY lpentry = (LPRASAUTODIALENTRY) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RASAUTODIALENTRY));
    lpentry->dwSize = sizeof(RASAUTODIALENTRY);

    // Add a (non-functional) address to the Autodial mapping database
    // (this ensures RasEnumAutodialAddresses() has something to return)
    dwRet = RasSetAutodialAddress(lpEntryAddress, 0, lpentry, lpentry->dwSize, 1);
    
    // Call RasEnumAutodialAddresses() with lppAddresses = NULL. dwBytes is returned with the 
    // required buffer size and a return code of ERROR_BUFFER_TOO_SMALL
    dwRet = RasEnumAutodialAddresses(lppAddresses, &dwBytes, &dwAddresses);

    if (dwRet == ERROR_BUFFER_TOO_SMALL){
        // Allocate the memory needed for the array of RAS Autodial addresses.
        lppAddresses = (LPTSTR *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwBytes);
        if (lppAddresses == NULL){
            wprintf(L"HeapAlloc failed!\n");
            return 0;
        }
        
        // Call RasEnumAutodialAddresses() to enumerate all RAS Autodial addresses
        dwRet = RasEnumAutodialAddresses(lppAddresses, &dwBytes, &dwAddresses);

        // If successful, print the RAS Autodial addresses
        if (dwRet == ERROR_SUCCESS){
            wprintf(L"The following RAS Autodial addresses were found:\n");
            for (DWORD i = 0; i < dwAddresses; i++){
                wprintf(L"%s\n", lppAddresses[i]);
            }
        }
        // Remove the address
        dwRet = RasSetAutodialAddress(lpEntryAddress, 0, NULL, 0, 0);
        
        //Deallocate memory for the address buffers
        HeapFree(GetProcessHeap(), 0, lppAddresses);    
        HeapFree(GetProcessHeap(), 0, lpentry);
        lppAddresses = NULL;
        return 0;
    }

    // There was either a problem with RAS or there are no RAS Autodial addresses to enumerate
    if(dwAddresses >= 1){
        wprintf(L"The operation failed to acquire the buffer size.\n");
    }else{
        wprintf(L"There were no RAS Autodial addresses found.\n");
    }

    // Remove the address
    dwRet = RasSetAutodialAddress(lpEntryAddress, 0, NULL, 0, 0);
    HeapFree(GetProcessHeap(), 0, lpentry);
    return 0;
}

참고

ras.h 헤더는 RAsEnumAutodialAddresses를 유니코드 전처리기 상수의 정의에 따라 이 함수의 ANSI 또는 유니코드 버전을 자동으로 선택하는 별칭으로 정의합니다. 인코딩 중립 별칭을 인코딩 중립이 아닌 코드와 혼합하면 컴파일 또는 런타임 오류가 발생하는 불일치가 발생할 수 있습니다. 자세한 내용은 함수 프로토타입에 대한 규칙을 참조하세요.

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows 2000 Professional[데스크톱 앱만]
지원되는 최소 서버 Windows 2000 Server[데스크톱 앱만]
대상 플랫폼 Windows
헤더 ras.h
라이브러리 Rasapi32.lib
DLL Rasapi32.dll

추가 정보

RASAUTODIALENTRY

RasGetAutodialAddress

RasSetAutodialAddress

RAS(원격 액세스 서비스) 개요

원격 액세스 서비스 함수