On Oct 29, 2:03 pm, trytobr...@gmail.com wrote:
Sorry, I have overlooked...
I am researching now the NetRemoteTOD. Quite interesting.
Thanks, lets see if I can get it to work.
Here is some c# code, I wrote to try out this function. You could
convert this to vb, and modify it to loop through a list of machines
- either from a file, or enumerating the machines on the network.
class Program
{
static void Main ( string[] args )
{
IntPtr handle = IntPtr.Zero;
if (NetRemoteTOD ( "\\\\yournetworkpc", ref handle ) ==
NERR_Success)
{
TIME_OF_DAY_INFO time =
(TIME_OF_DAY_INFO)Marshal.PtrToStructure ( handle, typeof
( TIME_OF_DAY_INFO ) );
// new date time. The hours are in utc, so you hae to
use the timezone
// offset.
DateTime dt = new DateTime ( (int)time.tod_year,
(int)time.tod_month, (int)time.tod_day, (int)(time.tod_hours -
(time.tod_timezone / 60)), (int)time.tod_mins, (int)time.tod_secs );
Console.WriteLine ( dt );
uint result = NetApiBufferFree ( handle );
if (result != NERR_Success)
Console.WriteLine ( "Memory cleanup failed: {0}",
result );
}
}
private const uint NERR_Success = 0;
/// <summary>
/// Free the buffer allocated by the NetRemoteTOD function
/// </summary>
/// <param name="Buffer">pointer to the buffer</param>
/// <returns>NERR_Success on success, else the system error
code.</returns>
[DllImport("netapi32.dll", SetLastError=false)]
private static extern uint NetApiBufferFree ( IntPtr Buffer );
[DllImport ( "netapi32.dll", CharSet = CharSet.Unicode,
SetLastError = false )]
private static extern uint NetRemoteTOD ( string
UncServerName, ref IntPtr BufferPtr );
[StructLayout(LayoutKind.Sequential)]
private struct TIME_OF_DAY_INFO
{
public uint tod_elapsedt;
public uint tod_msecs;
public uint tod_hours;
public uint tod_mins;
public uint tod_secs;
public uint tod_hunds;
public uint tod_timezone;
public uint tod_tinterval;
public uint tod_day;
public uint tod_month;
public uint tod_year;
public uint tod_weekday;
}
}