Category Archives: Visual Basic 6 (VB6)

Send a message to a user in your network

This is sort of like the old DOS command NET SEND, allowing you to send messages to other users in your network. Module Option Explicit Private Declare Function NetMessageBufferSend Lib “netapi32.dll” _(ByVal servername As String, _ByVal msgname As String, _ByVal fromname As String, _ByVal Buffer As String, _ByVal BufSize As Long) As Long Private Const NERR_SUCCESS As Long… Read More »

Strip out Strings of exe files

This is a small little bit code that will rip out all the string in a file. Start a new program and place this code in to the General Declarations select of the Form. Also you will need to add a command button to the form as well. Then press F5. Module Public Sub sDumpStrings(strFile As String, strTextFile… Read More »

Run Length Encoding Example

Probably the simplest of compression methods, run length encoding might be useful in helping you store large amounts of repetitive data. Start a new project and add two command buttons to the form and aslo a text box. Now place the follwing code below in to the general declarations selecion of the form and press 5F. Press the… Read More »

Create Controls at RunTime

A module that allows you to create a control during the execution of your program, on the fly. This example creates a simple button. ‘API CallsPublic Declare Function CreateWindowEx Lib “user32.dll” Alias “CreateWindowExA” (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal… Read More »

Get CPU Info

Using GetSystemInfo, inside of kernel32, we can get all kinds of information about the local computer. This example shows how to retrieve the description of the CPU. Module ‘API StructuresPublic Type SYSTEM_INFO    wProcessorArchitecture As Integer    wReserved As Integer    dwPageSize As Long    lpMinimumApplicationAddress As Long    lpMaximumApplicationAddress As Long    dwActiveProcessorMask As Long    dwNumberOfProcessors As Long    dwProcessorType As Long    dwAllocationGranularity As Long    wProcessorLevel As Integer    wProcessorRevision As IntegerEnd Type Public Type OSVERSIONINFO    dwOSVersionInfoSize… Read More »

How to Subclass a Form

Subclassing in Visual Basic is the processing of intercepting Windows messages that a Visual Basic program normally wouldn’t receive. Here is how we can subclass a form with VB6. Module ‘==============inside a MODULEOption Explicit’************************************************************’API’************************************************************ Private Declare Function CallWindowProc Lib “user32.dll” Alias “CallWindowProcA” ( _    ByVal lpPrevWndFunc As Long, _    ByVal hWnd As Long, _    ByVal Msg As Long, _    ByVal wParam As… Read More »

Get the List of the Active Tasks

We’ve already seen how you can kill a task or process, but how about getting a list of running tasks? This should fit the bill nicely. Module Option Explicit ‘ API ConstantsConst WS_MINIMIZE = &H20000000 ‘ Style bit ‘is minimized’Const HWND_TOP = 0 ‘ Move to top of z-orderConst SWP_NOSIZE = &H1 ‘ Do not re-size windowConst SWP_NOMOVE =… Read More »

How to Play a Wave File in VB6

With wave (.WAV) files, you can create voice responses and other audio interaction in your program. Playing wave files in your program is easy, as demonstrated here. Module Option Explicit Public Declare Function sndPlaySound Lib “winmm.dll” Alias “sndPlaySoundA” _    (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Usage Option Explicit Private Sub Command1_Click()    sndPlaySound “C:\WINDOWS\MEDIA\Start.wav”, &H1End Sub

Monitor Mouse and Keyboard Activity

With just a little bit of API goodness, you can monitor mouse and keyboard activity. Option Explicit ‘===========================================================’TYPE’===========================================================Private Type POINTAPIx As Integery As IntegerEnd Type’===========================================================’API’===========================================================Private Declare Sub GetCursorPos Lib “user32.dll” (lpPoint As POINTAPI)Private Declare Function GetAsyncKeyState Lib “user32.dll” (ByVal vKey As Long) As Integer’===========================================================’Variables’===========================================================Private posOld As POINTAPIPrivate posNew As POINTAPI ‘===========================================================’InputCheck’===========================================================Public Function InputCheck() As Boolean    Dim i As Integer… Read More »

User Loop Break

If you have a long-running loop, you might want to give the user the ability to break out of the loop, in case they’ve changed their mind. This bit of code shows how to do that. Module Private Declare Function GetAsyncKeyState Lib “user32.dll” _    (ByVal vKey As Long) As Integer ‘//ESCAPEConst VK_ESCAPE = &H1B’//Button ClickConst VK_LBUTTON = &H1 Usage… Read More »