procedure TForm1.Button3Click(Sender: TObject);
var
ExeHandle:THandle;
begin
ExeHandle:=findWindow(nil,pchar('暴风影音'));
Button1.Caption:= inttostr(ExeHandle);
if ExeHandle<>0 then
PostMessage(ExeHandle, WM_Close, 0, 0);
end;
在播放视频中,不能关闭暴风影音(Button1.Caption为0),
播放完后,可以关闭暴风影音,Button1.Caption显示为它的句柄。
能不能在播放视频中,关闭暴风影音。
如何不用关闭播放影音,只关闭正播放的视频。
var
ExeHandle:THandle;
begin
ExeHandle:=findWindow(nil,pchar('暴风影音'));
Button1.Caption:= inttostr(ExeHandle);
if ExeHandle<>0 then
PostMessage(ExeHandle, WM_Close, 0, 0);
end;
在播放视频中,不能关闭暴风影音(Button1.Caption为0),
播放完后,可以关闭暴风影音,Button1.Caption显示为它的句柄。
能不能在播放视频中,关闭暴风影音。
如何不用关闭播放影音,只关闭正播放的视频。
解决方案 »
- dephi调用基于soapheader认证的webservice(c#)
- frReport的双面打印
- 用CreateOleObject创建excel后怎么取得单元格中的批注?
- fastreport的pageheader的数据源的问题
- 如何获得系统目录的名字呢?比如我做一个软件放在WIN2000下获得系统目录c:\winnt\,我放在98或者XP下获得系统目录为c:\windows.那么我怎
- 问大家一个有关PARADOX数据库的问题
- 如何进行数据类型转换
- 怎么样扫描一个文本找到它的头字符然后将首字符删除?
- DLL调用出错的问题?结束主程序时非法操作!
- 在MDI窗口中,我出问题了!!!!请高手相救!!!!!
- 大华demo线程调用怎么办
- 关于大型软件,MSSQL软件连接数过多,cpu很高的解决方法
H:THandle;
P:DWORD;
begin
H:=FindWindow(nil,'暴风影音');
if H<>0 then
begin
GetWindowThreadProcessId(H,@P);
if P<>0 then
TerminateProcess(OpenProcess(PROCESS_TERMINATE,False,P),$FFFFFFFF);
end;
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
procedure CloseWnd(const Str: string);
public
{ Public declarations }
end;var
Form2: TForm2;implementationuses TlHelp32;{$R *.dfm}{ TForm2 }function KillTask(ExeFileName: string): integer;
const
PROCESS_TERMINATE = $0001;
var
ContinueLoop: BOOL;
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;procedure TForm2.CloseWnd(const Str: string);
var
Wnd: THandle;
buf: array [0..254] of WideChar;
ArrWnd: array of THandle;
I: Integer;
begin
Wnd := GetWindow(Handle, GW_HWNDFIRST); repeat
GetWindowText(Wnd, buf, 255); if Pos(UpperCase(Str), UpperCase(string(buf))) > 0 then
begin
SetLength(ArrWnd, Length(ArrWnd) + 1);
ArrWnd[High(ArrWnd)] := Wnd;
end; Wnd := GetWindow(Wnd, GW_HWNDNEXT);
until Wnd = 0; for I := Low(ArrWnd) to High(ArrWnd) do
SendMessage(ArrWnd[I], WM_CLOSE, 0, 0);
end;procedure TForm2.Button1Click(Sender: TObject);
begin
CloseWnd('记事本');
end;procedure TForm2.Button2Click(Sender: TObject);
begin
KillTask('notepad.exe');
end;end.