Question on manipulating hardware...

Can I manipulate hardware using VB .NET like restarting Windows, locking Windows into only one program, etc...?

If so, can someone help me on how to restart windows?

Thx...

Comments

  • [b][red]This message was edited by kainsworth at 2004-5-2 10:9:6[/red][/b][hr]
    One way of doing this is by means of the ExitWindows API. Put the following code at the top of your form or in a separate Public scope module .
    [code]
    Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As _
    Integer, ByVal dwReserved As Integer) As Integer

    Public Enum Choices
    Logoff = 0
    Shutdown = 1
    Reboot = 2
    ForceLogOff = 4
    ForceReboot = 6
    PowerDown = 8
    ForcePowerDown = 12
    End Enum

    Public Sub ExitFromWindows(ByVal Choice As Choices)
    ExitWindowsEx(Choice, 0)
    End Sub
    [/code]
    Now you can call any of the choices listed in that enumeration above just by passing in the appropriate name, e.g. Put this code in a button click event in a form:
    [code]
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ExitFromWindows(Choices.Logoff)
    End Sub
    [/code]
    if you want to log off.

    It goes almost without saying that the enforced shutting down of a user's system is something that needs to be approached with caution. In most situations you would want to insert code in the calling code above to give them a chance to have their say before you unceremoniously dump them out of their system :-)

    Hope this helps.

    Ged

    PS. I don't know of any way of "locking windows into only one program", and to be honest am not really sure where or when it would be appropriate.

    ==========================================================
    : Can I manipulate hardware using VB .NET like restarting Windows, locking Windows into only one program, etc...?
    :
    : If so, can someone help me on how to restart windows?
    :
    : Thx...
    :



  • Thanx a lot Ged!!!

    It really help me much!!!

    One example I want for locking windows to only one program is: I want the Employees of the Company to Time In/Time Out in a Time and Attendance Control System... And the employee can't run other programs or shut down windows until of course they've pressed the Power button...

    Is there any site I can get an information for Windows API in VS .NET that can be easily understant?

    tnx once again...


    : [b][red]This message was edited by kainsworth at 2004-5-2 10:9:6[/red][/b][hr]
    : One way of doing this is by means of the ExitWindows API. Put the following code at the top of your form or in a separate Public scope module .
    : [code]
    : Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As _
    : Integer, ByVal dwReserved As Integer) As Integer
    :
    : Public Enum Choices
    : Logoff = 0
    : Shutdown = 1
    : Reboot = 2
    : ForceLogOff = 4
    : ForceReboot = 6
    : PowerDown = 8
    : ForcePowerDown = 12
    : End Enum
    :
    : Public Sub ExitFromWindows(ByVal Choice As Choices)
    : ExitWindowsEx(Choice, 0)
    : End Sub
    : [/code]
    : Now you can call any of the choices listed in that enumeration above just by passing in the appropriate name, e.g. Put this code in a button click event in a form:
    : [code]
    : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    : ExitFromWindows(Choices.Logoff)
    : End Sub
    : [/code]
    : if you want to log off.
    :
    : It goes almost without saying that the enforced shutting down of a user's system is something that needs to be approached with caution. In most situations you would want to insert code in the calling code above to give them a chance to have their say before you unceremoniously dump them out of their system :-)
    :
    : Hope this helps.
    :
    : Ged
    :
    : PS. I don't know of any way of "locking windows into only one program", and to be honest am not really sure where or when it would be appropriate.
    :
    : ==========================================================
    : : Can I manipulate hardware using VB .NET like restarting Windows, locking Windows into only one program, etc...?
    : :
    : : If so, can someone help me on how to restart windows?
    : :
    : : Thx...
    : :
    :
    :
    :
    :

  • Hi,

    Glad it was some help.

    Most people - me included - find APIs can be a bit difficult at times, so I can't promise you any source that makes them easy to understand initially. However, at one time the KPD Team at allapi.net were the absolute undisputed leaders in all things API. Their original site is at www.allapi.net and although I haven't looked at in a long while, I think it is still worth a visit. They used to have a downloadable application which was basically a searchable database of almost all the API functions. It was however specifically aimed at Vb5 and VB6 developers.
    They went very quiet for a long time, but I see they have now started up a new site which is .Net related at www.mentalis.org. However, you will see that this has nothing like the scope of their original site.
    As I said, it's never been an easy subject in my opinion. Still, with the power of .Net many of the traditional API functions that were well used in VB.Old are no longer needed as equivalent methods are available in the framework.

    ================================================================



    : Thanx a lot Ged!!!
    :
    : It really help me much!!!
    :
    : One example I want for locking windows to only one program is: I want the Employees of the Company to Time In/Time Out in a Time and Attendance Control System... And the employee can't run other programs or shut down windows until of course they've pressed the Power button...
    :
    : Is there any site I can get an information for Windows API in VS .NET that can be easily understant?
    :
    : tnx once again...
    :
    :
    : : [b][red]This message was edited by kainsworth at 2004-5-2 10:9:6[/red][/b][hr]
    : : One way of doing this is by means of the ExitWindows API. Put the following code at the top of your form or in a separate Public scope module .
    : : [code]
    : : Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As _
    : : Integer, ByVal dwReserved As Integer) As Integer
    : :
    : : Public Enum Choices
    : : Logoff = 0
    : : Shutdown = 1
    : : Reboot = 2
    : : ForceLogOff = 4
    : : ForceReboot = 6
    : : PowerDown = 8
    : : ForcePowerDown = 12
    : : End Enum
    : :
    : : Public Sub ExitFromWindows(ByVal Choice As Choices)
    : : ExitWindowsEx(Choice, 0)
    : : End Sub
    : : [/code]
    : : Now you can call any of the choices listed in that enumeration above just by passing in the appropriate name, e.g. Put this code in a button click event in a form:
    : : [code]
    : : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    : : ExitFromWindows(Choices.Logoff)
    : : End Sub
    : : [/code]
    : : if you want to log off.
    : :
    : : It goes almost without saying that the enforced shutting down of a user's system is something that needs to be approached with caution. In most situations you would want to insert code in the calling code above to give them a chance to have their say before you unceremoniously dump them out of their system :-)
    : :
    : : Hope this helps.
    : :
    : : Ged
    : :
    : : PS. I don't know of any way of "locking windows into only one program", and to be honest am not really sure where or when it would be appropriate.
    : :
    : : ==========================================================
    : : : Can I manipulate hardware using VB .NET like restarting Windows, locking Windows into only one program, etc...?
    : : :
    : : : If so, can someone help me on how to restart windows?
    : : :
    : : : Thx...
    : : :
    : :
    : :
    : :
    : :
    :
    :

  • Thanx again!!! That was a great help!!! Anyway, is there a way I can change the backcolor and forecolor of DateTimePicker (the combo box style not the calendar itself).thnx...
    : Hi,
    :
    : Glad it was some help.
    :
    : Most people - me included - find APIs can be a bit difficult at times, so I can't promise you any source that makes them easy to understand initially. However, at one time the KPD Team at allapi.net were the absolute undisputed leaders in all things API. Their original site is at www.allapi.net and although I haven't looked at in a long while, I think it is still worth a visit. They used to have a downloadable application which was basically a searchable database of almost all the API functions. It was however specifically aimed at Vb5 and VB6 developers.
    : They went very quiet for a long time, but I see they have now started up a new site which is .Net related at www.mentalis.org. However, you will see that this has nothing like the scope of their original site.
    : As I said, it's never been an easy subject in my opinion. Still, with the power of .Net many of the traditional API functions that were well used in VB.Old are no longer needed as equivalent methods are available in the framework.
    :
    : ================================================================
    :
    :
    :
    : : Thanx a lot Ged!!!
    : :
    : : It really help me much!!!
    : :
    : : One example I want for locking windows to only one program is: I want the Employees of the Company to Time In/Time Out in a Time and Attendance Control System... And the employee can't run other programs or shut down windows until of course they've pressed the Power button...
    : :
    : : Is there any site I can get an information for Windows API in VS .NET that can be easily understant?
    : :
    : : tnx once again...
    : :
    : :
    : : : [b][red]This message was edited by kainsworth at 2004-5-2 10:9:6[/red][/b][hr]
    : : : One way of doing this is by means of the ExitWindows API. Put the following code at the top of your form or in a separate Public scope module .
    : : : [code]
    : : : Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As _
    : : : Integer, ByVal dwReserved As Integer) As Integer
    : : :
    : : : Public Enum Choices
    : : : Logoff = 0
    : : : Shutdown = 1
    : : : Reboot = 2
    : : : ForceLogOff = 4
    : : : ForceReboot = 6
    : : : PowerDown = 8
    : : : ForcePowerDown = 12
    : : : End Enum
    : : :
    : : : Public Sub ExitFromWindows(ByVal Choice As Choices)
    : : : ExitWindowsEx(Choice, 0)
    : : : End Sub
    : : : [/code]
    : : : Now you can call any of the choices listed in that enumeration above just by passing in the appropriate name, e.g. Put this code in a button click event in a form:
    : : : [code]
    : : : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    : : : ExitFromWindows(Choices.Logoff)
    : : : End Sub
    : : : [/code]
    : : : if you want to log off.
    : : :
    : : : It goes almost without saying that the enforced shutting down of a user's system is something that needs to be approached with caution. In most situations you would want to insert code in the calling code above to give them a chance to have their say before you unceremoniously dump them out of their system :-)
    : : :
    : : : Hope this helps.
    : : :
    : : : Ged
    : : :
    : : : PS. I don't know of any way of "locking windows into only one program", and to be honest am not really sure where or when it would be appropriate.
    : : :
    : : : ==========================================================
    : : : : Can I manipulate hardware using VB .NET like restarting Windows, locking Windows into only one program, etc...?
    : : : :
    : : : : If so, can someone help me on how to restart windows?
    : : : :
    : : : : Thx...
    : : : :
    : : :
    : : :
    : : :
    : : :
    : :
    : :
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories