Printing from a Windows Service

前端 未结 1 1240
无人共我
无人共我 2021-01-21 00:20

Ok, I am trying to print a page from a windows service that I installed using a Visual Studio setup project.

At first I set the Account property yo Local System, but it

1条回答
  •  [愿得一人]
    2021-01-21 00:41

    I wouldn't recommend using interact with desktop. You will run into compatibility problems on Vista, Windows 7, and later versions of Windows.

    You could use WTSQueryUserToken to get a user token for a logged on user and then print from that user's token. You could do this using CreateProcessAsUser to do the actual printing.

    To get the logged on sessions you could use WTSGetActiveConsoleSessionId or WTSEnumerateSessions.

    0 讨论(0)
提交回复
热议问题