Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
Available now!
Buy at Amazon US or
Buy at Amazon UK



Articles

» Windows API reference
» Webcam streaming in VB.NET
» Remoting with firewalls
» RSA from first principles
» Key & MouseLogger in .NET
» Networking Resource Kit for .NET
» Migrating VB6 Winsock to VB.NET
» Migrating C++ sockets to C#
» RFC Reference guide
» COM Reference guide
» WMI Reference guide
» SQL stored procedures
» TCP & UDP port reference
» NET Framework reference
» Ethernet Type codes
» MAC address assignments
» DLL entry point reference
» Boost SQL performance
» Free SMS Messaging
» Internet Explorer

Contact us

   

Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As _ Integer, ByVal dwReserved As Integer) As Integer

Private Declare Function GetCurrentProcess Lib "kernel32" () As Integer

Private Declare Function OpenProcessToken Lib "advapi32" (ByVal _ ProcessHandle As Integer, ByVal DesiredAccess As Integer, ByRef TokenHandle As Integer) As Integer

Private Declare Function LookupPrivilegeValue Lib "advapi32"  Alias _ "LookupPrivilegeValueA"(ByVal lpSystemName As String, ByVal lpName As _ String, ByRef lpLuid As Form1.LUID) As Integer

Private Declare Function AdjustTokenPrivileges Lib "advapi32" (ByVal _ TokenHandle As Integer, ByVal DisableAllPrivileges As Integer, ByRef _ NewState As Form1.TOKEN_PRIVILEGES, ByVal BufferLength As Integer, ByRef _ PreviousState As Form1.TOKEN_PRIVILEGES, ByRef ReturnLength As Integer) As _ Integer

     

These functions are actually implemented in DLLs contained within the windows operating system, namely user32.dll, kernel32.dll and advapi32.dll.

Finally, a reference to the interoperation services namespace is required

C#

using System.Runtime.InteropServices;

VB.NET

imports System.Runtime.InteropServices

If you are using VB.NET you will need to add a reference (project > Add reference) to Microsoft Visual Basic .NET compatibility runtime. This allows for the more friendly API declarations, which account for much of the structure changes between the C# and VB.NET versions of this application.

To test this application, run it from Visual Studio .NET. Use the field provided to change the reboot time to some time in the future. Ensure that all your work is saved, then check ‘Enable automatic reboot’. Then sit back and watch your computer switch itself off when the timer reaches the designated time.

 

Page 3 


Google

Copyright 2013 Open Merchant Account Ltd.