using System; using System.Runtime.InteropServices; namespace Vanara.PInvoke { public static partial class NetApi32 { /// /// A set of bit flags indicating the features of interest in OptionsWanted or features supported OptionsSupported in . /// [PInvokeData("lmremutl.h", MSDNShortId = "e807489a-250e-4d4c-adb6-eff8ac30603b")] [Flags] public enum RemoteSupportFlags : uint { /// Requests Remote Administration Protocol support. SUPPORTS_REMOTE_ADMIN_PROTOCOL = 0x00000002, /// Requests RPC support. SUPPORTS_RPC = 0x00000004, /// Requests Security Account Manager (SAM) support. SUPPORTS_SAM_PROTOCOL = 0x00000008, /// Requests Unicode standard support. SUPPORTS_UNICODE = 0x00000010, /// /// Requests support for the first three values listed in this table. If UNICODE is defined by the calling application, requests /// the four features listed previously. /// SUPPORTS_LOCAL = 0x00000020, /// Requests all supported options. SUPPORTS_ANY = 0xFFFFFFFF, } /// /// The NetRemoteComputerSupports function queries the redirector to retrieve the optional features the remote system /// supports. Features include Unicode, Remote Procedure Call (RPC), and Remote Administration Protocol support. The function /// establishes a network connection if one does not exist. /// /// /// Pointer to a constant string that specifies the name of the remote server to query. If this parameter is NULL, the local /// computer is used. /// /// /// /// Specifies a value that contains a set of bit flags indicating the features of interest. This parameter must be at least one of /// the following values. /// /// /// /// Value /// Meaning /// /// /// SUPPORTS_REMOTE_ADMIN_PROTOCOL /// Requests Remote Administration Protocol support. /// /// /// SUPPORTS_RPC /// Requests RPC support. /// /// /// SUPPORTS_SAM_PROTOCOL /// Requests Security Account Manager (SAM) support. /// /// /// SUPPORTS_UNICODE /// Requests Unicode standard support. /// /// /// SUPPORTS_LOCAL /// /// Requests support for the first three values listed in this table. If UNICODE is defined by the calling application, requests the /// four features listed previously. /// /// /// /// /// /// /// Pointer to a value that receives a set of bit flags. The flags indicate which features specified by the OptionsWanted parameter /// are implemented on the computer specified by the UncServerName parameter. (All other bits are set to zero.) /// /// The value of this parameter is valid only when the NetRemoteComputerSupports function returns NERR_Success. /// /// /// If the function succeeds, the return value is NERR_Success. /// If the function fails, the return value can be one of the following error codes. /// /// /// Return code /// Description /// /// /// ERROR_INVALID_PARAMETER /// Either the OptionsWanted parameter or the OptionsSupported parameter is NULL; both parameters are required. /// /// /// ERROR_NOT_ENOUGH_MEMORY /// Insufficient memory is available. /// /// /// /// No special group membership is required to successfully execute the NetRemoteComputerSupports function. // https://docs.microsoft.com/en-us/windows/desktop/api/lmremutl/nf-lmremutl-netremotecomputersupports NET_API_STATUS // NET_API_FUNCTION NetRemoteComputerSupports( IN LPCWSTR UncServerName, IN DWORD OptionsWanted, OUT LPDWORD OptionsSupported ); [DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("lmremutl.h", MSDNShortId = "e807489a-250e-4d4c-adb6-eff8ac30603b")] public static extern Win32Error NetRemoteComputerSupports([MarshalAs(UnmanagedType.LPWStr), Optional] string UncServerName, RemoteSupportFlags OptionsWanted, out RemoteSupportFlags OptionsSupported); /// The NetRemoteTOD function returns the time of day information from a specified server. /// /// 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. /// /// /// 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. /// /// /// 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. /// /// /// 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. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/lmremutl/nf-lmremutl-netremotetod NET_API_STATUS NET_API_FUNCTION // NetRemoteTOD( LPCWSTR UncServerName, LPBYTE *BufferPtr ); [DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("lmremutl.h", MSDNShortId = "5a935e09-f188-4ee1-b998-c67488475baa")] public static extern Win32Error NetRemoteTOD([MarshalAs(UnmanagedType.LPWStr), Optional] string UncServerName, out SafeNetApiBuffer BufferPtr); /// The TIME_OF_DAY_INFO structure contains information about the time of day from a remote server. // https://docs.microsoft.com/en-us/windows/desktop/api/lmremutl/ns-lmremutl-_time_of_day_info typedef struct _TIME_OF_DAY_INFO { // DWORD tod_elapsedt; DWORD tod_msecs; DWORD tod_hours; DWORD tod_mins; DWORD tod_secs; DWORD tod_hunds; LONG tod_timezone; DWORD // tod_tinterval; DWORD tod_day; DWORD tod_month; DWORD tod_year; DWORD tod_weekday; } TIME_OF_DAY_INFO, *PTIME_OF_DAY_INFO, *LPTIME_OF_DAY_INFO; [PInvokeData("lmremutl.h", MSDNShortId = "bf89f071-5c04-40c2-a7b7-4e59fc9eaa02")] [StructLayout(LayoutKind.Sequential)] public struct TIME_OF_DAY_INFO { /// /// Type: DWORD /// The number of seconds since 00:00:00, January 1, 1970, GMT. /// public uint tod_elapsedt; /// /// Type: DWORD /// The number of milliseconds from an arbitrary starting point (system reset). /// /// Typically, this member is read twice, once when the process begins and again at the end. To determine the elapsed time /// between the process's start and finish, you can subtract the first value from the second. /// /// public uint tod_msecs; /// /// Type: DWORD /// The current hour. Valid values are 0 through 23. /// public uint tod_hours; /// /// Type: DWORD /// The current minute. Valid values are 0 through 59. /// public uint tod_mins; /// /// Type: DWORD /// The current second. Valid values are 0 through 59. /// public uint tod_secs; /// /// Type: DWORD /// The current hundredth second (0.01 second). Valid values are 0 through 99. /// public uint tod_hunds; /// /// Type: LONG /// /// The time zone of the server. This value is calculated, in minutes, from Greenwich Mean Time (GMT). For time zones west of /// Greenwich, the value is positive; for time zones east of Greenwich, the value is negative. A value of –1 indicates that the /// time zone is undefined. /// /// public int tod_timezone; /// /// Type: DWORD /// The time interval for each tick of the clock. Each integral integer represents one ten-thousandth second (0.0001 second). /// public uint tod_tinterval; /// /// Type: DWORD /// The day of the month. Valid values are 1 through 31. /// public uint tod_day; /// /// Type: DWORD /// The month of the year. Valid values are 1 through 12. /// public uint tod_month; /// /// Type: DWORD /// The year. /// public uint tod_year; /// /// Type: DWORD /// The day of the week. Valid values are 0 through 6, where 0 is Sunday, 1 is Monday, and so on. /// public uint tod_weekday; } } }