Login | Register

Start at startup

July 23, 2006, 14:19 by Calle
[loading]
-->
A Game Maker application works just like any other application, why not copy from the windows dev?

<b>HKCU\Software\Microsoft\Windows\CurrentVersion\Run </b>
Launches a program automatically when a particular user logs in. This key is used when you always want to launch a program when a particular user is using a system.
<b>HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce </b>
Launches a program the next time the user logs in and removes its value entry from the registry. This key is typically used by installation programs.
<b>HKLM\Software\Microsoft\Windows\CurrentVersion\Run </b>
Launches a program automatically at system startup. This key is used when you always want to launch a program on a particular system.

<b>HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce </b>
Launches a program the next time the system starts and removes its value entry from the registry. This key is typically used by installation programs.
<b>HKLM\Software\Microsoft\Windows\CurrentVersion\RunServices </b>
Launches a service (a standard NT service or a background process) automatically at startup. An example of a service is a Web server such as Microsoft Internet Information Server.
<b>HKLM\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce</b>
Launches a service (a standard NT service or a background process) the next time the system is started, then removes its value entry from the registry.


As you can see these are keys to the registry. You are supposed to write to them. You will need to provide one name and one value. The name should be unique for that registry key, so for an example the name of you game/application plus some random numbers maybe will be secure. The value should contain the path towards the game/application which should start. At Windowsdev they provide this example code:

Private Const cPGM = "C:\VB Forum\startup\TestStartup.exe"

Dim oShell As IWshShell_Class
Set oShell = New IWshShell_Class
oShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\MyVBApp", _
cPGM, "REG_SZ"

Now we need to translate that last command, oShell.RegWrite into GML…

registry_write_string_ext(key,name,str)

So… key should be set to any of the keys mentioned above, name should be set to anything unique, suggestively the filename, and the value should be the entire path. The entire path towards to program (and remember that because this path need to be correct, you should every run of your program check it is still correct) is to be found out like this:

Path = working_directory +”yourgame.exe”;

You can look whether your code worked or not by going into Start > Run > msconfig and then look under “Autostart”. If the code worked correctly you should find your own values in that list.

Comments

Loading comments... [loading]
.
Users logged in:

game maker articles, game maker examples, game maker tutorials, gmtutorials, game maker questions and answers, game maker crash course, how to create games