The issue is with Windows data packing, and the difference in 32-bit file structures and 64-bit file structures.
This is for 32-bit:
TYPE FILEDIALOGTYPE
lStructSize AS LONG ' For the DLL call
hwndOwner AS LONG ' Dialog will hide behind window when not set correctly
hInstance AS LONG ' Handle to a module that contains a dialog box template.
lpstrFilter AS _OFFSET ' Pointer of the string of file filters
lpstrCustFilter AS _OFFSET
nMaxCustFilter AS LONG
nFilterIndex AS LONG ' One based starting filter index to use when dialog is called
lpstrFile AS _OFFSET ' String full of 0's for the selected file name
nMaxFile AS LONG ' Maximum length of the string stuffed with 0's minus 1
lpstrFileTitle AS _OFFSET ' Same as lpstrFile
nMaxFileTitle AS LONG ' Same as nMaxFile
lpstrInitialDir AS _OFFSET ' Starting directory
lpstrTitle AS _OFFSET ' Dialog title
flags AS LONG ' Dialog flags
nFileOffset AS INTEGER ' Zero-based offset from path beginning to file name string pointed to by lpstrFile
nFileExtension AS INTEGER ' Zero-based offset from path beginning to file extension string pointed to by lpstrFile.
lpstrDefExt AS _OFFSET ' Default/selected file extension
lCustData AS LONG
lpfnHook AS LONG
lpTemplateName AS _OFFSET
END TYPE
Notice that several of these elements are being transfered as LONG variable types:
lStructSize AS LONG ' For the DLL call
hwndOwner AS LONG ' Dialog will hide behind window when not set correctly
hInstance AS LONG ' Handle to a module that contains a dialog box template.
For 64-bit Windows, all these handles would need to be_INTEGER64 before they could possibly work.
And since data is packed in 8-byte fields usually, you may need to add some Filler to the data structure. For example, let's say I have a data structure like this:
TYPE Example Structure
X AS LONG
Y AS _INTEGER64
END TYPE
In 32-bit, data is packed in 4-byte fields generally, for Window's API Functions, so it's fine as written.
In 64-bit, data is generally packed in 8-byte fields, so your structure would need to become:
TYPE Example Structure
X AS LONG
Filler AS LONG '4 bytes of nothing but space so data fields align properly.
Y AS _INTEGER64
END TYPE
I ran into this same issue with the windows Printer Selection routines, and talked about the issue here, previously:
https://www.qb64.org/forum/index.php?topic=1859.msg110961#msg110961