Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than netapi32, prefix the name with the module name and a period.
NetRemoteTOD (netapi32)
.
C# Signature:
[DllImport("Netapi32.dll", CharSet=CharSet.Unicode)]
static extern int NetRemoteTOD(string UncServerName, ref IntPtr BufferPtr);
VB Signature:
<DllImport("netapi32", CharSet:=CharSet.Unicode)> Function NetRemoteTOD( _
ByVal UncServerName As String, ByRef BufferPtr As IntPtr) As Integer
End Function!!!!User-Defined Types:
Declare Function NetRemoteTOD Lib "Netapi32.dll" (TODO) As TODO
public class GetNetRemoteTOD
{
#region API
[DllImport( "netapi32.dll" , EntryPoint="NetRemoteTOD", SetLastError=true,
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)] private static extern int NetRemoteTOD(string UncServerName, ref IntPtr BufferPtr);
[DllImport( "netapi32.dll")] private static extern void NetApiBufferFree(IntPtr bufptr);
[StructLayout(LayoutKind.Sequential)]
public struct structTIME_OF_DAY_INFO
{
public int itod_elapsedt;
public int itod_msecs;
public int itod_hours;
public int itod_mins;
public int itod_secs;
public int itod_hunds;
public int itod_timezone;
public int itod_tinterval;
public int itod_day;
public int itod_month;
public int itod_year;
public int itod_weekday;
}
#endregion
#region Core functions
public int [] xNetRemoteTOD( string ServerName )
{
structTIME_OF_DAY_INFO result = new structTIME_OF_DAY_INFO();
IntPtr pintBuffer = IntPtr.Zero;
int[] TOD_INFO = new int[12];
// Get the time of day.
int pintError = NetRemoteTOD(ServerName, ref pintBuffer);
if ( pintError > 0 ) { throw new System.ComponentModel.Win32Exception ( pintError ); }
// Get the structure.
result = (structTIME_OF_DAY_INFO)Marshal.PtrToStructure(pintBuffer, typeof(structTIME_OF_DAY_INFO));
If you need to get the time from a domain controller:
using System.DirectoryServices.ActiveDirectory;
DomainControllerCollection controllers = Domain.GetCurrentDomain().DomainControllers;
foreach (DomainController c in controllers)
Console.WriteLine(c.CurrentTime);
Returns the time of day information from a specified server.
2/11/2008 9:44:46 AM - -85.176.13.93
Frees the memory allocated by network management functions.
6/21/2016 8:26:32 AM - -63.226.251.37
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 4:00:13 AM - Damon Carr-72.43.165.29
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).