Налобал я такую процедуру которая читает раздел реестра HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run Const ERROR_NO_MORE_ITEMS = 259& Const HKEY_LOCAL_MACHINE = &H80000002 Const KEY_ENUMERATE_SUB_KEYS = &H8 Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long Public Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As Any) As Long Public Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long Public RegCount As Byte
Public Sub CheckExistance() Dim hKey As Long, Cnt As Long, ParametrName As String, Value As String, LengthOfParametr As Long, LengthOfValue As Long Dim Reg As Object Const BUFFER_SIZE As Long = 255 LengthOfParametr = BUFFER_SIZE RegCount = 0 'Open a registry key If RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", 0, KEY_ENUMERATE_SUB_KEYS, hKey) = 0 Then 'initialize ParametrName = Space(BUFFER_SIZE) Value = Space(BUFFER_SIZE) LengthOfParametr = BUFFER_SIZE LengthOfValue = BUFFER_SIZE 'enumerate the values Do While RegEnumValue(hKey, Cnt, ParametrName, LengthOfParametr, 0, ByVal 0&, ByVal Value, LengthOfValue) <> ERROR_NO_MORE_ITEMS 'show data If LengthOfValue > 0 Then 'prepare for next value If StrComp(Left(ParametrName, LengthOfParametr), App.EXEName & ".exe", vbTextCompare) = 0 And StrComp(Left(Value, LengthOfValue - 1), App.Path + "\" + App.EXEName + ".exe", vbTextCompare) = 0 Then RegCount = RegCount + 1 End If End If Cnt = Cnt + 1 ParametrName = Space(BUFFER_SIZE) Value = Space(BUFFER_SIZE) LengthOfParametr = BUFFER_SIZE LengthOfValue = BUFFER_SIZE Loop 'Close the registry key RegCloseKey hKey Else MsgBox "Error while operating RegOpenKeyEx" End If End Sub Так в 98 без проблем пашет, а XP -не хочет, почему, в чем секрет откройте глаза на истину..:)
Ответить
|