Results 1 to 2 of 2

Thread: registry

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2000
    Location
    Faraway from Osama bin Laden <--- Loser
    Posts
    42
    Basically, I want to access the registery with VB. I tried copying the code from vb-world.net's tutorial but the public const wont' work. It gives me an error. I have vb 6.0

    heres the code:
    'None of the Public Const's wont work. It gives me a compile error. Constants, fixed-length strings, etc are not allowed as Public members of object modules

    Public Const HKEY_CLASSES_ROOT = &H80000000
    Public Const HKEY_CURRENT_USER = &H80000001
    Public Const HKEY_LOCAL_MACHINE = &H80000002
    Public Const HKEY_USERS = &H80000003
    Public Const HKEY_CURRENT_CONFIG = &H80000005
    Public Const HKEY_DYN_DATA = &H80000006
    Public Const REG_SZ = 1 'Unicode nul terminated string
    Public Const REG_BINARY = 3 'Free form binary
    Public Const REG_DWORD = 4 '32-bit number
    Public Const ERROR_SUCCESS = 0&

    Public Declare Function RegCloseKey Lib "advapi32.dll" _
    (ByVal hKey As Long) As Long

    Public Declare Function RegCreateKey Lib "advapi32.dll" _
    Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey _
    As String, phkResult As Long) As Long

    Public Declare Function RegDeleteKey Lib "advapi32.dll" _
    Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey _
    As String) As Long

    Public Declare Function RegDeleteValue Lib "advapi32.dll" _
    Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal _
    lpValueName As String) As Long

    Public Declare Function RegOpenKey Lib "advapi32.dll" _
    Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey _
    As String, phkResult As Long) As Long

    Public Declare Function RegQueryValueEx Lib "advapi32.dll" _
    Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName _
    As String, ByVal lpReserved As Long, lpType As Long, lpData _
    As Any, lpcbData As Long) As Long

    Public 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

    --------------
    hot2fire
    --------------
    I hate Microsoft, but I use it because I still badly need it. Hehe. Good luck in VB programming.

  2. #2
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298
    It means pretty much what it says...

    Try replacing each on with private if they are only going to be used within each module.

    e.g.
    Code:
    Private Const HKEY_CLASSES_ROOT = &H80000000
    Or else just use constant.
    e.g.
    Code:
    Const HKEY_CLASSES_ROOT = &H80000000
    Hope it works.
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width