Aracılığıyla paylaş


Device.GetSystemInfo Method

Gets the system information of the device.

Namespace:  Microsoft.SmartDevice.Connectivity
Assembly:  Microsoft.SmartDevice.Connectivity (in Microsoft.SmartDevice.Connectivity.dll)

Syntax

'Declaration
Public Function GetSystemInfo As SystemInfo
'Usage
Dim instance As Device 
Dim returnValue As SystemInfo 

returnValue = instance.GetSystemInfo()
public SystemInfo GetSystemInfo()
public:
SystemInfo^ GetSystemInfo()
public function GetSystemInfo() : SystemInfo

Return Value

Type: Microsoft.SmartDevice.Connectivity.SystemInfo
Returns a class of type SystemInfo.

Exceptions

Exception Condition
DeviceNotConnectedException

The device is not connected.

SmartDeviceException

A COM exception occurred.

Remarks

The device must be connected.

The return value includes system information for the device such as operating system version information, page-file info, virtual memory consumption and usage, battery life details, and physical memory consumption and usage. For more information, see SystemInfo.

Examples

' Connect to the device.
device.Connect()

' If the device is connected, retrieve system information and output to console. 
If device.IsConnected() Then 
    Dim info As SystemInfo = device.GetSystemInfo()

    Console.WriteLine("Total Page File:  " + info.TotalPageFile.ToString())
    Console.WriteLine("Available Page File:  " + info.AvailPageFile.ToString())
    Console.WriteLine("Page Size:  " + info.PageSize.ToString() + vbCr + vbLf)

    Console.WriteLine("Total RAM:  " + info.TotalPhys.ToString())
    Console.WriteLine("Available RAM:  " + info.AvailPhys.ToString() + vbCr + vbLf)

    Console.WriteLine("Total Virtual Memory:  " + info.TotalVirtual.ToString())
    Console.WriteLine("Available Virtual Memory:  " + _
                      info.AvailVirtual.ToString() + vbCr + vbLf)

    If info.ACLineStatus = 1 Then
        Console.WriteLine("AC Line plugged in.")
    ElseIf info.ACLineStatus = 0 Then
        Console.WriteLine("AC Line unplugged.")
    End If

    Console.WriteLine("Main Battery:  " + info.BatteryFlag.ToString())
    Console.WriteLine("   Capacity:  " + info.BatteryFullLifetime.ToString())
    Console.WriteLine("   Percent:  " + info.BatteryLifePercent.ToString())
    Console.WriteLine("   Life:  " + info.BatteryLifetime.ToString())


    Console.WriteLine("Device Time:  " + info.CurrentTime.ToString())

    Console.WriteLine("Processor Architecture:  " + _
                      info.ProcessorArchitecture.ToString())
    Console.WriteLine("Instruction Set:  " + info.InstructionSet.ToString())
    Console.WriteLine("Number of CPU:  " + info.NumberOfProcessors.ToString())
    Console.WriteLine("OS:  " + info.OSMajor.ToString() + "." + _
                      info.OSMinor.ToString() & _
                      "." + info.OSBuildNo.ToString())
    Console.WriteLine("Locale ID:  " + info.SystemDefaultLocaleId.ToString())

    ' Query Device for current security policies  
    Dim readxml As String = "<wap-provisioningdoc>" & _
    "<characteristic type=""SecurityPolicy"">" & _
    "<parm-query name=""4123""/>" & _
    "<parm-query name=""4122""/>" & _
    "<parm-query name=""4101""/>" & _
    "<parm-query name=""4102""/>" & _
    "<parm-query name=""4097""/>" & _
    "</characteristic>" & _
    "</wap-provisioningdoc>"

    Console.WriteLine(device.ProvisionDevice(readxml, _
                                             device.ConfigActions.ProcessInput))

    ' Deploy two-tier prompt security configuration to device and see changes 
    Dim provisionxml As String = "<wap-provisioningdoc>" & _
    "<characteristic type=""SecurityPolicy"">" & _
    "<parm name=""4123"" value=""0"" />" & _
    "<parm name=""4122"" value=""0"" />" & _
    "<parm name=""4101"" value=""16"" />" & _
    "<parm name=""4102"" value=""1"" />" & _
    "<parm name=""4097"" value=""2"" />" & _
    "</characteristic>" & _
    "</wap-provisioningdoc>"

    Console.WriteLine(device.ProvisionDevice(provisionxml, _
                                             device.ConfigActions.ProcessInput))

    ' Read metadata about the policies
    Console.WriteLine(device.ProvisionDevice(readxml, _
                                             device.ConfigActions.ReadMetadata))
    device.Disconnect()
    Console.ReadLine()
