From: Cojocaru Sergiu on
Hello,
trying to send a broadcast message in vista ( under administrator, in
elevated process) using BroadcastSystemMessage and it fails with last error
5 ( access denied) why??? I call this function after mounting an iso as
drive using my driver. Disk is mounted well and I can access it and read
information, but explorer do not show it ( because it didn't received
message about device arrival :) ). Tryed to run it with UAC off and it sends
message very well.

My function:

HRESULT BroadcastVolumeDeviceChange(WPARAM notification, WCHAR DriveLetter)

{

static PDEV_BROADCAST_VOLUME pMyDevHdr = NULL;

DWORD dwFlag = BSM_ALLCOMPONENTS;

DWORD volumeMask = 1 << (DriveLetter - L'A');

// Allocate our broadcast header and keep it around (static)

// We have to keep it around because if we post the broadcast the buffers
that we

// pass into the broadcast have to stick around after this call returns.

if (NULL == pMyDevHdr)

{

pMyDevHdr = new DEV_BROADCAST_VOLUME;

}

// Initialize our broadcast header

pMyDevHdr->dbcv_devicetype = DBT_DEVTYP_VOLUME;

pMyDevHdr->dbcv_size = sizeof(DEV_BROADCAST_VOLUME);

pMyDevHdr->dbcv_flags = DBTF_NET;

pMyDevHdr->dbcv_unitmask = volumeMask;

// Broadcast the device change notification

BroadcastSystemMessage(BSF_IGNORECURRENTTASK,

&dwFlag,

WM_DEVICECHANGE,

notification,

(LPARAM)pMyDevHdr);

return S_OK;

}