阅读:988回复:1
xp 或2003下打印界面的问题
我同事作了一个打印驱动,在2k下完全正常,但在 XP和2k server 和2003上,出来的界面只在超级管理员的那个桌面才能看到,而在其他用户桌面看不到,列如在guest的用户打印东西后看不到对话框切换到administrator后对话框显示在这里了
|
|
沙发#
发布于:2005-04-06 17:30
在2003sdk上有例子,但不知道能不能用
DWORD dwGuiThreadId = 0; int UserMessageBox( RPC_BINDING_HANDLE h, LPSTR lpszWindowStation, LPSTR lpszDesktop, LPSTR lpszText, LPSTR lpszTitle, UINT fuStyle) { DWORD dwThreadId; HWINSTA hwinstaSave; HDESK hdeskSave; HWINSTA hwinstaUser; HDESK hdeskUser; int result; // Ensure connection to service window station and desktop, and // save their handles. GetDesktopWindow(); hwinstaSave = GetProcessWindowStation(); dwThreadId = GetCurrentThreadId(); hdeskSave = GetThreadDesktop(dwThreadId); // Impersonate the client and connect to the User\'s // window station and desktop. RpcImpersonateClient(h); hwinstaUser = OpenWindowStation(lpszWindowStation, FALSE, MAXIMUM_ALLOWED); if (hwinstaUser == NULL) { RpcRevertToSelf(); return 0; } SetProcessWindowStation(hwinstaUser); hdeskUser = OpenDesktop(lpszDesktop, 0, FALSE, MAXIMUM_ALLOWED); RpcRevertToSelf(); if (hdeskUser == NULL) { SetProcessWindowStation(hwinstaSave); CloseWindowStation(hwinstaUser); return 0; } SetThreadDesktop(hdeskUser); // Display message box. dwGuiThreadId = dwThreadId; result = MessageBox(NULL, lpszText, lpszTitle, fuStyle); dwGuiThreadId = 0; // Restore window station and desktop. SetThreadDesktop(hdeskSave); SetProcessWindowStation(hwinstaSave); CloseDesktop(hdeskUser); CloseWindowStation(hwinstaUser); return result; } |
|