A downloadable extension for Windows

Download NowName your own price

Have you ever wanted to ensure that your GameMaker game can only be run one instance at a time on a Windows computer?

If the answer is yes, then this extension is for you! GMRuntimeLock's easy to use API (only two functions) allows you to lock down access in a custom manner.

Functions:

  • double GMRuntimeLock_lock(string, double)
  • double GMRuntimeLock_unlock()

The function GMRuntimeLock_lock() takes two parameters. The first, a string, is a unique string for your game. It should be a fixed string, perhaps the name of your game. The second parameter is a timeout value in milliseconds. Passing in 1000 would make the function wait for one second before returning.

The return value is true if the lock was acquired, and false if it failed. The attempt can be repeated as many times as needed or until you deem it has taken too long and stop trying.

The function GMRuntimeLock_unlock() will release the lock. The return value is true if the lock was held, and false if the lock was not held. After this another instance may try to acquire the lock. The lock is automatically released when the program exits so it is not strictly necessary to ensure it is called in a game end event or some other manual process.

The simplest use, exiting the program if the lock can't be acquired on the first try.


A slightly more involved program that will wait until the lock is acquired.




In this latter example, when the lock_acquired variable value is true, instead of just changing what is draw in the windows, the instance could be destroyed, one could use room_goto() to go to the main start room, etc.

To add the extension to a project, select Tools -> Import Local Package, and select the *.yymps file in the directory where you downloaded it.

Note: The extension is for 64-bit projects running on Windows only.

Download

Download NowName your own price

Click download now to get access to the following files:

gmruntimelock-1.0.1.yymps 54 kB
GMRuntimeLockDemo.zip 2 MB

Leave a comment

Log in with itch.io to leave a comment.