Code archives/Miscellaneous/Shutdown and restart your program or visit a webpage

This code has been declared by its author to be Public Domain code.

Download source code

Shutdown and restart your program or visit a webpage by Zethrax2015
*** Blitz3D Code ***

Code shows how to do a shutdown and restart of your program to apply graphics changes, visit a webpage or shell execute a program on exit, etc. Also shows how to get the executable path, including the exe filename.

*** To test this code, compile it as an executable. ***

This code shows how to restart a program executable. This can be useful to apply graphics changes that require a program restart (assuming the preference settings for those changes have been saved and will be loaded and applied on restart).

The code also shows how to open a web-page URL in the user's default browser on shutdown. This can be useful if you want to give the user the option to visit the home-page for your program, or if your game contains advertising that the user can click on to shutdown the program and go to the ad's web-page.

REQUIRES:-
Userlib 'kernel32.decls' decls file for 'Kernel32.dll' - http://www.blitzbasic.com/codearcs/codearcs.php?code=1180


The code can be found at: http://www.blitzbasic.com/codearcs/codearcs.php?code=3185

Comments

Guy Fawkes2015
Nice, but for me, it just counts down to 0 & closes when trying to restart. :/


BlitzSupport2015
Did you build as executable?

Works well here!


Guy Fawkes2015
Works now! Thanks, @Blitz!


dna2015
Hello.

I get the error:
api_GetCommandLine() not found for some reason.

** I see. I forgot the kernel32.decls file.

*** I hate to seem like an Idiot but I'm using B3D. Does this only work with B2D?


Zethrax2015
I haven't tested it with BlitzPlus but it would likely work with that. It's pretty simple code so you should be able to adapt it to work with other Windows based languages.


Code Archives Forum