question about user32.dll (1 Viewer)

accessuser1023

Registered User.
Local time
Today, 04:10
Joined
Nov 12, 2012
Messages
71
all,

do the functions in this lib ever change? I'm dealing with deployment environments that range from windows XP all the way up to windows 8. If I reference functions in this lib by declaring them in VBA, does anyone think there will be issues with this across that huge span of OS's?

thanks.
 

pr2-eugin

Super Moderator
Local time
Today, 10:10
Joined
Nov 30, 2011
Messages
8,494
I am not entirely sure, but in general/theory, it will always be forward compatible.. So I think it should be fine.. However you might want to look at declaring the functions as PtrSafe as newer versions of VB and Access versions they might be both 32 bit and 64 bit..
 

accessuser1023

Registered User.
Local time
Today, 04:10
Joined
Nov 12, 2012
Messages
71
newer versions of office *are* 32 and 64 bit. what you just said is justified immediately by the initial text on this page:

http://msdn.microsoft.com/en-us/library/office/gg278832.aspx

way to go. thanks. :)

However, see the attached image for the VBA version in Office 2007. It's 6.5. So if I write this in an API declaration ...

Code:
Declare PtrSafe Function LoadCursorBynum Lib "user32" Alias "LoadCursorA" _
  (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
... I get red text, which is a syntax error obviously. But if I leave that keyword out ...

Code:
Declare Function LoadCursorBynum Lib "user32" Alias "LoadCursorA" _
  (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
... then I get NO error. Do you think that this means I can't use this keyword in pre-VBA7 and just check to see if the code errors out on Win7 and Win 8 machines using 64 bit office?

what are your thoughts on that? thanks.
 

Attachments

  • vba version.jpg
    vba version.jpg
    30.6 KB · Views: 205
Last edited:

pr2-eugin

Super Moderator
Local time
Today, 10:10
Joined
Nov 30, 2011
Messages
8,494
As mentioned in the link,
MSDN said:
To ensure backwards compatibility with VBA version 6 and earlier use the following construct:
Code:
#If Vba7 Then 
Declare PtrSafe Function LoadCursorBynum Lib "user32" Alias "LoadCursorA" _
  (ByVal hInstance As Long, ByVal lpCursorName As Long) As LongLong
#Else 
Declare Function LoadCursorBynum Lib "user32" Alias "LoadCursorA" _
  (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
#EndIf
 

Users who are viewing this thread

Top Bottom