//---------------------------------------------------------------------------- // // Copyright (c) Intel Corporation, 2010-2014 All Rights Reserved. // //---------------------------------------------------------------------------- using System; using System.IO; using Intel.Manageability; using Intel.Manageability.Exceptions; using Common.Utils; using System.Runtime.InteropServices; namespace TimeSynchronizationSample { class Program { [DllImport("kernel32.dll", CallingConvention = CallingConvention.StdCall)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetDefaultDllDirectories(int directoryFlags); static void Main(string[] args) { // set default dll lookup directory to system SetDefaultDllDirectories(0x00000800); //LOAD_LIBRARY_SEARCH_SYSTEM32 IAMTInstance amt = null; ConnectionInfoEX ci = null; try { // Check if JSON path was provided as an argument. If not, default path would be used. try { ci = ProgramInput.DeserializeJsonToStruct(args.Length > 0 ? args[0] : null); } catch (IOException e) { Console.WriteLine($"Could not read argument file: {e.Message}"); return; } amt = AMTInstanceFactory.CreateEX(ci); } catch (ManageabilityException e) { ci?.Dispose(); Console.WriteLine(e.Message); return; } try { // Print the Intel AMT network time before the setting. TimeSynchronizationFunctionality.GetNetworkTime(amt); // Set the Intel AMT network time. TimeSynchronizationFunctionality.SetNetworkTime(amt); // Print the Intel AMT network time after the setting. TimeSynchronizationFunctionality.GetNetworkTime(amt); // Print the Intel AMT's sync time enabled state. // Available since Intel AMT 9.0 only. TimeSynchronizationFunctionality.GetSyncTimeEnabledState(amt); // Set the Intel AMT's sync time enabled state. // Available since Intel AMT 9.0 only. TimeSynchronizationFunctionality.SetSyncTimeState(amt); // Print the Intel AMT network time setter. // Available since Intel AMT 9.0 only. TimeSynchronizationFunctionality.GetTimeSetter(amt); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { amt?.Dispose(); } } } }