RasDeleteEntryA 함수(ras.h)

RasDeleteEntry 함수는 전화 번호부에서 항목을 삭제합니다.

구문

DWORD RasDeleteEntryA(
  [in] LPCSTR unnamedParam1,
  [in] LPCSTR unnamedParam2
);

매개 변수

[in] unnamedParam1

전화 번호부(PBK) 파일의 전체 경로 및 파일 이름을 지정하는 null로 끝나는 문자열에 대한 포인터입니다. 이 매개 변수가 NULL인 경우 함수는 현재 기본 전화 번호부 파일을 사용합니다. 기본 전화 번호부 파일은 전화 접속 네트워킹 대화 상자의 사용자 기본 설정 속성 시트에서 사용자가 선택한 파일입니다.

Windows Me/98/95: 이 매개 변수는 항상 NULL이어야 합니다. 전화 접속 네트워킹은 전화 번호부 파일이 아닌 레지스트리에 전화 번호부 항목을 저장합니다.

[in] unnamedParam2

삭제할 기존 항목의 이름을 지정하는 null로 끝나는 문자열에 대한 포인터입니다.

반환 값

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

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

의미
ERROR_ACCESS_DENIED
사용자에게 올바른 권한이 없습니다. 관리자만 이 작업을 완료할 수 있습니다.
ERROR_INVALID_NAME
lpszEntry에 지정된 항목 이름이 없습니다.

설명

다음 샘플 코드는 lpszEntry 변수에 지정된 전화 번호부 항목을 삭제합니다.

#include <stdio.h>
#include <windows.h>
#include "ras.h"
#include "strsafe.h"

#define PHONE_NUMBER_LENGTH 7
#define DEVICE_NAME_LENGTH 5
#define DEVICE_TYPE_LENGTH 5

DWORD __cdecl wmain(){

    DWORD dwRet = ERROR_SUCCESS;
    LPTSTR lpszEntry = L"RASEntryName";
    LPTSTR lpszphonenumber = L"5555555";
    LPTSTR lpszdevicename = L"Modem";
    LPTSTR lpszdevicetype = RASDT_Modem;

    // Allocate heap memory for the RASENTRY structure
    LPRASENTRY lpentry = (LPRASENTRY)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RASENTRY));
    if (lpentry == NULL){
        printf("HeapAlloc failed");
        return 0;
       }
  
    // The RASENTRY->dwSize member has to be initialized or the RRAS APIs will fail below.
    lpentry->dwSize = sizeof(RASENTRY);
    lpentry->dwFramingProtocol = RASFP_Ppp;
    lpentry->dwfOptions = 0;
    lpentry->dwType = RASET_Phone;
    dwRet |= StringCchCopyN(lpentry->szLocalPhoneNumber, RAS_MaxPhoneNumber, lpszphonenumber, PHONE_NUMBER_LENGTH);
    dwRet |= StringCchCopyN(lpentry->szDeviceName, RAS_MaxDeviceName, lpszdevicename, DEVICE_NAME_LENGTH);
    dwRet |= StringCchCopyN(lpentry->szDeviceType, RAS_MaxDeviceType, lpszdevicetype, DEVICE_TYPE_LENGTH);
    if (dwRet != ERROR_SUCCESS){
        wprintf(L"RASENTRY structure initialization failed");
        HeapFree(GetProcessHeap(), 0, lpentry);
        return 0;
    }

    // Validate the new entry's name
    dwRet = RasValidateEntryName(NULL, lpszEntry);
    if (dwRet != ERROR_SUCCESS){
        wprintf(L"RasValidateEntryName failed: Error = %d\n", dwRet);
        HeapFree(GetProcessHeap(), 0, lpentry);
        return 0;
    }

    // Create and set the new entry's properties
    dwRet = RasSetEntryProperties(NULL, lpszEntry, lpentry, lpentry->dwSize, NULL, 0);
    if (dwRet != ERROR_SUCCESS){
        wprintf(L"RasSetEntryProperties failed: Error = %d\n", dwRet);
        HeapFree(GetProcessHeap(), 0, lpentry);
        return 0;
    }

    // Clean up: delete the new entry
    dwRet = RasDeleteEntry(NULL, lpszEntry);
    if (dwRet != ERROR_SUCCESS){
        wprintf(L"RasDeleteEntry failed: Error = %d\n", dwRet);
    }

    HeapFree(GetProcessHeap(), 0, lpentry);
    return 0;
}

참고

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

요구 사항

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

추가 정보

RasCreatePhonebookEntry

RasEnumEntries

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

원격 액세스 서비스 함수