Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
C#
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..
Posted
Updated 5-Nov-14 22:08pm
v3

1 solution

Use the SetPrinter[^] API call, with the structure PRINTER_INFO_2[^] and change pDatatype to "EMF 1.008"
 
Share this answer
 
Comments
Member 11093824 6-Nov-14 5:31am    
how to use setprinter in C#.net for changing the datatype in printer_info_2 through programming?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900