1

Error: 'Can't find DLL Entry point GetSystemInfo in kernel32' is encountered running the code below, but only with a newer version of Kernel32.dll.

Kernel32.dll 6.1.7601.24441 on first machine - NOT working 6.1.7601.24236 on second machine, working fine 6.1.7601.24168 on third machine - working fine

tested on 32 bit and 64 bit versions of Microsoft Access client encountering error is using Kernel32.dll 6.1.7601.24441 on Windows 7 Enterprise 64-bit with Microsoft Access 2016 MSO (16.0.4639.1000) 64-bit all windows and office updates applied

Two MS-Access objects: one Form and one Module MS-Access Form requires a command button named btnDetermineBitVersion

'-----------------begin of form Code

Option Compare Database
Option Explicit

Private Sub btnDetermineBitVersion_Click()
    Dim isSixtyFour As Boolean
    Dim strMessage As String

    isSixtyFour = IsOffice64Bit()

    If isSixtyFour Then
        strMessage = "Using 64 bit version of Microsoft Access"
    Else
        strMessage = "Using 32 bit version of Microsoft Access"
    End If

    MsgBox strMessage, vbInformation, "Library Health Check"

End Sub
' ----------------------- end of Form code
'------------------------ begin of Module
Option Compare Database
Option Explicit

Public Const PROCESSOR_INTEL_386 As Long = 386
Public Const PROCESSOR_INTEL_486 As Long = 486
Public Const PROCESSOR_INTEL_PENTIUM As Long = 586
Public Const PROCESSOR_MIPS_R4000 As Long = 4000
Public Const PROCESSOR_ALPHA_21064 As Long = 21064
Public Const PROCESSOR_PPC_601 As Long = 601
Public Const PROCESSOR_PPC_603 As Long = 603
Public Const PROCESSOR_PPC_604 As Long = 604
Public Const PROCESSOR_PPC_620 As Long = 620
Public Const PROCESSOR_HITACHI_SH3 As Long = 10003
Public Const PROCESSOR_HITACHI_SH3E As Long = 10004
Public Const PROCESSOR_HITACHI_SH4 As Long = 10005
Public Const PROCESSOR_MOTOROLA_821 As Long = 821
Public Const PROCESSOR_SHx_SH3 As Long = 103
Public Const PROCESSOR_SHx_SH4 As Long = 104
Public Const PROCESSOR_STRONGARM As Long = 2577
Public Const PROCESSOR_ARM720 As Long = 1824
Public Const PROCESSOR_ARM820 As Long = 2080
Public Const PROCESSOR_ARM920 As Long = 2336
Public Const PROCESSOR_ARM_7TDMI As Long = 70001

Public Const PROCESSOR_ARCHITECTURE_INTEL As Long = 0
Public Const PROCESSOR_ARCHITECTURE_MIPS As Long = 1
Public Const PROCESSOR_ARCHITECTURE_ALPHA As Long = 2
Public Const PROCESSOR_ARCHITECTURE_PPC As Long = 3
Public Const PROCESSOR_ARCHITECTURE_SHX As Long = 4
Public Const PROCESSOR_ARCHITECTURE_ARM As Long = 5
Public Const PROCESSOR_ARCHITECTURE_IA64 As Long = 6
Public Const PROCESSOR_ARCHITECTURE_ALPHA64 As Long = 7
Public Const PROCESSOR_ARCHITECTURE_AMD64 As Long = 9
Public Const PROCESSOR_ARCHITECTURE_UNKNOWN As Long = &HFFFF&

Public Const PROCESSOR_LEVEL_80386 As Long = 3
Public Const PROCESSOR_LEVEL_80486 As Long = 4
Public Const PROCESSOR_LEVEL_PENTIUM As Long = 5
Public Const PROCESSOR_LEVEL_PENTIUMII As Long = 6

Public Const sCPURegKey = "HARDWARE\DESCRIPTION\System\CentralProcessor\0"

Public Const HKEY_LOCAL_MACHINE As Long = &H80000002


