我想判断c:\1.exe是否运行了,代码该怎么写啊?
解决方案 »
- FindFirst如何只设置查找.txt,和pdf文件?
- Delphi7下如何模拟HTTP post/get请求,并能够获取响应的文本.
- 怎样用程序禁用、启用网络连接(在线等)
- Adoquery是不是不能执行'select * into [数据库绝对地址].[表名] From 表名'的SQL语句
- 我将datacontrol组中的控件都hide掉了,怎么再恢复过来?
- delphi可以写病毒呢!
- 有用过xlswrite的朋友吗?请介绍一下它的用法,或提供帮助文档好吗?谢谢
- 我该怎样选择,请发表你的意见?
- 求救!还是不能解决!绝对给分!谢谢大家!
- 如何控制记录数!
- 谁有delphi2007汉化补丁
- StringGrid右键选择单元格
ReName 1.exe 2.exe
ReName 2.exe 1.exe
ShowMessage('没运行');
except
ShowMessage('运行了');
end;呵呵,有点搞笑
枚举进程,并检查进程的exe路径
Uses
Forms,Windows
Var Hwnd:Thandle;
Begin
Hwnd:=FindWindow(‘TForm1’,‘Form1’);
If Hwnd=0 then
Begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
End
else showmessage('App is running!') ;
End;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,tlhelp32, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
function SQLExist:boolean;implementation{$R *.dfm}
function SQLExist:boolean;
var ProcessList:Thandle;
pe:TPROCESSENTRY32;
begin
ProcessList:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
pe.dwSize:=sizeof(TPROCESSENTRY32);
try
if process32first(ProcessList,pe) then
if strcomp(pe.szExeFile,'sqlservr.exe')=0 then
begin
sqlexist:=true;
exit;
end
else
while process32next(processlist,pe) do
if strcomp(pe.szExeFile,'sqlservr.exe')<>0 then
sqlexist:=false
else
begin
sqlexist:=true;
exit;
end;
finally
closehandle(processlist);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if sqlexist then
label1.Caption:='SQLServer正在运行.'
else
label1.Caption:='SQLServer不在运行!';
end;end.