Log off / shut down (Desktop)

LineCutter

Active Member
Licensed User
Longtime User
It looks as if it ought to be possible to signal a logoff or shutdown of the desktop from .NET (& therefore B4PPC). I think that that's a job requiring the door library, but I can't figure out the process for calling a function from a dll loaded by a door object.
:sign0104:

I found this on the 'net:
B4X:
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]Public Class Form1[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]    Inherits System.Windows.Forms.Form[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]    Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long[/COLOR][/COLOR][/SIZE][/FONT]

[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]    Private Enum ExitWindowsFlags[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]        ' logoff user without reboot[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]        Logoff = 0[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]        ' Causes system shutdown[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]        Shutdown = 1[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]        ' system reboot[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]        Reboot = 2[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]        ' add this constant to prevent the user from cancelling[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]        Forceit = 4[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]    End Enum[/COLOR][/COLOR][/SIZE][/FONT]

[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]        ExitWindowsEx(ExitWindowsFlags.Logoff, 0&)[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]    End Sub[/COLOR][/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=#000000]End Class[/COLOR][/COLOR][/SIZE][/FONT]
Can you point me at a way to get at ExitWindowsEx? (In return I'll use it to create a freeware "stop the kids hogging the computer all day" program.)
 

LineCutter

Active Member
Licensed User
Longtime User
Thanks, you've saved me some time by avoiding a futile search for the way to do this. I'll put that project on hold until I can manage a library.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…