#If VBA7 Then
    Public Type SYSTEM_INFO
       wProcessorArchitecture As Integer
       dwOemID As Long
       dwPageSize As Long
       lpMinimumApplicationAddress As LongPtr
       lpMaximumApplicationAddress As LongPtr
       dwActiveProcessorMask As LongPtr
       dwNumberOfProcessors As Long
       dwProcessorType As Long
       dwAllocationGranularity As Long
       wProcessorLevel As Integer
       wProcessorRevision As Integer
    End Type
#Else
    Public Type SYSTEM_INFO
       wProcessorArchitecture As Integer
       dwOemID As Long
       dwPageSize As Long
       lpMinimumApplicationAddress As Long
       lpMaximumApplicationAddress As Long
       dwActiveProcessorMask As Long
       dwNumberOfProcessors As Long
       dwProcessorType As Long
       dwAllocationGranularity As Long
       wProcessorLevel As Integer
       wProcessorRevision As Integer
    End Type
#End If

#If VBA7 Then
    Public Declare PtrSafe Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
#Else
    Public Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
#End If

#If VBA7 Then
    Declare PtrSafe Function IsWow64Process Lib "kernel32" ( _
        ByVal hProcess As LongPtr, _
        ByRef Wow64Process As Boolean) As Boolean

    Declare PtrSafe Function GetCurrentProcess Lib "kernel32" () As LongPtr
#Else
    Declare Function IsWow64Process Lib "kernel32" ( _
        ByVal hProcess As Long, _
        ByRef Wow64Process As Boolean) As Boolean

    Declare Function GetCurrentProcess Lib "kernel32" () As Long
#End If

Function IsOffice64Bit() As Boolean

    Dim SI As SYSTEM_INFO

    IsOffice64Bit = False
    GetSystemInfo SI
    If SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 Then
        IsWow64Process GetCurrentProcess(), IsOffice64Bit
        IsOffice64Bit = Not IsOffice64Bit
    End If

End Function

'------------------------end of Module

The expected result is a simple message. The result when running on a machine using Kernel32.dll version 6.1.7601.24441 is either a crash or 'Can't find DLL entry point GetSystemInfo in kernel32'.

1
  • I'd try GetNativeSystemInfo, also because GetSystemInfo might produce incorrect results when used this way when running 32-bits VBA and 64-bits Windows.
    – Erik A
    May 19, 2019 at 14:13

2 Answers 2

3

It has been discovered that my client's security program named 'PROTECT' was blocking scripts inside our MS-Access front-end program files from accessing kernel32.dll. Thanks all for taking a shot at this.

0

Since I don't have Windows 7, I unfortunately can't check that.

But since your question doesn't say exactly whether you need to solve exactly the API problem, or just need the functionality, here's a simple alternative solution:

Public Function IsOffice64Bit() As Boolean
    #If Win64 Then
        IsOffice64Bit = True
    #End If
End Function
6
  • My mistake for not being more specific then. I need to solve the API problem. I'm making numerous calls to the kernel32.dll but I simplified my code example. May 18, 2019 at 20:56
  • All this code posted, but left out the the all important all knowing declare line for the API call. For Access x32, if it works, then it will work on all platforms. However, for Access x64 you need to ensure that memory pointers are of x64 bit length. You have to match up the x64 required varibles with the x64 bit API call (memory pointers). So, you need longLong or better yet LongPtr in the API call. Thankfully LongPtr is x32 bits in x32 version, and x64 bits in x64 version. So, you need to use LongPtr correctly in the x64 bit calls. The ONLY part to fix is the API call and you left that out. May 19, 2019 at 12:04
  • @albert-d-kallal: Take a deeper look, the Declare statement isn’t missing. ;-)
    – AHeyne
    May 19, 2019 at 12:26
  • ah very good - by bad, my apologies. Rather surprising that .dll entry points would change - that is VERY rare (MS does not do this and is not supposed to). Does code only break for x64, or does it break simply on all machines - even the x32 bit version with the later .dll? May 19, 2019 at 22:57
  • Remember, for x32 version, the kernel32.dll is in the syswow folder. The system32 folder is actually the x64 bit version of the .dll. ---- see this link - it suggests that the entry points may well be different and change: social.msdn.microsoft.com/Forums/windowsdesktop/en-US/… May 19, 2019 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.