Log off / shut down (Desktop)

Discussion in 'Questions (Windows Mobile)' started by LineCutter, Oct 15, 2008.

  1. LineCutter

    LineCutter Active Member Licensed 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:
    Code:
    [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.)
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    It is not possible to do it with the Door library, because the ExitWindowsEx is a native method.
    It will require a (small) library.
     
  3. LineCutter

    LineCutter Active Member Licensed 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.
     
  4. agraham

    agraham Expert Licensed User

    I'll knock it up for you tomorrow, should only take a few minutes.
     
  5. LineCutter

    LineCutter Active Member Licensed User

    Is there anything you can't produce a library for?:sign0027:

    Thanks!
     
  6. agraham

    agraham Expert Licensed User

  7. giannimaione

    giannimaione Well-Known Member Licensed User

    Agraham, the best ;)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice