//---------------------------------------------------------------------------- // // Copyright (c) Intel Corporation, 2011 - 2014 All Rights Reserved. // //---------------------------------------------------------------------------- using System; using System.Collections; using System.Security; using Intel.Manageability; using Intel.Manageability.Exceptions; using Common.Utils; using System.IO; using System.Runtime.InteropServices; namespace EventLogSample { 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 in CMD. If empty, default directory file will be selected 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 { //Getting the current number of record in the log. LogEventFunctionality.CurrentNumberOfRecord(amt); //Getting existing records in the log. LogEventFunctionality.GetAllRecords(amt); //Getting existing specific records in the log. LogEventFunctionality.GetRecords(amt, 3, 20); //Register Event Filter to recorded in the log. LogEventFunctionality.RegisterToLog(amt); //Unegister Event Filter that recorded in the log. LogEventFunctionality.UnRegisterToLog(amt); //Freeze the log. so, modifications in the log, are not allowed LogEventFunctionality.FreezeLog(amt); ////Unfreeze the log. so, modifications in the log, are allowed LogEventFunctionality.UnFreezeLog(amt); //Delete all records from the log. LogEventFunctionality.ClearLog(amt); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { amt?.Dispose(); } } } }