Struggle with Migrating to 64bit (1 Viewer)

GaP42

Active member
Local time
Today, 21:12
Joined
Apr 27, 2020
Messages
338
I have used the free helper applications by Peter Cole to identify the functions and make changes to the declarations to accommodate moving to 64bit (in fact trying to make it able to generate the 32bit and 64 bit versions), however I have come to a stop when trying to upgrade the code borrowed from The Smiley Coder to capture the screen image when an error arises.

The particular function I am currently attempting to fix is: GdiplusStartup, which has the following 64 bit declaration:
Code:
Private Declare PtrSafe Function GdiplusStartup Lib "GDIPlus" _
        (token As LongPtr, inputbuf As GdipStartupInput, Optional ByVal outputbuf As Long = 0) As Long

On compiling the code it reports 'user-defined type not defined.

The relevant declarations are:
Code:
'Declare a UDT for GDI+

   Private Type GdiplusStartupInput
    #If VBA7 Then
      GdiplusVersion As Long
      DebugEventCallback As LongPtr
      SuppressBackgroundThread As Boolean
      SuppressExternalCodecs As Boolean
      
      GdipToken As LongPtr
      
    #Else
      GdiplusVersion As Long
      DebugEventCallback As Long
      SuppressBackgroundThread As Boolean
      SuppressExternalCodecs As Boolean
      
      GdipToken As Long
      
    #End If

and the function is called through the following:
Code:
' ----==== SaveJPG ====----

Private Sub SaveJPG(ByVal pict As StdPicture, ByVal FileName As String, Optional ByVal quality As Byte = 80)

Dim tSI As GdiplusStartupInput
Dim lRes As Long
Dim lGDIP As GdipToken
Dim lBitmap As Long

   ' Initialize GDI+

   tSI.GdiplusVersion = 1
   lRes = GdiplusStartup(lGDIP, tSI)

   If lRes = 0 Then

      ' Create the GDI+ bitmap
      ' from the image handle
      lRes = GdipCreateBitmapFromHBITMAP(pict.Handle, 0, lBitmap)

      If lRes = 0 Then
         Dim tJpgEncoder As GUID
         Dim tParams As EncoderParameters
etc.

Any suggestions assistance is welcome..

Thankyou
 

Josef P.

Well-known member
Local time
Today, 13:12
Joined
Feb 2, 2023
Messages
826
On compiling the code it reports 'user-defined type not defined.
Is a line in the code highlighted when the compiler message appears?
If not, maybe everything is correct and a decompile removes the "confusion of the compiler".
 

GaP42

Active member
Local time
Today, 21:12
Joined
Apr 27, 2020
Messages
338
Is a line in the code highlighted when the compiler message appears?
If not, maybe everything is correct and a decompile removes the "confusion of the compiler".
Thanks Josef - it highlights the GDI+ function declaration. I'll try the decompile and a compact / repair to see if it makes a change - tomorrow :)
 

Josef P.

Well-known member
Local time
Today, 13:12
Joined
Feb 2, 2023
Messages
826
Eagle-eye mode on: ;)

Code:
Private Declare PtrSafe Function GdiplusStartup Lib "GDIPlus" _
        (token As LongPtr, inputbuf As GdipStartupInput, Optional ByVal outputbuf As Long = 0) As Long

Private Type GdiplusStartupInput

GdipStartupInput vs. GdiplusStartupInput

As soon as a line is marked, the compiler is always right. :) (No decompile is required.)
 
Last edited:

GaP42

Active member
Local time
Today, 21:12
Joined
Apr 27, 2020
Messages
338
Eagle-eye mode on: ;)

Code:
Private Declare PtrSafe Function GdiplusStartup Lib "GDIPlus" _
        (token As LongPtr, inputbuf As GdipStartupInput, Optional ByVal outputbuf As Long = 0) As Long

Private Type GdiplusStartupInput

GdipStartupInput vs. GdiplusStartupInput

As soon as a line is marked, the compiler is always right. :) (No decompile is required.)
Thanks Josef. Made the correction, changing to the GdipStartupInput in the UDT and the call to the function. Compiler progresses past this point. Good eyes! Now to work on the next glitch.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:12
Joined
May 7, 2009
Messages
19,243
also you can remove the:

Private Type GdiplusStartupInput

when you declare the Type as Public:

Code:
'Declare a UDT for GDI+

#If VBA7 Then
    Public Type GdiplusStartupInput
        GdiplusVersion As Long
        DebugEventCallback As LongPtr
        SuppressBackgroundThread As Boolean
        SuppressExternalCodecs As Boolean
        GdipToken As LongPtr
    End Type
