[Interest] A QThread question...
Bo Thorsen
bo at vikingsoft.eu
Wed Oct 21 12:17:04 CEST 2015
Den 21-10-2015 kl. 11:48 skrev NoMercy:
> Hello everyone and thanks for you replies,
>
> I've a rather advaced question about QThreads (well advanced to my
> knowledge anyways)
>
> I have a Windows service that runs under System user (naturally) but I
> want to create and run a thread from within that service and change the
> token of that thread so it runs in user evironment.
>
> and to do so, I thought of something like this;
> get QThread::currentThreadId -- Documentation says do not use it but?
> get handle of that thread by OpenThread(threadID)
> and use SetThreadToken to move thread to user space.
>
> I'm using 4.8.6 btw
>
> do you think it is possible?
> is this approach safe?
> would it be stable?
> any possible implications?
> if it works, would my main thread can still comunicate through
> signals/slots?
If you are going to do native stuff to the threads, then I think you
would be wise to create the thread with the native windows calls for it
instead of trying to bend a QThread to the rules.
The whole notion of threads running as a separate user feels like such a
dirty solution anyway, and QThread might muddy the waters even more. For
example, signal from one user thread to a slot in a thread running as
another user... It just gets weird.
Keep it simple, create the thread yourself and separate this completely.
Bo Thorsen,
Director, Viking Software.
--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
More information about the Interest
mailing list