我编写了一个CDPLAYER,我想在光盘关闭时不让WINDOWS自动播放,而是用我的程序播放。怎么做??(50分)

  • 主题发起人 主题发起人 jackyxinli
  • 开始时间 开始时间
J

jackyxinli

Unregistered / Unconfirmed
GUEST, unregistred user!
我想应该有两种方法来解决:<br>&nbsp; 一、改注册表;<br>&nbsp; 二、拦截WINDOWS消息。<br>我现在想知道如何拦截这个WINDOWS消息,也就是向WINDOWS发出一个虚拟的按下SHIFT键的消息,怎么做呢?请指教。<br>谢谢!
 
提供改注册表的方法:<br>以下程序在窗口创建时读入播放器路径参数到Edit1,修改Edit1后点击Button1写入注册表<br><br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, StdCtrls,Registry;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Edit1: TEdit;<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>var<br>reg :TRegistry;<br>begin<br>Reg:=TRegistry.Create;<br>&nbsp; &nbsp;with reg do<br>&nbsp; try<br>&nbsp; begin<br>&nbsp; &nbsp;RootKey := HKEY_CLASSES_ROOT;<br>&nbsp; &nbsp;OpenKey('/AudioCD/shell/play/command',false);<br>&nbsp; &nbsp;Edit1.Text:=ReadString('');<br>&nbsp; end<br>&nbsp; finally<br>&nbsp; &nbsp;Closekey;<br>&nbsp; &nbsp;Free;<br>&nbsp; end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>reg :TRegistry;<br>begin<br>Reg:=TRegistry.Create;<br>&nbsp; with Reg do<br>&nbsp; try<br>&nbsp; begin<br>&nbsp; &nbsp; RootKey := HKEY_CLASSES_ROOT;<br>&nbsp; &nbsp; OpenKey('/AudioCD/shell/play/command',false);<br>&nbsp; &nbsp; WriteString('',Edit1.Text);<br>&nbsp; end<br>&nbsp; finally<br>&nbsp; &nbsp; CloseKey;<br>&nbsp; &nbsp; Free;<br>&nbsp; end;<br>end;<br>end.<br>
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部