#Else
    Public Type GdiplusStartupInput
        GdiplusVersion As Long
        DebugEventCallback As Long
        SuppressBackgroundThread As Boolean
        SuppressExternalCodecs As Boolean
        GdipToken As Long
    End Type
#End If
 
Last edited:

GaP42

Active member
Local time
Today, 21:12
Joined
Apr 27, 2020
Messages
338
Well it might take a bit longer. After fixing and progressing past the sticking point as in post #5, I made some further 64 bit-related changes. Saved and closed. Then disaster - on re-opening the application went into displaying a partial view of the opening form (a variation of the AllenBrowne Splash screen) and then closed Access - no warning message. I have tried a safe mode open and decompile - it continues in the same fashion - repeatedly attempting to open the Splash screen and then closing. (the routine for the splash screen was one that was edited for 64 bit changes, which may not have been completed)
Looks like I will need to go back to a previous backup and redo this update!
 

GaP42

Active member
Local time
Today, 21:12
Joined
Apr 27, 2020
Messages
338
Thanks Sonic8 - I can load the database (FE) and see the objects - however a compact and repair just loops thru and closes the app - I'll explore to see if working on finishing the splash screen updates can fix it first.
 

GaP42

Active member
Local time
Today, 21:12
Joined
Apr 27, 2020
Messages
338
I am caught now with the function InternetGetConnectedState:Thre 32 bit declaration is:
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (lpdwFlags As Long, ByVal dwReserved As Long) As Boolean

- however there is no translation/equivalent I have found for 64 bit.

it is used here:
Code:
Public Function TSCf_IsConnectedToInternet() As Boolean
    On Error Resume Next
    Dim Stat As Long
    TSCf_IsConnectedToInternet = (InternetGetConnectedState(Stat, 0&) <> 0)
End Function

I did find this
https://www.access-programmers.co.u...-windows-os-64-bit-vba-ms-access-2019.320847/ ' refer comment #5 - however as a novice I am not sure of the equivalence/implementation/ substitution
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:12
Joined
May 7, 2009
Messages
19,243
just add PtrSafe:

#If VBA7 Then
Private Declare PtrSafe Function InternetGetConnectedState Lib "wininet.dll" (lpdwFlags As Long, ByVal dwReserved As Long) As Boolean
#Else
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (lpdwFlags As Long, ByVal dwReserved As Long) As Boolean
#End If
 

GaP42

Active member
Local time
Today, 21:12
Joined
Apr 27, 2020
Messages
338
just add PtrSafe:

#If VBA7 Then
Private Declare PtrSafe Function InternetGetConnectedState Lib "wininet.dll" (lpdwFlags As Long, ByVal dwReserved As Long) As Boolean
#Else
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (lpdwFlags As Long, ByVal dwReserved As Long) As Boolean
#End If
Thanks arnelgp - seems so simple! So the rule is - if you cannot find a "translation/equivalent" then just add PtrSafe.
Stepping thru to the next issue

Just checking if TheSmileyCoder has an updated 64bit compatible version to The Access Crash Reporter - I am getting an error on CreateBitmapPicture - Argument not optional: only changes made were to make hBmp and hPal longPtr
Set CaptureWindow = CreateBitmapPicture(hBmp, hPal)
 
Last edited:

GaP42

Active member
Local time
Today, 21:12
Joined
Apr 27, 2020
Messages
338
Thanks Sonic8 - I can load the database (FE) and see the objects - however a compact and repair just loops thru and closes the app - I'll explore to see if working on finishing the splash screen updates can fix it first.
An update: I have managed to fix the loading of the database - after working through the updates to the AllenBrowne Splash Screen routine (with some personal mods). So am happy I did not have to go through a full recovery.
There is still work to be done with the error handling routine adapted from theSmileyCoder (does not appear to be active since mid 2022). I suspect I will need guidance on this.

The partial shot of the splash screen (which can be called up as needed)
 
Last edited:

GaP42

Active member
Local time
Today, 21:12
Joined
Apr 27, 2020
Messages
338
An update - Steve Halder - Halder Consulting - has updated the Smiley Coder's Access Crash Reporter tool to operate in 32 or 64 bit. A link is provided in his blog that allows you to download (https://www.accessjumpstart.com/access-crash-reporter/). Refer to the Smiley coders site for configuration/ explanation.

I think I am now through the updates needed.

Thanks everyone.
 

Users who are viewing this thread

Top Bottom