How to determine the type of selected printer which is dot matrix or not?

Usually on older Windows version (98 or older) I can use MarkingTechnology in the Printer api to get the current printer type. But it is not available on Windows 2000 or newer. Do you have another way to detect it on Windows 2000 or newer?

Sample code for printer information request via WMI query in C #

var queryResult = string.Empty;
var query = new WqlObjectQuery("Select * from Win32_Printer");
var searcher = new ManagementObjectSearcher(query);

foreach (ManagementObject printer in searcher.Get())
{
    foreach (var p in printer.Properties)
    {
        queryResult += p.Name + ": " + printer[p.Name] + Environment.NewLine;
    }

    queryResult += "--------------------------------" + Environment.NewLine;
}

      

Win32_Printer Class Documentation

Thank,

+3


source to share


2 answers


Short answer: No, there doesn't seem to be a consistent way to do this.



+2


source


I am doing my best to find out how the Dot Matrix printer can be detected. I am trying to call the GetDeviceCaps function (gets the device specific information for a specified device.) To get a TECHNOLOGY item that should be returned as a character stream if the selected printer is a dot matrix.

var hdc = CreateDC("WINSPOOL", printerName, null, IntPtr.Zero);
var technology = (DeviceCapTechnology)GetDeviceCaps(hdc, (int)DeviceCap.TECHNOLOGY);

      

However, it always returns TECHNOLOGY as a Bitmap display . I don't know why it always returns a value like this.



[DllImport("gdi32.dll")]
static extern int GetDeviceCaps(IntPtr hdc, int nIndex);

[DllImport("gdi32.dll")]
static extern IntPtr CreateDC(string lpszDriver, string lpszDevice, string lpszOutput, IntPtr lpInitData);

      

GetDeviceCaps function

Sample project

0


source







All Articles