易截截图软件、单文件、免安装、纯绿色、仅160KB

Delphi结束进程模块

uses Tlhelp32;
function KillTask(ExeFileName: string): integer;
const
  PROCESS_TERMINATE = $0001;
var
  ContinueLoop: BOOLean;
  FSnapshotHandle: THandle;
  FProcessEntry32: TProcessEntry32;
begin
  Result := 0;
  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
  while integer(ContinueLoop) <> 0 do
  begin
    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase
          (ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) = UpperCase
          (ExeFileName))) then
      Result := integer(TerminateProcess(OpenProcess(PROCESS_TERMINATE, BOOL(0)
              , FProcessEntry32.th32ProcessID), 0));
    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
  end;
  CloseHandle(FSnapshotHandle);
end;
调用的时候只需要
if KillTask('qq.exe') <> 0 then
    showmessage('结束QQ成功')
else
    showmessage('无法结束QQ');
你在程序里面用一个计时器,每隔一秒钟检查一下,如果有就结束,也就实现了禁止运行的目的。
procedure TForm1.Timer1Timer(Sender: TObject);
begin
    KillTask('qq.exe');
end;


相关文档:

Delphi解决刷新闪烁、图片文字透明、报告内存泄露……

1.防止刷新时闪烁的终极解决办法
{ 防止刷新时闪烁的终极解决办法(对付双缓冲无效时) }
  Perform($000B, 0, 0); //锁屏幕  防止闪烁
  // 做一些会发生严重闪烁的事情..
  //解锁屏幕并重画
  Perform($000B, 1, 0);
& ......

delphi 将汉字翻译成拼音缩写的函数介绍

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
 &n ......

delphi 取CPU序列号的方法


interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls, StdCtrls, Buttons;
type
TDemoForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
GetButton: TBitBtn;
CloseButton: TBitBtn;
Bevel1: TBevel;
Label5: TLabel; ......

delphi显示 jpg、png、gif 图片及 gif 动画的方法

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Bu ......

delphi 金山词霸屏幕取词技术的介绍

朋友,先要导入 XDICTGRB_TLB ,然后用下面的source,注意TForm1 = class(TForm,IXDictGrabSink) //!!!
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleServer, XDICTGRB_TLB;
type
TForm1 = class(TForm,IXDictGrabSink) //!!!
GrabPro ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号