| |

VerySource

 Forgot password?
 Register
Search
View: 20|Reply: 3

How to make the program run only one instance in PB

[Copy link]

1

Threads

1

Posts

2

Credits

Newbie

Rank: 1

Credits
2

 China

Post time: 2020-3-18 22:00:01
| Show all posts |Read mode
How to make the program run only one instance in PB
Reply

Use magic Report

0

Threads

21

Posts

18

Credits

Newbie

Rank: 1

Credits
18

 China

Post time: 2020-6-22 16:45:01
| Show all posts
app open write
ls_temp ='A random string'
gl_mutex = CreateMutex(0,0,ls_temp)
i = getlasterror()
if I = 183 and handle(GetApplication())> 0 then
messagebox('Message','xx system process is already running!', exclamation!)
return
end if

Function declaration
function ulong CreateMutex (ulong lpMutexAttributes, int bInitialOwner, ref string lpName) library "kernel32.dll" ALIAS FOR "CreateMutexA"
function ulong GetLastError () library "kernel32.dll"
function ulong ReleaseMutex(LONG H) library "kernel32.dll"
Reply

Use magic Report

0

Threads

98

Posts

52

Credits

Newbie

Rank: 1

Credits
52

 China

Post time: 2020-6-22 18:15:01
| Show all posts
long ll_winhandle
string ls_class,ls_winTitle
setNull(ls_class)
ls_winTitle = "Program main window name"
//Check if the main window already exists
ll_winhandle = FindWindowA(ls_class,ls_winTitle)
if ll_winhandle> 0 then
BringWindowToTop(ll_winhandle)
halt close
end if
Reply

Use magic Report

0

Threads

98

Posts

52

Credits

Newbie

Rank: 1

Credits
52

 Germany

Post time: 2020-6-22 20:30:01
| Show all posts
Function ulong BringWindowToTop(ulong HWND) Library "user32.dll"
Function ulong FindWindowA (String lpClassName,String lpWindowName) Library "user32.dll"
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list