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 »

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 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 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 »

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 »

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

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 »

Implement chm Help in Visual Basic

Give your app a more polished appearance by using .chm files for your help system. First place a existing chm File in the project path. You must know what name your htm pages have to work correct. Module Option ExplicitPrivate Declare Function HtmlHelpTopic Lib “hhctrl.ocx” Alias _    “HtmlHelpA” (ByVal hWnd As Long, ByVal lpHelpFile As String, _    ByVal wCommand As… Read More »

Kill a Program Process

This will allow you kill running tasks or processes, provided the account you are running it under has the permissions to do so. This could be useful if you want to write your own version of Task Manager. ‘——————————————————-Type PROCESSENTRY32    dwSize As Long    cntUsage As Long    th32ProcessID As Long    th32DefaultHeapID As Long    th32ModuleID As Long    cntThreads As Long    th32ParentProcessID As Long    pcPriClassBase As Long    dwFlags As Long    szexeFile… Read More »

Move a non-caption form using no API, no DLL

Paste the following code in a module and call it from the mousemove routine of the form that you like to move as: mousemove [form.name],x,y,button. Drag the form to move it, use same calling code if you need to move the form dragging over a control in the form (pay attention to click_routine potential conflict). Sub moveform(ff As Form,… Read More »