Delphi U盘插入拨出检测
Delphi U盘插入拨出检测:
1、新建工程;
2、在form1上放一个Label;
3、定义一个私有过程
procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE;
完整代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AppEvnts, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
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);
var
myMsg : String;
begin
Case Msg.WParam of
32768:
begin
myMsg :='U盘插入';
Label1.Caption:=myMsg
end;
32772:
begin
myMsg :='U盘拔出';
Label1.Caption:=myMsg;
end;
end;
end;
end.
相关文档:
Delphi 关键字详解[整理于 "橙子" 的帖子]
absolute
//它使得你能够创建一个新变量, 并且该变量的起始地址与另一个变量相同.
var
Str: string[32];
StrLen: Byte absolute Str;
//这个声明指定了变量StrLen起始地址与Str相同.
//由于字符串的第0个位置保存了字符串的长度, 所以StrLen的值即字符串长度.
begin ......
1.根据 Delphi 指令参考手册中
说明:
Assigned 函式在参数不为nil时传回True,表示指针已经指到某个内存地址,这个内存地址可能是一个对象地首地址,也可能在函数或过程中,声明一个指针变量,没有赋值为nil ,无乱的指向某处,这两个种情况,Assigned(指针变量)都不为nil , 函数放回True;
而参数为nil时则传回Fals ......
帮助页在http://delphi.about.com/cs/adptips2003/a/bltip0203_2.htm
自己在实现的过程中的具体过程如下:
function InstallInf(const PathName: string; hParent: HWND): Boolean;
var
instance: HINST;
begin
instance := ShellExecute(hParent,
PChar('open ......
关于书签(BookMark)操作;
书签操作主要用于在表中快速地定位记录指针,在应用程序中常常要保存记录指针所在的位置,在进行其他处理之后,希望能快速地返回到先前指针所在的位置,此时,使用书签将显得特别有用。有关书签操作,Delphi提供了三个方法,它们是:
●&n ......
procedure TForm1.Button2Click(Sender: TObject);
var
name:String ;
begin
name := edit2.Text ;
name := '%' + name ;
query1.Close ;
query1.SQL.Clear ;
query1.SQL.Add('select * from gjh_t where name like '''+name+'''') ;
&nb ......