摘要:[C#][VB.NET]變更預設印表機
利用 WMI 便可以變更預設印表機
C#
private void ChangeDefaultPrinter(string printerName)
{
ManagementObject mo = new ManagementObject("Win32_Printer.DeviceID='" + printerName + "'");
mo.InvokeMethod("SetDefaultPrinter", null, null);
}
VB.Net
Private Sub ChangeDefaultPrinter(ByVal printerName As String)
Dim mo As New ManagementObject("Win32_Printer.DeviceID='" & printerName & "'")
mo.InvokeMethod("SetDefaultPrinter", Nothing, Nothing)
End Sub
更多的WMI 應用