Option Explicit
'*******************************************
'绿色SQL Server模块
‘doStartSQLServe,启动SQL Server
‘doCheckSQLServerStatus,查找sqlservr.exe进程
‘doTerminateSQLServer, 杀掉sqlservr.exe进程
'*******************************************
Public Const listen_port = "7788" '监听端口
Public Const instance_name = "GreenSQL" 'SQL Server实例名
Private Const RegFile = "GreenSQL.reg" 'reg文件名
Private bSingleUser As Boolean '单用户模式
'======================用于创建进程API函数常数定义=====================
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
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 Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Declare Function CreateProcess _
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
'======================用于创建进程API函数常数定义=====================
'======================用于执行程序API函数常数定义=====================
Private Declare Function ShellExecute _
Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Declare Sub Sleep _
Lib "kernel32" (ByVal dwMilliseconds As Long)
'======================用于执行程序API

这段VB6代码提供了启动和停止SQL Server的功能。通过`doStartSQLServer`函数启动SQL Server,利用`doCheckSQLServerStatus`查找sqlservr.exe进程,而`doTerminateSQLServer`函数则负责结束进程。代码中还包含了创建进程、执行程序的API函数声明,以及用于创建进程、查找进程和终止进程的API函数。此外,还涉及到SQL Server实例的注册表文件的创建。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



