|
Re: WTSSendMessage fail with error Access Denied "kalpesh" <kalpeshgedia@gmail.com> wrote in message
news:1182513015.859303.288070@a26g2000pre.googlegroups.com...
>i describe my Issue that i am developing virtual printer driver DLL
> which is run by
> spooler service of operation system, means my driver is run under
> spooler service.
Services all run in session 0. That's a starting point.
> Now i need to show one MessageBox from my this DLL in Window vista
> but
> vista not support any user interface from service thats why i use
> this
> WTSSendMessage function but this function give me error "ACCESS
> DENIED"...
>
>
> //Code i used
>
>
> #define WTS_CURRENT_SERVER ((HANDLE)NULL)
> #define WTS_CURRENT_SERVER_HANDLE ((HANDLE)NULL)
> #define WTS_CURRENT_SERVER_NAME (NULL)
>
>
> #define WTS_CURRENT_SESSION ((DWORD)-1)
"Current Session" is one of those items that sticks out like a sore thumb on
Vista. Keep reading...
> function return with "Error : Access Denied";;
> WTSSendmesage function fail
> and return with error "ACCESS DENIED".
>
> This function failed is happening on Window vista only,
> One more thing is this same code is running successfully On Window XP
> means i think that
> there is some problem arise due to Vista securtiy...
Between Windows XP and Windows Vista, a few things changed.
First, Windows XP already had the feature that several users could be logged
in to multiple sessions, so your driver would wind up sending its message to
the "console" session, which might not be the currently active session. Your
driver needs to take account of the possibility that multiple users may be
logged in at multiple sessions, or it will fail to notify active users on
Windows XP or Server 2003.
Worse, on Windows Vista, the user _never_ gets to log on in session 0,
because it's a security risk to have users and services running in the same
logon session.
You will need to investigate WTSEnumerateSessions to get a list of all the
sessions, and send your message to all of them that are in the WTSActive
state.
I notice you're also passing "FALSE" for the parameter documented as "DWORD
Timeout", and "0" for the parameter documented as "BOOL bWait". I think you
have these reversed - while the effect is to pass a value of 0 to each, it's
confusing.
Finally, since you can't really tell if anyone's paying attention to your
dialog here, I would suggest setting bWait to FALSE, and Timeout to some
value after which the dialog will disappear from the sessions that aren't
actually being watched by a user right now. Setting a timeout of 0 is just
asking for trouble, as your dialogs back up on an inactive desktop, taking
up space that will never be returned because the user isn't there - and then
when the user returns, they have to do what, click OK like a million times?
Stop abusing your users just because you don't want to spend a few seconds
to think about good timeout values.
Alun.
~~~~ |