다음을 통해 공유


PosExplorer 클래스(.NET용 POS v1.14 SDK 설명서)

PosExplorer는 .NET용 Microsoft Point of Service(.NET용 POS) 서비스에 대한 단일 진입점이 있는 POS(서비스 지점) 애플리케이션을 제공합니다. PosExplorer는 다음을 통해 애플리케이션을 지원합니다.

  • 설치된 POS 디바이스 열거.
  • 서비스 개체 인스턴스화.
  • POS 주변 디바이스가 연결되거나 연결이 끊어지는 경우 플러그 앤 플레이 이벤트 수신.

PosExplorer 속성

다음 표에서는 PosExplorer 속성에 대해 설명합니다.

속성 Type 설명
PosRegistryKey 문자열 HKEY_LOCAL_MACHINE을 기준으로 .NET 구성 루트 레지스트리 키에 대한 POS를 반환합니다.
StatisticsFile 문자열 디바이스 통계가 포함된 파일의 경로를 반환합니다.
SynchronizingObject ISynchronizeInvoke ISynchronizeInvoke 개체를 포함합니다.

PosExplorer 메서드

다음 표에서는 PosExplorer 메서드에 대해 설명합니다.

메서드 반환 형식 설명
CreateInstance PosDevice 디바이스에 대한 서비스 개체를 인스턴스화합니다.
GetDevice DeviceInfo 지정된 형식의 디바이스를 반환합니다(시스템에서 하나만 있어야 합니다).
GetDevice DeviceInfo 지정된 논리적 이름 또는 별칭을 가진 형식의 디바이스를 반환합니다.
GetDevices DeviceCollection 모든 POS 디바이스를 반환합니다.
GetDevices DeviceCollection 지정된 호환성 수준을 가진 모든 POS 디바이스를 반환합니다.
GetDevices DeviceCollection 해당 형식의 POS 디바이스를 반환합니다.
GetDevices DeviceCollection 해당 형식과 지정된 호환성 수준의 POS 디바이스를 반환합니다.
새로 고침 없음 연결된 POS 디바이스 목록을 다시 열거하고 내부 데이터 구조를 다시 빌드합니다.

PosExplorer 이벤트

다음 표에서는 PosExplorer 이벤트에 대해 설명합니다.

이벤트 설명
DeviceAddedEvent 플러그 앤 플레이 호환되는 POS 디바이스가 연결된 경우 수신됩니다.
DeviceRemovedEvent 플러그 앤 플레이 호환되는 POS 디바이스의 연결이 끊어지면 수신됩니다.

다음 코드 예제에서는 PosExplorer의 인스턴스를 만들고, 플러그 앤 플레이 이벤트에 연결하고, 이를 사용하여 연결된 모든 MSR(자기 줄무늬 판독기) 디바이스를 식별하는 방법을 보여줍니다. 코드 예제에서는 MSR에 관한 정보를 콘솔에 출력하며, 출력이 완료되면 디바이스를 닫습니다.

// Creates a new instance of an MSR.
void CreateMsr(DeviceInfo msrinfo)
{
    msr = (Msr)explorer.CreateInstance(msrinfo);
    msr.Open();
    msr.Claim(1000);
    msr.DeviceEnabled = true;
}

static void Main(string[] args)
{

    // Create a new instance of PosExplorer and use it to
    // collect device information.
    PosExplorer explorer = new PosExplorer();
    DeviceCollection devices = explorer.GetDevices();

    // Search all connected devices for an MSR, print its service
    // object name to the console, and close it when finished.
    foreach (DeviceInfo device in devices)
    {
      if (device.Type == DeviceType.Msr)
      {
         if (device.ServiceObjectName == currentMsr)
         {
            CreateMsr(device);
            Console.WriteLine(device.ServiceObjectName);

            // It is important that applications close all open
            // Service Objects before terminating.
            msr.Close();
            msr = null;
         }
      }
    }
}

참고 항목

개념

기타 리소스