NetRemoteTOD 함수(lmremutl.h)

NetRemoteTOD 함수는 지정된 서버에서 하루 중 시간 정보를 반환합니다.

구문

NET_API_STATUS NET_API_FUNCTION NetRemoteTOD(
  [in]  LPCWSTR UncServerName,
  [out] LPBYTE  *BufferPtr
);

매개 변수

[in] UncServerName

함수를 실행할 원격 서버의 DNS 또는 NetBIOS 이름을 지정하는 상수 문자열에 대한 포인터입니다. 이 매개 변수가 NULL이면 로컬 컴퓨터가 사용됩니다.

[out] BufferPtr

TIME_OF_DAY_INFO 정보 구조를 수신하는 주소에 대한 포인터입니다. 이 버퍼는 시스템에서 할당되며 NetApiBufferFree 함수를 사용하여 해제해야 합니다.

반환 값

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

함수가 실패하면 반환 값은 시스템 오류 코드입니다. 오류 코드 목록은 시스템 오류 코드를 참조하세요.

설명

NetRemoteTOD 함수를 성공적으로 실행하려면 특별한 그룹 멤버 자격이 필요하지 않습니다.

예제

다음 코드 샘플에서는 NetRemoteTOD 함수를 호출하여 현재 날짜와 시간을 검색하고 인쇄하는 방법을 보여 줍니다. 이를 위해 샘플은 TIME_OF_DAY_INFO 구조를 사용합니다. 마지막으로 샘플은 정보 버퍼에 할당된 메모리를 해제합니다.

#include <stdio.h>
#include <windows.h> 
#include <lm.h>
#pragma comment(lib, "netapi32.lib")

#ifndef UNICODE
#define UNICODE
#endif

int wmain(int argc, wchar_t *argv[])
{
   LPTIME_OF_DAY_INFO pBuf = NULL;
   NET_API_STATUS nStatus;
   LPTSTR pszServerName = NULL;

   if (argc > 2)
   {
      fwprintf(stderr, L"Usage: %s [\\\\ServerName]\n", argv[0]);
      exit(1);
   }
   // The server is not the default local computer.
   //
   if (argc == 2)
      pszServerName = (LPTSTR) argv[1];
   //
   // Call the NetRemoteTOD function.
   //
   nStatus = NetRemoteTOD((LPCWSTR) pszServerName,
                          (LPBYTE *)&pBuf);
   //
   // If the function succeeds, display the current date and time.
   //
   if (nStatus == NERR_Success)
   {
      if (pBuf != NULL)
      {
         fprintf(stderr, "\nThe current date is: %d/%d/%d\n",
                 pBuf->tod_month, pBuf->tod_day, pBuf->tod_year);
         fprintf(stderr, "The current time is: %d:%d:%d\n",
                 pBuf->tod_hours, pBuf->tod_mins, pBuf->tod_secs);
      }
   }
   //
   // Otherwise, display a system error.
   else
      fprintf(stderr, "A system error has occurred: %d\n", nStatus);
   //
   // Free the allocated buffer.
   //
   if (pBuf != NULL)
      NetApiBufferFree(pBuf);

   return 0;
}

요구 사항

   
지원되는 최소 클라이언트 Windows 2000 Professional[데스크톱 앱만]
지원되는 최소 서버 Windows 2000 Server[데스크톱 앱만]
대상 플랫폼 Windows
헤더 lmremutl.h(Lm.h 포함)
라이브러리 Netapi32.lib
DLL Netapi32.dll

참고 항목

네트워크 관리 함수

네트워크 관리 개요

원격 유틸리티 함수

TIME_OF_DAY_INFO