>> Can anybody tell what message, if any, is sent
when the user put s a new
>>floppy disk or CDROM in their drives?
its called WM_DEVICECHANGE
here is an extract from win32.hlp if
cant find it.
[New -Windows 95]
Event = (UINT) wParam; dwData = (DWORD) lParam;
The WM_DEVICECHANGE device message notifies an application or device
driver
of a change to the hardware configuration of a device or the computer.
Parameters:
Event:
Event type. Can be one of these values:
Value Meaning
DBT_DEVICEARRIVAL A device has
been inserted and is now available.
DBT_DEVICEQUERYREMOVE Permission to remove a device is
requested. Any
application can deny this request and cancel the removal.
DBT_DEVICEQUERYREMOVEFAILED Request to remove
a device has been canceled.
DBT_DEVICEREMOVEPENDING Device is about to be removed. Can not be denied.
DBT_DEVICEREMOVECOMPLETE
Device has been removed.
DBT_DEVICETYPESPECIFIC Device-specific event.
DBT_CONFIGCHANGED Current configuration
has changed.
dwData
Address of a structure that contains event-specific data. Its meaning
depends on the given event.
Return Value:
Returns TRUE to complete a requested action, FALSE otherwise.
Remarks:
For devices that offer software-controllable features, such as ejection
and
locking, the operating system typically sends a DBT_DEVICEREMOVEPENDING
message to let applications and device drivers end their use of the
device
gracefully.
If the operating system forcefully removes of a device, it may not
send a
DBT_DEVICEQUERYREMOVE message before doing so.
--------
Subject: Re: notification of disk change
At 03:06 PM 10/22/98 +0400, you wrote:
>Konrad,
>Will this message be fired because a floppy disk is removed from the
drive
>? I don't think so. It's not the drive that is changed, just the floppy
>disk. I'm not sure, but that's what I think.
>
>Shiv.
>
hi shiv,
i thought the question was about cd???
but its obviuosly that a change of floppydisk can
be trapped as well.
the following code is an extract from
Tom Deprez (tom.deprez@uz.kuleuven.ac.be)
CDEvents component (found at the DSP).
.
private
procedure WndProc(var Msg: TMessage);
protected
procedure WMDeviceChange(var Msg : TWMDeviceChange); dynamic;
public
.
procedure TCDEvents.WndProc(var Msg: TMessage);
begin
if (Msg.Msg = WM_DEVICECHANGE) then
try
WMDeviceChange(TWMDeviceChange(Msg));
except
Application.HandleException(Self);
end
else
Msg.Result := DefWindowProc(FWindowHandle,
Msg.Msg, Msg.wParam,
Msg.lParam);
end;
procedure TCDEvents.WMDeviceChange(var Msg : TWMDeviceChange);
var lpdb : PDEV_BROADCAST_HDR;
lpdbv : PDEV_BROADCAST_VOLUME;
function IsCD : Boolean;
begin
Result := false;
if lpdb^.dbch_devicetype = DBT_DEVTYP_VOLUME then begin
lpdbv := PDEV_BROADCAST_VOLUME(Msg.dwData);
Result := ((lpdbv^.dbcv_flags and DBTF_MEDIA) =
1);
end;
end;
begin
(* received a wm_devicechange message *)
lpdb := PDEV_BROADCAST_HDR(Msg.dwData);
(* look at the event send together with the wm_devicechange
message *)
case Msg.Event of
DBT_DEVICEARRIVAL : begin
if IsCD and Assigned(fAfterArrival)
then
fAfterArrival(Self,
GetFirstDriveLetter(lpdbv^.dbcv_unitmask));
end;
DBT_DEVICEREMOVECOMPLETE : begin
if IsCD and Assigned(fAfterRemove)
then
fAfterRemove(Self,
GetFirstDriveLetter(lpdbv^.dbcv_unitmask));
end;
end;
end;
you can find this component by searching for
(surprisingly) CDEvents.
it has other nice features, as OpenDoor and so on.