locked
Safe VBA "Handles" for 32bit and 64bit RRS feed

  • Question

  •  

    I posted this in the wrong forum yesterday.  Hope this is the right place.

     

    Been looking for days and can't find the VBA type I should be using for handles.  Type "Long" won't work once we move to Vista; Right?  VBA Long is only 32bits, but handles under Vista are 64bits.  Won't all my functions that use type "Long" for handles break? 

     

    Type "IntPtr" and Type "SafeHandle" won't compile under VBA, and I can't discover that VBA has type aliasing.  If aliasing was available, I could alias "Handle" to "Long" for now, and to "Currency" later on...

     

    I've tried putting the following within the class module "clsHandle", but not successfully.

     

    #If WIN64 Then
          Public cValue As Currency  'use the only available 64-bit integer for handles
       #Else
          Public cValue As Long      'use a 32-bit integer for handles
       #End If

    Actually, this does sort-of work, but not cleanly; I always have to say "myHndl.cValue = GetWindow(...)" which is contrary to the clean approach I was looking for that won't break when we upgrade.

     

    I'm really stuck...

     

    Wednesday, May 2, 2007 2:29 PM