Home > Back-end >  How to judge whether the specified process running whether or not the file name change
How to judge whether the specified process running whether or not the file name change

Time:10-21

An executable file a.e xe
No matter what it changes into a file name, such as changing b.e xe or CCCCCC. Exe, etc.
How can you determine whether the file to run?
How to do

CodePudding user response:

Signature,,, MD5,,, the file size

CodePudding user response:

Can not detailed point, MD5 is not applicable, because there can be a program in a word, the same program, for example, one is English, one is the localization, they are the same program, but the MD5 certainly is not the same, how to judge whether it run, whether it is English or localization version

CodePudding user response:

The kernel variable, is ok, don't listen to any of the above,

CodePudding user response:

I am not going to write a.e xe, how can I know the other programs the kernel variable?

CodePudding user response:

Enumeration form, determine the title,

CodePudding user response:

Test whether the program run
In some cases, we write the application at the same time, there can be only one instance running in the memory, the server program, for example, some equipment need exclusive, even we just let the program at the same time there is only one instance running (such as application UltraEdit did, let you cannot run multiple application UltraEdit) at the same time, in order to achieve this function, need to add program code, the procedure is as follows:
Press Ctrl + F12, select Project1, add the following statement
The program Project1.
USES the
Windows, {to join the other to call a function}
Forms,
Unit1 in 'Unit1. Pas' {Form1};
{$R *. RES}

Const classname='TFormScreen'; {statement is given priority to form the name of the class}
Var handle: integer; {variable}
The begin
{-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- the main part for the judgment -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --}
Handle:=findwindow (classname, nil); {lookup to see if there is such a form}
If handle<> 0 then {no 0, the program has been running}
The begin
Messagebox (0, 'the program has a in running! 'and' run ', 0); {tip program has been running}
ShowWindow (handle, SW_Show); {display program}
The SetForegroundWindow (handle); {activation procedure}
The halt; Exit {}
end;


{-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -}
Application. The Initialize;
Application CreateForm (TForm1 Form1);
Application. The Run;
End.

CodePudding user response:

Halo, how didn't see the problem?
I'm not write your own programs, to write a program to find the other one is running, this other program title is not fixed, md5 is not fixed, but is the same program, the detailed point is
There is a procedure A.e xe, this is not I write, is the process of the download
This program A.e xe is titled "aaa", through the localization tools modification A.e xe entitled "BBB", and then stored as B.e xe
I want to write a program, whether a.e xe is b.e xe, can judge the detected
This should write know what I mean

CodePudding user response:

refer to 7th floor zhtmax response:
dizzy, how didn't see the problem?
I'm not write your own programs, to write a program to find the other one is running, this other program title is not fixed, md5 is not fixed, but is the same program, the detailed point is
There is a procedure A.e xe, this is not I write, is the process of the download
This program A.e xe is titled "aaa", through the localization tools modification A.e xe entitled "BBB", and then stored as B.e xe
I want to write a program whether a.e xe also...


Since the title has changed, so you can use the "class name" enumerated by the window, will not change the name of the class, if not the only through a window in the name of the class to find, that is to say, other process also have the same name of the class, so you can search through each exe Z sequence to determine which is the A.e xe and B.e xe, Z sequence can definitely meet your requirements,

CodePudding user response:

refer to the second floor zhtmax response:
can not detailed point, MD5 is not applicable, because there can be a program in a word, the same program, for example, one is English, one is the localization, they are the same program, but the MD5 certainly is not the same, how to judge whether it run, whether in English or localization version of

I know what you mean, like a game of the main program, there may be original, may have localization
There are many ways, such as a MD5 contrast table, or again, find EXE feature codes (I did a similar function, I adopt the PE file to compile time as signature)
EXE or see the relative path again some file exists, if present, is considered to be the specified EXE running
Such as QQ. Exe with directory IM. DLL and ABL. Sys file,,,,

Other methods and there are many different one, for example, can fulfill your purpose

CodePudding user response:

Pay attention to the usage findwindow, not necessarily find the title, also can check the window class name, the name of the class will not change during localization.

FindWindow (lpClassName, {window class name} lpWindowName: PChar title} {window) : HWND; {returns a handle to the window. Failure to return 0}

CodePudding user response:

 function IsFileInUseEx (FileName: string) : Boolean; 
Var
HFileRes: HFILE;
FileAttr: Integer;
The begin
Result:=False;
FileAttr:=GetFileAttributes (Pchar (FileName));
If (FileAttr mod 2)=1 then SetFileAttributes (Pchar (FileName), 0).
HFileRes:=CreateFile (PChar (FileName), GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0).
Try
Result:=(hFileRes=INVALID_HANDLE_VALUE);
If FileAttr & lt;> 0 then SetFileAttributes (Pchar (FileName), FileAttr);
The Finally
The CloseHandle (hFileRes);
The End;
end;
  • Related