Category Archives: Visual Basic 6 (VB6)

Registry Module

Working with the registry is no longer a chore, thanks to this handy module. In the attached module, you’ll find functions to add, remove, and change keys and values in the Windows Registry. Attachments File Uploaded Size 455-20190822-164748-regmodule.zip 8/22/2019 4:47:48 PM 2460

Manage the Registry Module, Part 2

Here is another take on registry management. See the attached ZIP file for the source code. Usage Public Function GetShellFolder(sFolder As String) As String ‘ handle of the registry key to be accessed   Dim hKey As Long’ path of the folder being sought (returned by function)   Dim sFolderName As String’ path of the Shell Folders key in the registry   Dim sShellFoldersPath… Read More »

Enumerate Services to Collection

Here is a class and module that enumerates the services on a Windows computer. It gets each service and puts its info into a public collection which can be used anywhere in the program. The attached ZIP file contains the full class module, as well as the standard module. Usage Option Explicit Private Sub Command1_Click()   Dim x As clsService   Dim… Read More »

Logoff, Shutdown or Restart via API

This handy module will let you perform end-of-session functions,such as logging off the current user, shutting down or restarting the computer. Option Explicit ‘API constantsPrivate Const EWX_LOGOFF = 0Private Const EWX_SHUTDOWN = 1Private Const EWX_REBOOT = 2Private Const EWX_FORCE = 4Private Const TOKEN_ADJUST_PRIVILEGES = &H20Private Const TOKEN_QUERY = &H8Private Const SE_PRIVILEGE_ENABLED = &H2Private Const ANYSIZE_ARRAY = 1Private Const… Read More »

Start, Stop, Pause and Get Status of Services

Using the Windows API, you can easily work with Windows services. This module makes it even easier, allowing you to query status, stop, start, and pause services, on the local machine or remote computers. Option Explicit ‘API ConstantsPublic Const SERVICES_ACTIVE_DATABASE = “ServicesActive”‘ Service ControlPublic Const SERVICE_CONTROL_STOP = &H1Public Const SERVICE_CONTROL_PAUSE = &H2’ Service State – for CurrentStatePublic Const… Read More »

Search Engine

Searches various files on the hard disk depending on the search criteria entered by the user. See the attachement for the zip containing the project files. Attachments File Uploaded Size 967-20190822-115749-searchengine.zip 8/22/2019 11:57:49 AM 39782

Initiate Shutdown or Restart of Specified Computer

Explains how to initiate a shutdown or restart of a local or remote machine. Note that you have to run this with an account that has permission to execute the shutdown/restart on the specified machine. If dwTimeout is not zero, InitiateSystemShutdown displays a dialog box on the specified computer. The dialog box displays the name of the user… Read More »

Protect Form from Accidental Unloading

When you want ot protect the form unload in accidently you can use this following code. In this code, the action is When a form is prepared to unload The unload event was automatically raised on that event there is an parameter named “Cancel” which in the data type integer. When the unload event is raised the “cancel”… Read More »

Remove Extra Spaces from a String

Here is a quick little function to remove extra spaces from within in a string, which might be of help when processing user inputs. Public Function RemoveExtraSpaces(str As String) As String   str = Trim(str)   Dim L As Integer, i As Integer  Dim S As String  Dim Prev_char As String * 1   S = “”   L = Len(str)  i = 1  Do    Prev_char =… Read More »

Determine Even/Odd and Primeness

This is a simple demonstration of one way to determine if a number is even/odd, or prime/not prime. There is very minimal error checking, and the demo can only handle numbers in the range of a long integer. It’s a pretty simple program, meant for beginners to get an idea of how to accomplish this. If you have… Read More »