如何使用网络路径获取默认打印机名称

siv*_*mar 10 c# vb.net

我想通过网络路径获取默认的打印机名称.因为我使用网络打印机作为默认打印机.所以我需要在VB.NET或C#.Net中使用它.需要善意的帮助.提前致谢

Sivakumar.P

Jim*_* H. 35

尝试枚举System.Drawing.Printing.PrinterSettings.InstalledPrinters.

using System.Drawing.Printing;
string GetDefaultPrinter()
{
    PrinterSettings settings = new PrinterSettings();
    foreach (string printer in PrinterSettings.InstalledPrinters)
    {
        settings.PrinterName = printer;
        if (settings.IsDefaultPrinter)
            return printer;
    }
    return string.Empty;
}
Run Code Online (Sandbox Code Playgroud)