Category Archives: Visual Basic 6 (VB6)

Number of Bytes in a Directory

Given a valid path, this code uses Windows API calls to determine the number of bytes in the specified directory, including all subdirectories. Module Option Explicit ‘API constantsPublic Const MAX_PATH = 260Public Const INVALID_HANDLE_VALUE = -1Public Const FILE_ATTRIBUTE_DIRECTORY = &H10 ‘API typesPublic Type FILETIME    dwLowDateTime As Long    dwHighDateTime As LongEnd Type Public Type WIN32_FIND_DATA    dwFileAttributes As Long    ftCreationTime As FILETIME    ftLastAccessTime As FILETIME    ftLastWriteTime… Read More »

Enumerate Users Local or Remote

This is a pair of class modules that allow you to easily enumerate the currently logged in users on either the local machine or a specified remote machine. Class Module: clsGetRemoteLoggedInUsers This class returns the logged in users on a remote or local Workstation when the HostName property is set by your Program. It requires that the Class… Read More »

Save an Error log File

The following code shows how one can record errors to a Errors log file. Create an Errors.log file first and place that file in your apps path. Place the error handling in whatever procedures you want. Place the errLogger procedure in a module as a public procedure or in a form as a private procedure. Module Public Sub… Read More »

Count Files in a Directory

Given a valid path, this code will return the number of files in the specified directory. Module Option Explicit ‘API constantsPublic Const MAX_PATH = 260Public Const INVALID_HANDLE_VALUE = -1Public Const FILE_ATTRIBUTE_DIRECTORY = &H10 ‘API typesPublic Type FILETIME    dwLowDateTime As Long    dwHighDateTime As LongEnd Type Public Type WIN32_FIND_DATA    dwFileAttributes As Long    ftCreationTime As FILETIME    ftLastAccessTime As FILETIME    ftLastWriteTime As FILETIME    nFileSizeHigh As Long    nFileSizeLow As Long    dwReserved0 As… Read More »

Get the Temp Directory

Uses Kernel32 to retrieve the path for the Windows temporary directory. Module Private Declare Function GetTempPath Lib “kernel32.dll” Alias “GetTempPathA” ( _    ByVal nBufferLength As Long, _    ByVal lpBuffer As String _    ) As LongPublic Function GetTempDir() As String’ Returns the temp directory from the OS system    Dim sBuffer As String    Dim HoldBuffer As String    Dim iBuffLen As Long    Dim iReturn As Long    Const BUFFER_LENGTH =… Read More »

Use the Recycle Bin

Demonstration of how to send a file to the Windows Recycle Bin. Module ‘ StructuresPrivate Type SHFILEOPSTRUCT    hwnd As Long    wFunc As Long    pFrom As String    pTo As String    fFlags As Integer    fAnyOperationsAborted As Long    hNameMappings As Long    lpszProgressTitle As LongEnd Type ‘ APIPrivate Declare Function SHFileOperation Lib “shell32.dll” Alias “SHFileOperationA” (lpFileOp As SHFILEOPSTRUCT) As Long ‘ ContantsPrivate Const FO_DELETE = &H3Private Const FOF_ALLOWUNDO = &H40Private… Read More »

Another Way to Check if a File Exists

Using the DIR function may not be the best way to determine if a file exists, especially if you are using VB to compare two directories, and take actions when the files do not match. Module Function FileExist(sTestFile As String) As Boolean    ‘This function does not use DIR since it is possible that you might have    ‘been in the middle… Read More »

Convert Long Filename to Short

Nothing more than converting a long filename to a short 8.3 style filename. Module Private Declare Function GetShortPathName Lib “kernel32.dll” Alias “GetShortPathNameA” ( _    ByVal lpszLongPath As String, _    ByVal lpszShortPath As String, _    ByVal cchBuffer As Long_    ) As LongPublic Function ShortName(LongPath As String) As String’***************************************************************************’ Converts Long FileName to Short FileName’***************************************************************************    Dim ShortPath As String    Dim Ret As Long    Const MAX_PATH = 260… Read More »

Drop in the Bucket

Your plumbing has sprung a leak! Grab your trusty bucket and start catching all those drops of water that are falling from the damaged pipe. This becomes much more challenging with each level, as the difficulty continually increases. Rack up huge scores by earning Bonus Multipliers and the Gold Drop then save your best score on the top… Read More »

Net enum

Sample code from unknown author to enum the computers in a network using API, shows servers and clients with different icons. Ability to send messages to other computers and enum remote PC users. Many other filters can be activated such as SQL controllers to check properties of a network machine. Attachments File Uploaded Size 968-20190909-160046-net_enum.zip 9/9/2019 4:00:46 PM… Read More »