$4.95 Hosting 782x40

Visual Basic Code Snippets #5

Posted by admin on Friday, Sep 11th, 2009 at 12:24 pm
Filed Under: Programming and Visual Basic

In this next update I’ll re-post my Visual Basic code snippets (which are older than five years by the way) that pertain to System Functions.

Shutdown/Poweroff Windows

Compatibility: Win. 98-XP

Add the following code into a module within your project…

Public Declare Function ExitWindowsEx Lib "User32" Alias "ExitWindowsEx"(ByVal uFlags As Long, ByVal dwReserved As Long) As Long

Add the following code into a command button or wherever you want the code to execute…

Call ExitWindowsEx(EWX_POWEROFF,0)

Restart Windows

Compatibility: Win. 98-XP

Add the following code into a module within your project…

Public Declare Function ExitWindowsEx Lib "User32" Alias "ExitWindowsEx"(ByVal uFlags As Long, ByVal dwReserved As Long) As Long

Add the following code into a command button or wherever you want the code to execute…

Call ExitWindowsEx(EWX_REBOOT,0)

Shell Out to Default Web Browser

Compatibility: Win. 98-XP

Add the following code into a module within your project…

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Const conSwNormal = 1

Public Function shellSite(site As String)
ShellExecute hwnd, "open", site, vbNullString, vbNullString, conSwNormal
End Function

Add the following code wherever you want the code to execute…

Call shellSite("http://www.beneskew.com")

Visual Basic Code Snippets #6

Comments (2)

  1. [...] Visual Basic Code Snippets #5 [...]

  2. [...] #1 Visual Basic Code Snippets #2 Visual Basic Code Snippets #3 Visual Basic Code Snippets #4 Visual Basic Code Snippets #5 Visual Basic Code Snippets [...]

Leave a Reply

You must be logged in to post a comment.

Support Mr. Eskew! Buy a Shirt!

QueryVegas.com Tweets