procedure TProcessWindow.OKButtonClick(Sender: TObject);
var ProcessIDString: String;
i: Integer;
begin
if formsettings.cbUndoMemoryChanges.checked then CheckForChanges;
if Processlist.ItemIndex>-1 then
begin
DetachIfPossible;
ProcessIDString:='';
i:=1;
while ProcessList.Items[Processlist.ItemIndex][i]<>'-' do
begin
ProcessIDString:=ProcessIDString+ProcessList.Items[Processlist.ItemIndex][i];
inc(i);
end;
procedure TFrmProcessWatcher.PWOP(ProcessIDString:string);
var i:integer;
begin
val('$'+ProcessIDString,ProcessHandler.processid,i); //初学delphi 这里具体什么意思啊? val 后面'$'
if i<>0 then raise exception.Create(processidstring+' isn''t a valid processID');
if Processhandle<>0 then //这里通过 ProcessIDString 得到了 processid 难道这两个不一样,还是什么标志啊?
begin
CloseHandle(ProcessHandle);
ProcessHandler.ProcessHandle:=0;
end;
Open_Process; //这里打开
end;
procedure Open_Process;
begin
{$ifndef netclient}
ProcessHandler.ProcessHandle:=NewKernelHandler.OpenProcess(PROCESS_ALL_ACCESS,false,ProcessID);
{$endif}
end;
procedure TProcessWindow.OKButtonClick(Sender: TObject);
var ProcessIDString: String;
i: Integer;
begin
if formsettings.cbUndoMemoryChanges.checked then CheckForChanges;
if Processlist.ItemIndex>-1 then
begin
DetachIfPossible;
ProcessIDString:='';
i:=1;
while ProcessList.Items[Processlist.ItemIndex][i]<>'-' do
begin
ProcessIDString:=ProcessIDString+ProcessList.Items[Processlist.ItemIndex][i];
inc(i);
end;
procedure TFrmProcessWatcher.PWOP(ProcessIDString:string);
var i:integer;
begin
val('$'+ProcessIDString,ProcessHandler.processid,i); //初学delphi 这里具体什么意思啊? val 后面'$'Val函数是将字符串类型数值转换成整数类型值,'$'是告诉val函数,这个要转换的字符串类型数值要按十六进制的数值类型转换。
if i<>0 then raise exception.Create(processidstring+' isn''t a valid processID');
if Processhandle<>0 then //这里通过 ProcessIDString 得到了 processid 难道这两个不一样,还是什么标志啊?Processhandle是在外部取得的,不是ProcessIDString得到的。这一句主要是判断Processhandle(进程句柄)是否为零,如果不为零则调用下面的CloseHandle函数关闭进程
begin
CloseHandle(ProcessHandle);
ProcessHandler.ProcessHandle:=0;
end;
Open_Process; //这里打开
end;
procedure Open_Process;
begin
{$ifndef netclient}
ProcessHandler.ProcessHandle:=NewKernelHandler.OpenProcess(PROCESS_ALL_ACCESS,false,ProcessID);
{$endif}
end;
小菜菜一个! 希望大家帮助下哈~ PROCESS_ALL_ACCESS具体数值应该时什么饿?
SYNCHRONIZE = $00100000;
STANDARD_RIGHTS_REQUIRED = $000F0000;
PROCESS_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED or SYNCHRONIZE or $FFF);
Val 不是API
简单来请就是将字符串 S 转成数值存放于 V
若非正确数值格式的话, 则将错误位置放于 Code. 而不会像StrToInt会产生例外.
例如:
Val("123r567", V , Code)
V=123
Code= 3
'$' 是让Delphi视字符串为十六进制
100 = 64h = Delphi的 $64
Declaration
procedure Val(S; var V; var Code: Integer);
Description
The Val function converts the string value S to its numeric representation, as if it were
read from a text file with Read.
S is a string-type expression; it must be a sequence of characters that form a signed
whole number. V is an integer-type or real-type variable. Code is a variable of type Integer.
If the string is invalid, the index of the offending character is stored in Code; otherwise,
Code is set to zero. For a null-terminated string, the error position returned in Code is
one larger than the actual zero-based index of the character in error.
Val performs range checking differently depending upon the state of $R and the type of
the parameter V.