The era of VB6 may be considered "legacy" by some, but for those who appreciate elegant simplicity and rapid development, it remains an invaluable tool in the modern programmer's toolkit.
A Library Management System developed in Visual Basic 6.0, using MS Access DB - TalhaObaid/library-management-system Library management
Option Explicit ' Win32 API Declarations Public Const TH32CS_SNAPPROCESS As Long = &H2 Public Const PROCESS_TERMINATE As Long = &H1 Public 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 As String * 260 End Type Public Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long Public Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long Public Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long ' Populates a ListBox with current running processes Public Sub RefreshProcessList(lstTarget As ListBox) Dim hSnapshot As Long Dim pe32 As PROCESSENTRY32 Dim fSuccess As Long Dim exeName As String lstTarget.Clear pe32.dwSize = Len(pe32) hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) If hSnapshot = -1 Then Exit Sub fSuccess = Process32First(hSnapshot, pe32) Do While fSuccess ' Clean fixed-length string null characters exeName = Left$(pe32.szExeFile, InStr(pe32.szExeFile, Chr$(0)) - 1) ' Store process name along with its PID packed into the string item lstTarget.AddItem exeName & " (PID: " & pe32.th32ProcessID & ")" fSuccess = Process32Next(hSnapshot, pe32) Loop CloseHandle hSnapshot End Sub ' Forces a process shutdown by its Process Identifier (PID) Public Function KillProcessByPID(ByVal PID As Long) As Boolean Dim hProcess As Long Dim result As Long ' Request explicit termination rights from kernel hProcess = OpenProcess(PROCESS_TERMINATE, 0, PID) If hProcess <> 0 Then result = TerminateProcess(hProcess, 0) CloseHandle hProcess KillProcessByPID = (result <> 0) Else KillProcessByPID = False End If End Function Use code with caution. 4. Flat-File Cryptographic Text Editor (CipherPad) Project Overview