程序自启动:Const HKEY_LOCAL_MACHINE = &H80000002 Const REG_SZ = 1 ' Unicode nul terminated string Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As LongPrivate Sub Form_Load() Dim ret Dim strPath As String Dim strValue As String Dim b() As BytestrPath = "software\microsoft\windows\currentversion\run" strValue = "1980GAOBO" strdata = "f:\1980gaobo.exe" & vbNullChar b = StrConv(strdata, vbFromUnicode) RegCreateKey HKEY_LOCAL_MACHINE, strPath, ret length = UBound(b) + 1 RegSetValueEx ret, strValue, 0, REG_SZ, b(0), length RegCloseKey ret End Sub 注销的时候程序好象都会被强行停止呀
各位大虾,不会呀!我注销某次会话SQLSERVER仍然工作呀!难道不是吗?
SQL SERVER 是注册成系统的服务进程。 随系统一起启动,与当前是否有用户登陆无关。
to:realdreamer(想做李敖徒弟) ,但是,如何才能象SQLSERVER 一样SQL SERVER 是注册成系统的服务进程。 随系统一起启动,与当前是否有用户登陆无关。
Const REG_SZ = 1 ' Unicode nul terminated string
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As LongPrivate Sub Form_Load()
Dim ret
Dim strPath As String
Dim strValue As String
Dim b() As BytestrPath = "software\microsoft\windows\currentversion\run"
strValue = "1980GAOBO"
strdata = "f:\1980gaobo.exe" & vbNullChar
b = StrConv(strdata, vbFromUnicode)
RegCreateKey HKEY_LOCAL_MACHINE, strPath, ret
length = UBound(b) + 1
RegSetValueEx ret, strValue, 0, REG_SZ, b(0), length
RegCloseKey ret
End Sub
注销的时候程序好象都会被强行停止呀