Projects

Find all our projects in development below.
All source code is GNU General Public License (GPL)

QuickQuery Half-Life Edition

Browsing QuickQuery HL Edition/CDMod.bas (2.40 KB)

Attribute VB_Name = "CDMod"

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function CreateProcessByNum Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDirectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const NORMAL_PRIORITY_CLASS = &H20
Private Const WM_CLOSE = &H10

Private Type STARTUPINFO
    cb As Long
    lpReserved As String
    lpDesktop As String
    lpTitle As String
    dwX As Long
    dwY As Long
    dwXSize As Long
    dwYSize As Long
    dwXCountChars As Long
    dwYCountChars As Long
    dwFillAttribute As Long
    dwFlags As Long
    wShowWindow As Integer
    cbReserved2 As Integer
    lpReserved2 As Long
    hStdInput As Long
    hStdOutput As Long
    hStdError As Long
End Type

Private Type PROCESS_INFORMATION
    hProcess As Long
    hThread As Long
    dwProcessId As Long
    dwThreadId As Long
End Type

Private Const STARTF_USESHOWWINDOW = &H1
Private Const SW_MINIMIZE = 6

Public Function EndCD() As Long
Dim CDWnd As Long
    CDWnd = FindWindow("CDeathWndClass", vbNullString)
    EndCD = PostMessage(CDWnd, WM_CLOSE, 0&, 0&)
End Function

Public Function RunCD(CDLocation As String) As Long
On Error Resume Next
Dim typStartUpInfo As STARTUPINFO
Dim typProcessInfo As PROCESS_INFORMATION
    With typStartUpInfo
        .cb = Len(typStartUpInfo)
        .dwFlags = STARTF_USESHOWWINDOW
        .wShowWindow = SW_MINIMIZE
        .lpReserved = vbNullString
        .lpDesktop = vbNullString
        .lpTitle = vbNullString
    End With
    RunCD = CreateProcessByNum(CDLocation, vbNullString, 0, 0, True, NORMAL_PRIORITY_CLASS, ByVal 0&, Left(CDLocation, InStrRev(CDLocation, "\") - 1), typStartUpInfo, typProcessInfo)
    CloseHandle typProcessInfo.hThread
    CloseHandle typProcessInfo.hProcess
End Function


Download QuickQuery HL Edition/CDMod.bas

Back to file list


Back to project page