locked
cannot change default printer with vb net

    質問

  • customer can not change default printer in XP operating system with code for API in vb net, it happens only one machine, why?
    2011年12月10日 13:49

回答

  • Hi SaltBir,

    Welcome to the MSDN Forum.

    How many printers are installed in that machine? And what is the code for change the default printer? Please provide more details such as this.

    On the other hand, if there are serveral printers in the machine, you can try to reinstall them all again. Or reinstall the OS and add the printers.

    I hope this well be helpful.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    2011年12月12日 7:37

すべての返信

  • Hi SaltBir,

    Welcome to the MSDN Forum.

    How many printers are installed in that machine? And what is the code for change the default printer? Please provide more details such as this.

    On the other hand, if there are serveral printers in the machine, you can try to reinstall them all again. Or reinstall the OS and add the printers.

    I hope this well be helpful.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    2011年12月12日 7:37
  • Dear Mike,

    Miilions of apologizes for late reach due to some problems, and thanks for your welcome...

    Code is below to change default printer (we are using-Microsoft.VisualBasic.PowerPacks.dll NET v9)

            DeviceLine = PrinterName & "," & DriverName & "," & PrinterPort
            Call WriteProfileString("windows", "Device", DeviceLine)
            Call SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, "windows")

    this results with a message PRINTER ERROR 0.

    What is strange other users are not facing this problem in the same network-same printer (may be due different OS or versions of OS).

    Thanks a lot.

    Best Regards

    S.Tarik SALT

    2012年3月19日 6:16
  • reason was DEVICENAME, it could not be get from PRINTERS COLLECTION by code, may be  one of them raised error and sent code out, solved by RESUME ERROR ON NEXT, skipping the one that could not be read...
    2012年3月30日 13:06