Win10 set up local area network to share the printer, dynamically switch the default printer summary

Two computers are as follows:

The host computer (1) to ensure that the host computer to be installed on the printer driver

Vice Computer (2)

First set manually (attach Baidu tutorial ) that, if successful best, then setting process may encounter problems look down

 

 

The first pit: in 2 years has been shared computer network can not find the presence of a computer, it is gas, the solution is

Settings - Network and Interet- Ethernet - Network - Network Configuration File - private (public and private switching back and forth a bit, restart the computer, refresh my computer)

The second pit: find the existence of a computer, but when the network connection is required to fill credentials, Baidu a lot (to no avail), the simplest solution is to

Control Panel - All Control Panel Items - Network and Sharing Center - Advanced sharing settings - Password protected sharing - Turn off password protected sharing

 

Requirements: Users can optionally specify the printer for printing
. This is certainly going to dynamically modify the system default printer

    [System.Runtime.InteropServices.DllImport("winspool.drv", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
    private static extern Boolean SetDefaultPrinter(string name);
    /// <summary>
    /// 设置默认的打印机,如果失败抛出异常.
    /// </summary>
    /// <param name="name">打印机名字</param>
    public void ChangeDefaultPrinter(string name)
    {
        var result = SetDefaultPrinter(name);
        if (!result)
            throw new System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error());
    }
    private void Start()
    {
        ChangeDefaultPrinter("");
    }
 

Now here you can only change the local printer, network shares, being not found.

 

 

After experiencing problems, then we will continue to update

Published 23 original articles · won praise 13 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_42047805/article/details/94741969