Category Archives: Microsoft

Find the COM ports

Using API from Kernel32, this code will show you information about the serial or COM ports on the local computer. Module Option Explicit ‘API DeclarationsPublic Declare Function CreateFile Lib “kernel32.dll” Alias “CreateFileA” (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As… Read More »

Get PDC Name

The NetGetDCName function returns the name of the Primary Domain Controller (PDC) or PDC Emulator for the specified domain. Module Option Explicit’API callsPrivate Declare Function NetGetDCName Lib “netapi32.dll” (ServerName As Any, DomainName As Any, lpBuffer As Long) As LongPrivate Declare Function NetApiBufferFree Lib “netapi32.dll” (ByVal pBuffer As Long) As Long Private Declare Sub CopyMem Lib “kernel32.dll” Alias “RtlMoveMemory”… Read More »

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