Home > database >  The original concept to judge whether the program to run
The original concept to judge whether the program to run

Time:09-18

PB want to use to judge whether a Windows program in running,
, using the following function is always unsuccessful: (7) below you have a better way?
The integer li_size=144, li_result
String ls_executable=Space (li_size)
The integer li_module_usage
Uint li_module_handle
Li_result=FindExecutable (as_filename as_directory, ls_executable)
IF li_result & lt; 32 THEN Return FALSE
//such as executable file has been loaded, access to the file handle
Li_module_handle=GetModuleHandle (ls_executable)
IF li_module_handle & lt; 1 THEN
//not loaded
Return FALSE
The ELSE
//to get how many instances in the
Li_module_usage=GetModuleUsage (li_module_handle)
Return TRUE
END the IF

CodePudding user response:

It can judge whether the current process load, judge the external program should traversal process, check whether the program

CodePudding user response:

Oh? Have to traverse the process? FindExecutable judge whether process load, and can't judge whether external program is running?
It seems a little complicated,,

CodePudding user response:

To judge whether the program running, you can use a function
HANDLE CreateMutex (
LPSECURITY_ATTRIBUTES lpMutexAttributes,
BOOL bInitialOwner,
LPCTSTR lpName
);

Create a mutex variable, each run returns a handle,
If it is the second run, create the mutex is fail,
The return value may be ERROR_ALREADY_EXISTS shows mutex variable already exists,

This is my a little to create, own watch MSDN reference,

CodePudding user response:

Another method, is to use the DLL, create a Shared memory, record run your application data,

This can also be dealt with,

CodePudding user response:

The problem I met before, and have been resolved:
http://bbs.csdn.net/topics/390192251

CodePudding user response:

My own writing a DLL file, deduced IsRun function, introduced into an executable file path can determine whether a program in execution and need to leave a email or leave a message to me!

CodePudding user response:

Support, I also are paying attention to this problem,,

CodePudding user response:

Filemove failure that has been running or usage
  • Related