1. Limit One Copy

Hi All,

Does anyone know how to limit one copy of a program to run under=
 Windows? 

Thank you,
Chris

new topic     » topic index » view message » categorize

2. Re: Limit One Copy

-- allow only one instance of this program
object jk
constant
zCreateSemaphore = registerw32Function(kernel32,"CreateSemaphoreA",
                   {C_POINTER,C_INT,C_INT,C_POINTER},C_INT),
zGetLastError = registerw32Function(kernel32,"GetLastError",{},C_INT),
zERROR_ALREADY_EXISTS = 183
-- create a semaphore for this instance
jk = w32Func(zCreateSemaphore,{NULL, 0, 1, allocate_string("just_once")})
jk = w32Func(zGetLastError,{})
if jk = zERROR_ALREADY_EXISTS then 
  abort(0) -- abort if we're already running !
end if

> Does anyone know how to limit one copy of a program to run under Windows?

new topic     » goto parent     » topic index » view message » categorize

3. Re: Limit One Copy

Thank you Wolf, your code did the trick.

Chris



>
>-- allow only one instance of this program
>object jk
>constant
>zCreateSemaphore =3D=
 registerw32Function(kernel32,"CreateSemaphoreA",
>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0{C_POINTER,C_INT,C_INT,C_POINTER},C_INT),
>zGetLastError =3D
>registerw32Function(kernel32,"GetLastError",{},C_INT),
>zERROR_ALREADY_EXISTS =3D 183
>-- create a semaphore for this instance
>jk =3D w32Func(zCreateSemaphore,{NULL, 0, 1,
>allocate_string("just_once")})
>jk =3D w32Func(zGetLastError,{})
>if jk =3D zERROR_ALREADY_EXISTS then
>=A0abort(0) -- abort if we're already running !
>end if
>
>>=A0Does anyone know how to limit one copy of a program to run=
 under
>>Windows?
>
>
>
>


--

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu