cannot change default printer with vb net

已鎖定 cannot change default printer with vb net

  • 2011年12月10日 下午 01:49
     
     
    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月12日 上午 07: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.
  • 2012年3月19日 上午 06:16
     
     

    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月30日 下午 01:06
     
     
    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...