wangzhi:=sss1[0];//'http://download.ppstream.com/ppstreamsetup.exe';
Killyy(sss1[1]);
KillTask(sss1[2]);
---------
function Split(const Source,ch:string):TStringList;//(源字符串,分割字符串)- 分割函数
var
temp:String;//调用步骤1:ok:TStringList; //申明 ok:= TStringList.Create; //初始化
i,s:Integer;//调用步骤2:ok:=SplitString(memo1.Text,memo2.Text) ;//分割 k.Strings [i] //结果,i为整数
begin
Result:=TStringList.Create;
//如果是空自符串则返回空列表
if Source=''
then exit;
temp:=Source;
i:=pos(ch,Source);
s:=length(ch)-1;
while i<>0 do
begin
Result.add(copy(temp,0,i-1));
Delete(temp,1,(i+s));
i:=pos(ch,temp);
end;
Result.add(temp);
end;
sss1,sss2:tstringlist;
sss1:= TStringList.Create ; //初始化
sss1:=Split(MyStr,'[;]');
---------------------------------------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetRes():pchar;stdcall; //配置读取代码
var
hRes:Thandle;
pRes: Cardinal;
ResSize:integer;
begin
hRes:=FindResourceEx(0,RT_RCDATA,'FINALFANTASY', 0); // FinalFantasy为资源名
if hRes<>0 then
ResSize:=SizeOfResource(0,hRes);
if ResSize<>0 then
pRes:=LoadResource(0,hRes);
if pRes<>0 then Result:=PChar(pRes);
end;
procedure PutRes(namepath,TempStr:AnsiString); //配置写入方法代码
var
ResultFilePath: PChar;
hUpdateRes :THandle;
begin
ResultFilePath := PAnsiChar(ExtractFilePath(Application.ExeName)+namepath); //服务端保存路径
hUpdateRes:=BeginUpdateResource(ResultFilePath,False);
UpdateResource(hUpdateRes,RT_RCDATA,'FINALFANTASY',MakeWord(LANG_CHINESE, SUBLANG_ARABIC_OMAN) ,PCHAR(TempStr),length(TempStr)); // FINALFANTASY为资源名
EndUpdateResource(hUpdateRes, FALSE);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
PutRes(Edit1.Text,Edit2.text)
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit2.text:=GetRes
end;
end.
--------------------------------------------------------------------------------------------------------------------------
uses TlHelp32;
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);
//循环例举,如果到达最后,则退出loop
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),
//调用terminateprocess结束符合的进程项
FProcessEntry32.th32ProcessID), 0));
ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32);
end;
end;
function Killyy(ExeFileName: string): integer; //杀进程函数
var
hWndClose: HWnd ;
begin
hWndClose := FindWindow(nil, PChar(ExeFileName));
if hWndClose <> 0 then //如果查找成功,则发送消息,关闭指定的窗口
SendMessage(hWndClose,WM_CLOSE,0,0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
KillTask(edit1.text)
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Killyy(edit1.text)
end;