type
TForm1 = class(TForm)
private
{ Private declarations }
// 加入這一行
procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
// 加入這一段
procedure TForm1.WMDeviceChange (var Msg: TMessage);
const
CD_IN = $8000;
CD_OUT = $8004;
var
Msgstr : string;
begin
inherited;
case Msg.wParam of
CD_IN : Msgstr := '置入光碟片';
CD_OUT : Msgstr := '退出光碟片';
end;
ShowMessage(Msgstr) ;
end;
沒有留言:
張貼留言