Reputation: 7249
I am working with windows credential provider using a device that authenticates a user. Communication with the device is done on a separate thread.
I created and registered a credential provider dll
that windows interfaces with. The dll
creates a thread that authenticates the user and calls the credential provider. However, the call to the credential provider is currently on the thread that was created and not the main thread that windows Logon/UI
is on. This is clearly going to cause threading problems.
The solution is to use PostMessage
to post a message from the created thread to the Logon/UI
thread. I've only used PostMessage
with a windows gui application. How can I post a message from a thread to the windows Logon/UI
process in my application?
Upvotes: 0
Views: 2129
Reputation: 7839
My initial reaction was the same: you cannot.
But it is not a complete answer: you do not have to have a full blown window, you just need a message pump. COM uses the same technique when running in a STA (single thread apartment). A STA will create a hidden window. This is the reason the local server main thread needs to implement a Windows message pump.
The message pump can be as simple as:
MSG msg;
while (GetMessage (&msg, 0, 0, 0))
DispatchMessage (&msg);
COM does this to allow RPC between client and servers in different processes. You can do the same (google for COM STA, or read it on MSDN)
But you probably won't need to go down that way... As far as I understood, you own both threads (they are both in your codebase), and they run in the same process. You can use some shared memory + signaling approach (like global variables and Mutexes).
Upvotes: 2