End If
// Connect to the device.
            device.Connect();

            // If the device is connected, retrieve system information and output to console. 
            if (device.IsConnected())
            {
                SystemInfo info = device.GetSystemInfo();

                Console.WriteLine("Total Page File:  " + info.TotalPageFile.ToString());
                Console.WriteLine("Available Page File:  " + info.AvailPageFile.ToString());
                Console.WriteLine("Page Size:  " + info.PageSize.ToString() + "\r\n");

                Console.WriteLine("Total RAM:  " + info.TotalPhys.ToString());
                Console.WriteLine("Available RAM:  " + info.AvailPhys.ToString() + "\r\n");

                Console.WriteLine("Total Virtual Memory:  " + info.TotalVirtual.ToString());
                Console.WriteLine("Available Virtual Memory:  " + info.AvailVirtual.ToString()
                    + "\r\n");

                if (info.ACLineStatus == 1)
                {
                    Console.WriteLine("AC Line plugged in.");
                }
                else if(info.ACLineStatus == 0)
                {
                    Console.WriteLine("AC Line unplugged.");
                }
                Console.WriteLine("Main Battery Flag:  " + info.BatteryFlag.ToString());
                Console.WriteLine("   Capacity:  " + info.BatteryFullLifetime.ToString());
                Console.WriteLine("   Percent:  " + info.BatteryLifePercent.ToString());
                Console.WriteLine("   Life:  " + info.BatteryLifetime.ToString());

                Console.WriteLine("Device Time:  " + info.CurrentTime.ToString());

                Console.WriteLine("Processor Architecture:  " + 
                    info.ProcessorArchitecture.ToString());
                Console.WriteLine("Instruction Set:  " + info.InstructionSet.ToString());
                Console.WriteLine("Number of CPU:  " + info.NumberOfProcessors.ToString());
                Console.WriteLine("OS:  " + info.OSMajor.ToString() + "." + 
                    info.OSMinor.ToString() + 
                                  "." + info.OSBuildNo.ToString());
                Console.WriteLine("Locale ID:  " + info.SystemDefaultLocaleId.ToString());

                // Query Device for current security policies  
                string readxml = @"
<wap-provisioningdoc>
    <characteristic type=""SecurityPolicy"">
        <parm-query name=""4123""/>
        <parm-query name=""4122""/>
        <parm-query name=""4101""/>
        <parm-query name=""4102""/>
        <parm-query name=""4097""/>
    </characteristic>
</wap-provisioningdoc>";
                Console.WriteLine(device.ProvisionDevice(readxml, 
                    Device.ConfigActions.ProcessInput));

                // Deploy two-tier prompt security configuration to device and see changes 
                string provisionxml = @"
<wap-provisioningdoc>
    <characteristic type=""SecurityPolicy"">
        <parm name=""4123"" value=""0"" />
        <parm name=""4122"" value=""0"" />
        <parm name=""4101"" value=""16"" />
        <parm name=""4102"" value=""1"" />
        <parm name=""4097"" value=""2"" />
    </characteristic>
</wap-provisioningdoc>";
                Console.WriteLine(device.ProvisionDevice(provisionxml, 
                    Device.ConfigActions.ProcessInput));

                // Read metadata about the policies
                Console.WriteLine(device.ProvisionDevice(readxml, 
                    Device.ConfigActions.ReadMetadata));

                device.Disconnect();
                Console.ReadLine();
            }

.NET Framework Security

See Also

Reference

Device Class

Device Members

Microsoft.SmartDevice.Connectivity Namespace