Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WINAPI Differences
Message
General information
Forum:
Microsoft Office
Category:
Access
Title:
WINAPI Differences
Miscellaneous
Thread ID:
00623689
Message ID:
00623689
Views:
40
I have an application that updates the registry fine on WIN98 machines but fails on WINNT machines with error 59. Is there a difference in the WINAPI call?

Here is a rather long example of my code. Thanks in advance for your assistance.
'  WINAPI CALL FOR CREATING A REGISTRY KEY
    Public Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" _
        (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, _
        ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, _
        ByRef lpSecurityAttributes As Long, phkResult As Long, _
        lpdwDisposition As Long) As Long
    
'  WINAPI CALL FOR SETTING REGISTRY KEY VALUES
    ' Note that if you declare the lpData parameter as String, you must pass it By Value.
    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, ByVal lpData As Any, ByVal cbData As Long) As Long
        
'  WINAPI CALL FOR OPENING A REGISTRY KEY
    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
    
'  WINAPI CALL FOR CLOSING A REGISTRY KEY
    Public Declare Function RegCloseKey Lib "advapi32.dll" _
        (ByVal hKey As Long) As Long
        
'  DECLARE VARS, CONSTANTS, & DATA TYPES
    Public Type SECURITY_ATTRIBUTES
            nLength As Long
            lpSecurityDescriptor As Long
            bInheritHandle As Long
    End Type
    
    Public Const HKEY_CURRENT_USER = &H80000001
    Public Const REG_OPTION_NON_VOLATILE = 0       ' Key is preserved when system is rebooted
    Public Const STANDARD_RIGHTS_ALL = &H1F0000
    Public Const KEY_QUERY_VALUE = &H1
    Public Const KEY_SET_VALUE = &H2
    Public Const KEY_CREATE_SUB_KEY = &H4
    Public Const KEY_ENUMERATE_SUB_KEYS = &H8
    Public Const KEY_NOTIFY = &H10
    Public Const KEY_CREATE_LINK = &H20
    Public Const SYNCHRONIZE = &H100000
    Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
    Public Const ERROR_SUCCESS = 0&
    Public Const REG_SZ = 1                         ' Unicode nul terminated string


Public Function cApprentice(strPath As String) As Boolean

' Begin Code Header Block
'=============================================================
' modRegEdit.cApprentice
'-------------------------------------------------------------
' Purpose  : Create ODBC DSN for the Apprentice DBC
' Author   : Stephen W. Boyd, 11-08-2001
' Notes    : USE WINAPI REGISTRY CALLS
'-------------------------------------------------------------
' Parameters
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
' strPath (String)
'-------------------------------------------------------------
' Returns  : Boolean
'-------------------------------------------------------------
' Revision History
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
' 11-08-2001 SWB:
'=============================================================
' End Code Header block

'  Declare VARS
    Dim hNewKey As Long
    Dim hKey As Long
    Dim rc As Long
    
'  Error Control
    On Error GoTo errHandler
    
'  Create Branch
    rc = RegCreateKeyEx(HKEY_CURRENT_USER, _
        "Software\ODBC\ODBC.INI\Apprentice", _
        0&, _
        vbNullString, _
        REG_OPTION_NON_VOLATILE, _
        KEY_ALL_ACCESS, _
        0&, _
        hNewKey, _
        rc)

'  Check Key
    If rc = ERROR_SUCCESS Then
        rc = RegCloseKey(hNewKey)
        
        cApprentice = True
    Else
        cApprentice = False
    End If

'  Continue Check
    If rc = ERROR_SUCCESS Then
    
    '  Open Key
        rc = RegOpenKeyEx(HKEY_CURRENT_USER, _
            "Software\ODBC\ODBC.INI\Apprentice", _
            0&, _
            KEY_SET_VALUE, _
            hKey)
            
        If rc = ERROR_SUCCESS Then

        '  Set Values
            ' Driver
                rc = RegSetValueEx(hKey, _
                    "Driver", _
                    0&, _
                    REG_SZ, _
                    "C:\Windows\System\vfpodbc.dll", _
                    30)
                    
                    If Not rc = ERROR_SUCCESS Then GoTo errHandler
                    
            '  SourceDB
                rc = RegSetValueEx(hKey, _
                    "SourceDB", _
                    0&, _
                    REG_SZ, _
                    strPath & "appren.dbc", _
                    22)
                    
                    If Not rc = ERROR_SUCCESS Then GoTo errHandler
                    
            '  Description
                rc = RegSetValueEx(hKey, _
                    "Description", _
                    0&, _
                    REG_SZ, _
                    "Apprentice DSN (VFP)", _
                    9)
                    
                    If Not rc = ERROR_SUCCESS Then GoTo errHandler
                
            '  SourceType
                rc = RegSetValueEx(hKey, _
                    "SourceType", _
                    0&, _
                    REG_SZ, _
                    "DBC", _
                    4)
                    
                    If Not rc = ERROR_SUCCESS Then GoTo errHandler
                    
            '  BackGroundFetch
                rc = RegSetValueEx(hKey, _
                    "BackGroundFetch", _
                    0&, _
                    REG_SZ, _
                    "Yes", _
                    4)
                    
                    If Not rc = ERROR_SUCCESS Then GoTo errHandler
                    
            '  Exclusive
                rc = RegSetValueEx(hKey, _
                    "Exclusive", _
                    0&, _
                    REG_SZ, _
                    "No", _
                    3)
                    
                    If Not rc = ERROR_SUCCESS Then GoTo errHandler
                    
            '  Null
                rc = RegSetValueEx(hKey, _
                    "Null", _
                    0&, _
                    REG_SZ, _
                    "Yes", _
                    4)
                    
                    If Not rc = ERROR_SUCCESS Then GoTo errHandler
                    
            '  Deleted
                rc = RegSetValueEx(hKey, _
                    "Deleted", _
                    0&, _
                    REG_SZ, _
                    "Yes", _
                    4)
                    
                    If Not rc = ERROR_SUCCESS Then GoTo errHandler
                    
            '  Collate
                rc = RegSetValueEx(hKey, _
                    "Collate", _
                    0&, _
                    REG_SZ, _
                    "Machine", _
                    8)
                    
                    If Not rc = ERROR_SUCCESS Then GoTo errHandler
                    
            '  SetNoCountOn
                rc = RegSetValueEx(hKey, _
                    "SetNoCountOn", _
                    0&, _
                    REG_SZ, _
                    "No", _
                    3)
                    
                    If Not rc = ERROR_SUCCESS Then GoTo errHandler
                    
        '  Return Status
            If rc = ERROR_SUCCESS Then
                cApprentice = True
                RegCloseKey (hKey)
            Else
                cApprentice = False
            End If
            
        End If
                
    End If
    
'  Exit
    Exit Function
    
'  Error Control
errHandler:
    cApprentice = False
End Function
__________________________________
Stephen W. Boyd
NJATC I.T. Support
steveb@njatc.org

"Our perceptions are our personal realities" ...unknown
Reply
Map
View

Click here to load this message in the networking platform