本文介绍了如何使用带有C#.net的WMI将打印机数据类型更改为emf格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经搜索并获得下面复制的一些代码。

但这段代码工作正常,但只获得默认打印机(已连接)设置和属性。在这我正在读取打印机数据类型。现在我想将数据类型更改为NT EMF 1.008。

Hi,
I already search and get the some code copied below.
But this code working fine, but getting only default printer(which is connected) settings and properties. in this i am reading the printer datatype. now i want to change the datatype to NT EMF 1.008.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Management;
using System.ComponentModel;
using System.Runtime.InteropServices;


namespace SetValueOfWMI
{
    class Program
    {
        static void Main(string[] args)
        {
            ManagementEventWatcher watcher = WatchForProcessStart();
             while(true) watcher.WaitForNextEvent();
         }

        private static ManagementEventWatcher WatchForProcessStart()
        {
             string scope = @"\\.\root\CIMV2";
             string queryString = "SELECT TargetInstance FROM __InstanceCreationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_PrintJob'";

             ManagementEventWatcher watcher = new ManagementEventWatcher(scope, queryString);
             watcher.EventArrived += ProcessStarted;
             watcher.Start();
             return watcher;
         }

      private static void ProcessStarted(object sender, EventArrivedEventArgs e)
      {
          ManagementBaseObject targetInstance = (ManagementBaseObject)e.NewEvent.Properties["TargetInstance"].Value;
          targetInstance.Properties.Cast<propertydata>().ToList().ForEach(p => Console.WriteLine("{0}={1}", p.Name, p.Value));
      }
    }
}





请帮帮我..



Please help me..

推荐答案


这篇关于如何使用带有C#.net的WMI将打印机数据类型更改为emf格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 02:41