BroadcastSystemMessage function issue while using in a Service module

Ramashankar Agrahari 31 Reputation points
2022-01-06T14:55:45.58+00:00

Hi,
First of all sorry if this is not the right forum for this question. If so, please guide me to the forum where I can post this query.

I am doing a prototype where I need to Broadcast "WM_DEVICECHANGE" message to all applications (specifically to those who are working with camera, like skype/teams etc) running on my pc.
I am registering a direcshow camera device (my custom dll) using regsvr32 command on my pc. Once it is registered successfully I broadcast this message to all app from my desktop application (say as Notifier.exe) and they update their camera list immediately.
This solution works fine till I do it from desktop application. But if I am doing it from a service module then, even though BroadcastSystemMessage() returns success, it is not working correctly (I mean skype/teams dont get notified with this message as their list is not updated).
If I launch my notifier.exe from this service app (using createprocess() or shellexecute()) then also it doesn't work correctly.

I understand service have some other privileges/restriction for some operation, and probably launching any app from a service module might require some more settings/configuration to do, but I am unbale to find that.
So can anyone suggest how can I overcome this issue.

Thanks.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,386 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,481 questions
{count} votes

Accepted answer
  1. RLWA32 39,446 Reputation points
    2022-01-06T15:03:01.717+00:00

    Windows services typically run in non-interactive session 0. Interactive applications run in other sessions and generally will not receive window message broadcasts from sessions other than their own. One workaround would be to start a process in the user's interactive session that broadcasts the WM_DEVICECHANGE message. If your service is running as SYSTEM you can get the user's token with WTSQueryUserToken and then start the process with CreateProcessAsUser


0 additional answers

Sort by: Most helpful