109 lines
3.6 KiB
C#

//----------------------------------------------------------------------------
//
// Copyright (c) Intel Corporation, 2010-2014 All Rights Reserved.
//
//----------------------------------------------------------------------------
using System;
using Intel.Manageability;
using Intel.Manageability.Exceptions;
using Common.Utils;
using System.IO;
using System.Runtime.InteropServices;
namespace HardwareAssetSample
{
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
{
// Set that the tables will be updated on the next boot.
HardwareAssetFunctionality.EnableUpdateMediaTable(amt);
// Print the BIOS info
HardwareAssetFunctionality.PrintBIOSes_Info(amt);
// Print the Baseboard info
HardwareAssetFunctionality.PrintBaseboards(amt);
// Print the Computer System info
HardwareAssetFunctionality.PrintComputerSystem(amt);
// Print the Fans info
HardwareAssetFunctionality.PrintFans(amt);
// Print the FRUs info
HardwareAssetFunctionality.PrintFRUs(amt);
// Print the Media Devices info
HardwareAssetFunctionality.PrintMediaDevices(amt);
// Print the Memory Modules info
HardwareAssetFunctionality.PrintMemoryModules(amt);
// Print the Power Supplies info
HardwareAssetFunctionality.PrintPowerSupplies(amt);
// Print the Processors info
HardwareAssetFunctionality.PrintProcessors(amt);
// Print the Sensors info
HardwareAssetFunctionality.PrintSensors(amt);
// Print the Batteries info (Supported from AMT 12.0 and later)
HardwareAssetFunctionality.PrintBatteriesEx(amt);
// Print the Vpro Verification Table
HardwareAssetFunctionality.PrintVproVerificationTable(amt);
// Print the Amt Information
HardwareAssetFunctionality.PrintAmtInformation(amt);
// Disable table update.
HardwareAssetFunctionality.DisableUpdateMediaTable(amt);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
amt?.Dispose();
}
}
}
}