locked
Ref Shell32 API with late binding RRS feed

  • Question

  • In my poject, I need to ref to Shell32.dll. I donot want to do early binding as I have concerned when this project use in different computer (e.g form XP to Window 7 etc), the link is lost.

    I think the soluiton is using late binding. Please advise whether this  is true.

    If I were to use late binding, how to do it with Access VBA ?

    Thank you.

     


    TS Lim
    Saturday, August 13, 2011 5:48 AM

Answers

  • The terms early and late binding are normally used in conjunction with libraries (COM) that are used by setting a reference. Using the Shell32.dll means using the Shell32 API. This is a clasic API which is invoked by function/method calls. Thus you need to either import these calls in your VBA project - which would be something like early binding as your function calls are compiled against - or you can use the DLL functions like LoadLibrary to load these library at run-time and invoke these functions dynamically.

    But: The Shell32 API is quite stable, so that the overhead for invoking it dynamically is imho to much work. Consider using condition compilation to import different functions and build different versions of your application with static imports. E.g. as Office 2010 handles the 32bit/64bit issues. And see: Setting the conditionals in the VBA properties.


    Microsoft MVP Office Access
    https://mvp.support.microsoft.com/profile/Stefan.Hoffmann
    • Marked as answer by Bruce Song Wednesday, August 24, 2011 3:13 AM
    Saturday, August 13, 2011 9:10 AM
  • TS Lim wrote:

    In my poject, I need to ref to Shell32.dll. I donot want to do early binding as I have concerned when this project use in different computer (e.g form XP to Window 7 etc), the link is lost.

    I agree with Stefan.  I've been using the shell32.dll in the Auto FE
    Updater since 2000 on versions of Windows from Windows 98, NT 4.0 and
    newer.    It's been quite stable

    Now it's possible there are calls to shell32.dll that are unique to
    Windows Vista or Windows 7 that aren't in previous versions. But, as
    Stefan points out, shell32.dll isn't a traditional reference, so it will
    only cause a problem when that line of code is executed.

    Tony


    Tony Toews, Microsoft Access MVP
    Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
    Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
    For a convenient utility to keep your users FEs and other files   updated see http://www.autofeupdater.com/

    • Marked as answer by Bruce Song Wednesday, August 24, 2011 3:13 AM
    Saturday, August 13, 2011 11:10 PM

All replies

  • The terms early and late binding are normally used in conjunction with libraries (COM) that are used by setting a reference. Using the Shell32.dll means using the Shell32 API. This is a clasic API which is invoked by function/method calls. Thus you need to either import these calls in your VBA project - which would be something like early binding as your function calls are compiled against - or you can use the DLL functions like LoadLibrary to load these library at run-time and invoke these functions dynamically.

    But: The Shell32 API is quite stable, so that the overhead for invoking it dynamically is imho to much work. Consider using condition compilation to import different functions and build different versions of your application with static imports. E.g. as Office 2010 handles the 32bit/64bit issues. And see: Setting the conditionals in the VBA properties.


    Microsoft MVP Office Access
    https://mvp.support.microsoft.com/profile/Stefan.Hoffmann
    • Marked as answer by Bruce Song Wednesday, August 24, 2011 3:13 AM
    Saturday, August 13, 2011 9:10 AM
  • TS Lim wrote:

    In my poject, I need to ref to Shell32.dll. I donot want to do early binding as I have concerned when this project use in different computer (e.g form XP to Window 7 etc), the link is lost.

    I agree with Stefan.  I've been using the shell32.dll in the Auto FE
    Updater since 2000 on versions of Windows from Windows 98, NT 4.0 and
    newer.    It's been quite stable

    Now it's possible there are calls to shell32.dll that are unique to
    Windows Vista or Windows 7 that aren't in previous versions. But, as
    Stefan points out, shell32.dll isn't a traditional reference, so it will
    only cause a problem when that line of code is executed.

    Tony


    Tony Toews, Microsoft Access MVP
    Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
    Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
    For a convenient utility to keep your users FEs and other files   updated see http://www.autofeupdater.com/

    • Marked as answer by Bruce Song Wednesday, August 24, 2011 3:13 AM
    Saturday, August 13, 2011 11:10 PM