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.
相关文档:
procedure frmMain.CLS; //主窗体自定义事件CLS
var i:integer;
begin
for i:=0 to panel5.ControlCount -1 do
begin
if panel5.Controls[i] is TEdit then //Edit组件
begin
((panel5.Contro ......
Delphi从6.0就开始支持Web Services的开发和应用了,本文通过使用Delphi 7.0调用新浪发送短信的Web Service进行短信应用程序开发这一实例详细的介绍在Delphi中如何开发基于Web Services的应用系统。
第一步,准备工作,了解新浪短信Web Service。新浪发送短信的Web Service地址是http://smsinter.sina.com.cn/ws/smswebs ......
今天用delphi 2010,做一个简单的内存映射的程序,在delphi以前版本上跑的好好的程序,在2010上,居然出现了不同的效果,发送端发送的字符串,接收端只收到一半,大概程序如下:
发送端:
var
str : String;
begin
CopyMemory(@(PShare^.Data),str,Length(str)); //把数据拷贝到 ......
Delphi中 Round函数有个Bug
一旦参数是形如 XXX.5这样的数时
如果 XXX 是奇数 那么就会 Round up
如果 XXX 是偶数 那么就会 Round down
例如 Round(17.5)=18
但是 Round(12.5)=12
下面的函数即可纠正这个 Bug 但是是临时性的
执行 DoRound(12.5) 结果为 13 正确
function DoRound(Value: Extended): Int64;
......
附件资料
*指针的使用(代码)
示例:简单的指针应用
代码:
procedure TForm1.Button2Click(Sender: TObject);
var
a: Integer;
p: ^Integer;
begin
with self.Memo1.Lines do
begin
......