网站首页  词典首页

请输入您要查询的函数:

 

术语 netremotetod
释义 NetRemoteTOD
语法:
C++
NET_API_STATUS NetRemoteTOD(
__in LPCWSTR UncServerName,
__out LPBYTE *BufferPtr
);
NetRemoteTOD功能
该NetRemoteTOD函数返回天信息到指定的服务器的时间。
参数
UncServerName [in]
指针常量字符串指定的DNS或NetBIOS的远程服务器上的功能是执行的名称。如果该参数为NULL,则使用本地计算机。
BufferPtr [out]
指针的地址,它接收TIME_OF_DAY_INFO信息结构。此缓冲区分配制度,必须使用NetApiBufferFree释放功能。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值是一个系统错误代码。对于一个错误代码的列表,请参见系统错误代码。
备注
没有特殊组成员必须成功地执行NetRemoteTOD功能。
实例
下面的代码示例演示如何检索和打印向NetRemoteTOD函数调用当前的日期和时间。为此,该示例使用TIME_OF_DAY_INFO结构。最后,该示例释放的信息缓冲区分配的内存。
#include
#include
#include
#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;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmremutl.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
网络管理概述
网络管理功能
远程实用功能
TIME_OF_DAY_INFO
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月13日
==英文原文==NetRemoteTOD Function
The NetRemoteTOD function returns the time of day information from a specified server.
Syntax
C++
NET_API_STATUS NetRemoteTOD(
__in LPCWSTR UncServerName,
__out LPBYTE *BufferPtr
);
Parameters
UncServerName [in]
Pointer to a constant string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used.
BufferPtr [out]
Pointer to the address that receives the TIME_OF_DAY_INFO information structure. This buffer is allocated by the system and must be freed using the NetApiBufferFree function.
Return Value
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes .
Remarks
No special group membership is required to successfully execute the NetRemoteTOD function.
Examples
The following code sample demonstrates how to retrieve and print the current date and time with a call to the NetRemoteTOD function. To do this, the sample uses the TIME_OF_DAY_INFO structure. Finally, the sample frees the memory allocated for the information buffer.
#include
#include
#include
#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;
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderLmremutl.h (include Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
See Also
Network Management Overview
Network Management Functions
Remote Utility Functions
TIME_OF_DAY_INFO
Send comments about this topic to Microsoft
Build date: 8/13/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa370612(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:29:38