应该是更改注册表里面系统设置值
WriteProfileString("windows", "Device", DeviceLine)
然后发出WM_WININICHANGE消息,通知系统设置改变
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0,"windows")

解决方案 »

  1.   

    To set the default printer on Windows 2000/XP, call SetDefaultPrinter. To set the default printer to earlier operating systems, call GetProfileString, WriteProfileString, and SendNotifyMessage, as shown in the following code:        // read PrinterPorts section from win.ini
            // returned string should be of the form "driver,port,timeout,timeout", i.e. "winspool,LPT1:,15,45".
    GetProfileString(TEXT("Windows"),TEXT("Device"),_T(",,,"),m_szName, COUNTOF(m_szName));
    WriteProfileString(TEXT("Windows"),TEXT("Device"),pszPrinterName ));
            // Notify all open applications of the change. Note, only applications that handle the message will recognize the change.
    #if WM_WININICHANGE != WM_SETTINGCHANGE
            // Old message type; for windows 95
    SendNotifyMessage(HWND_BROADCAST,WM_WININICHANGE,0,(LPARAM)szWindows);
    #endif
            // New message type
    SendNotifyMessage(HWND_BROADCAST,WM_SETTINGCHANGE,0,(LPARAM)szWindows);