Solved

Looking for 64bit version of Declare Function GetUserName Lib

Posted on 2014-03-27
2
3,290 Views
Last Modified: 2014-03-28
I am using getusername function to use Windows login for security.  However, when I tried to use the mdb on a 64 bit setup I get the following error msg.

Compile Error

The code in this project must be updated to 64bit systems.  Please review and updatet declare statetments and then mark them with the PtrSafe atribute.

What do I need to do this?
0
Comment
Question by:Karen Schaefer
2 Comments
 
LVL 12

Accepted Solution

by:
pdebaets earned 500 total points
ID: 39961031
Here's the 64-bit definition:

Declare PtrSafe Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Open in new window

To make your db 32 and 64 bit compatible, include a check for the VBA7 compiler directive constant

#if VBA7 then
'* My 64-bit declarations
Declare PtrSafe Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#else
'* My 32-bit declarations
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#end if

Open in new window

0
 

Author Closing Comment

by:Karen Schaefer
ID: 39962076
great thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bind Combobox 4 29
subtract 1 in Access 2003 query 7 37
combine ShipTo and BillTo Address 3 22
count all and uniques records in a table 20 21
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now