随笔分类 - Delphi
摘要:无论是用VC还是用Delphi,启动外部程序,调用的都是相同的系统中的API函数,如下Delphi代码所示://登录按钮
procedure TForm1.Label_LoginClick(Sender: TObject);
begin RunOtherApp('C:\1.exe'); //启动1.exe end; //Delphi启动其它程序函数
//参数appPath为要打开的程序的路径
procedure TForm1.RunOtherApp(appPath:String);
begin //使用WinExec也可以打开程序,这里不用
//WinExec(Pchar(ap
阅读全文
摘要:最近我用Delphi写了个程序,需要将用户信息写入文件,因此在网上查了下Delphi有关文本文件的操作,经整理后,我将其封装成了一个函数,以方便以后的使用,访函数代码如下://将帐号信息写入文本文件函数
procedure TForm1.WriteUserToText(user:String; pass:String);
var txt:TextFile;
begin //先判断一下文件是否存在, 不存在时就创建它
if not FileExists('C:\p.txt') then
begin Assignfile(txt,'c:\p.txt'); //指定文
阅读全文
摘要:本工具网络下载地址:http://download.csdn.net/download/friendan/4637954本工具完整Delphi7源码:http://download.csdn.net/download/friendan/4637961//程序截图如下:写此程序的目的: 很多时候,我需要暂时离开电脑,不想关机,又想延长电脑屏幕的寿命,所以我想到了屏幕保护。众所周知,在系统中设置了屏幕保护后,需要在指定的一段时间内屏幕保护程序才能运行,而我的需求却是随时都可以启动屏幕保护程序,因此有了写这款小程序的想法!...程序的实现原理: 原理很简单啦,其实就是给系统发送一个广播消息,让系统启
阅读全文
摘要:///首先在控件栏定位到:Indy Clients添加控件IdSMTP///再定位到:Indy Misc添加控件IdMessage///发送邮件函数procedure TForm1.SendMail(YYuser: string;YYpass:string); begin try IdSMTP1.AuthenticationType:=atLogin; //设置登陆类型 IdSMTP1.Username:='1099897995@qq.com'; //设置登陆帐号 IdSMTP1.Password:='123456'; //设置登陆密码 IdSMTP1.Ho..
阅读全文
摘要:uses Tlhelp32; //在工程中引入单元Tlhelp32//使用函数前,请在工程的前面对函数进行声明,截图如下///Delphi结束指定进程函数function TForm1.EndProcess(ExeFileName:string):integer;const PROCESS_TERMINATE = $0001;var ContinueLoop: BOOLean; FSnapshotHandle: THandle; FProcessEntry32:TProcessEntry32;begin Result := 0; FSnapshotHandle := Creat...
阅读全文
摘要:在窗体(或控件)的OnMouseDown事件中加入下面几行代码即可//--------Delphi移动无标题窗体------------------------------------procedure TForm1.OnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);begin ReleaseCapture; SendMessage(Self.Handle,WM_NCLBUTTONDOWN,HTCAPTION,0);end;//////////////////...
阅读全文