Category Archives: Microsoft

String Encrypt and Decrypt

These two function provide a simple method to encrypt and decrypt a string. Simply drop this code in to a module, and it is ready for use. Option Explicit Public Function Encrypt(ByVal icText As String) As StringDim icLen As IntegerDim icNewText As StringicChar = “”   icLen = Len(icText)   For i = 1 To icLen      icChar = Mid(icText, i, 1)      Select Case Asc(icChar)         Case… Read More »

Read Remote Registry

This tip is based on existing tip (but with some bugfixes and explanation). The code should be treated as an example, e.g. more treating needed of other kinds of values Usage Dim CompName, sSMS_Site, sSMS_Travel As String CompName = “\\MyComputerName” sSMS_Site = ReadRemoteReg(CompName, HKEY_LOCAL_MACHINE, _ &nsbp; “SOFTWARE\Microsoft\Windows NT\CurrentVersion”, “SystemRoot”) Attachments File Uploaded Size 970-20190822-170650-remotereg.zip 8/22/2019 5:06:50 PM 2583

Get the Username of the Logged On User

This function will allow you to easily get the username of the currently logged on user. Just pop it in to a module, and you’re good to go. Private Declare Function GetUserName Lib “advapi32.dll” Alias “GetUserNameA” (ByVal lpBuffer As String, nSize As Long) As Long Public Function UserName() As String   Dim cn As String   Dim ls As Long   Dim res As… Read More »

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 »