/*// Declare the parameters for the cmdlet.
         * [Parameter(Mandatory = true)]
         * public string Name
         * {
         *  get { return name; }
         *  set { name = value; }
         * }
         * private string name;*/

        // Overide the ProcessRecord method to process
        // the supplied user name and write out a
        // greeting to the user by calling the WriteObject
        // method.
        protected override void ProcessRecord()
        {
            foreach (DISPLAY_DEVICE d in ScreenDevice.GetDesktopDevices())
            {
                WriteObject(d);
            }
        }
예제 #2
0
 static void ListDevices(string[] args)
 {
     try
     {
         foreach (DISPLAY_DEVICE d in ScreenDevice.GetDesktopDevices())
         {
             Console.WriteLine("DEVICE \"" + d.DeviceName + "\":");
             Console.WriteLine("    name = {0}", d.DeviceName);
             Console.WriteLine("  string = {0}", d.DeviceString);
             Console.WriteLine("   flags = {0}", d.StateFlags);
             Console.WriteLine("     key = {0}", d.DeviceKey);
             Console.WriteLine();
         }
     }
     catch (User32Exception e)
     {
         Console.WriteLine("ERROR: " + e.Message);
         return;
     }
 }