Logging Off/ Logging Out / Shutdown

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
nassausky
Posts: 21
Joined: Wed Nov 18, 2009 4:41 pm

Logging Off/ Logging Out / Shutdown

Post by nassausky »

I am trying to create a time management software for PC's at my library and was looking for an example or info on how to have an HMG application automatically logout at a certain time but the timing shouldn't be a problem. The tough part is to find the xbase code or example to actually do the logout or shutdown.

Thanks!
_________________
Sincerely,

Mike
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Logging Off/ Logging Out / Shutdown

Post by mol »

I think you can use windows shutdown with -l option:
execute file "shutdown.exe -l"

which is placed in windows\system32 folder by default.
jparada
Posts: 433
Joined: Fri Jan 23, 2009 5:18 pm

Re: Logging Off/ Logging Out / Shutdown

Post by jparada »

Hi,

A little example:

Code: Select all

#include "hmg.ch"

Function Main
	
	DEFINE WINDOW frmMain ;
		AT 0,0 ;
		WIDTH 400 ;
		HEIGHT 400 ;
		TITLE 'ShutDown' ;
		MAIN
		
		DEFINE BUTTON btnShutDown
			ROW	200
			COL	 40
			CAPTION	"ShutDown!!! - WARNING"
			ACTION	{ ShellExecute( 0, "Open", "C:\Windows\System32\ShutDown.exe", " -s -t 0", 0, 1 ) }
			WIDTH	160
			HEIGHT	40
		END BUTTON

	END WINDOW

	ACTIVATE WINDOW frmMain
	
Return
I tested on Windows Vista and it worked fine, please be careful!!!

Here you have a link for more information http://www.computerhope.com/shutdown.htm

HTH

Best Regards
Javier
nassausky
Posts: 21
Joined: Wed Nov 18, 2009 4:41 pm

Re: Logging Off/ Logging Out / Shutdown

Post by nassausky »

Oh excellent I will try that out today or tomorrow :)

Thank you very much.
_________________
Sincerely,

Mike
Post Reply