PC Review


Reply
Thread Tools Rate Thread

advapi32.dll

 
 
=?Utf-8?B?SmltUw==?=
Guest
Posts: n/a
 
      2nd Aug 2007
I've had the fosusername() function running on a client's computer for a long
time. Suddenly, it can't find the "tacomp90.ocx" library when executing
fOSUsername().
The function references "advapi32.dll" and errors out on a function call:

strUserName=String$(254,0)


Here's the code, straight from the MVP web site. Strangely, it works on my
computer, and not on hers:

Note: I did add in FMS codetools, etc to my computer, used on that database.
But that doesn't seem to be the module it's having troubles with...

Option Compare Database
Global glbUserName As String
Global glbUserId As String
Global glbUserAuthLevel As Long
Global glbModuleID As Byte

'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = UCase(Left$(strUserName, lngLen - 1))
Else
fOSUserName = vbNullString
End If
End Function
'******************** Code End **************************


--
Jim
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      2nd Aug 2007
If that specific line is causing you problems, it has nothing to do with
advapi32.dll: it's almost guaranteed to be a problem with your References
collection.

Go into the VB Editor and select Tools | References from the menu bar.
Examine all of the selected references.

If any of the selected references have "MISSING:" in front of them, unselect
them, and back out of the dialog. If you really need the reference(s) you
just unselected (you can tell by compiling your application, under the Debug
menu), go back in and reselect them.

If none have "MISSING:", select an additional reference at random, back out
of the dialog, then go back in and unselect the reference you just added. If
that doesn't solve the problem, try to unselect as many of the selected
references as you can (Access may not let you unselect them all), back out
of the dialog, then go back in and reselect the references you just
unselected. (NOTE: write down what the references are before you delete
them, because they'll be in a different order when you go back in)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"JimS" <(E-Mail Removed)> wrote in message
news:E1BFA48E-58BA-49BA-AB7E-(E-Mail Removed)...
> I've had the fosusername() function running on a client's computer for a
> long
> time. Suddenly, it can't find the "tacomp90.ocx" library when executing
> fOSUsername().
> The function references "advapi32.dll" and errors out on a function call:
>
> strUserName=String$(254,0)
>
>
> Here's the code, straight from the MVP web site. Strangely, it works on my
> computer, and not on hers:
>
> Note: I did add in FMS codetools, etc to my computer, used on that
> database.
> But that doesn't seem to be the module it's having troubles with...
>
> Option Compare Database
> Global glbUserName As String
> Global glbUserId As String
> Global glbUserAuthLevel As Long
> Global glbModuleID As Byte
>
> '******************** Code Start **************************
> ' This code was originally written by Dev Ashish.
> ' It is not to be altered or distributed,
> ' except as part of an application.
> ' You are free to use it in any application,
> ' provided the copyright notice is left unchanged.
> '
> ' Code Courtesy of
> ' Dev Ashish
> '
> Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
> "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
> Function fOSUserName() As String
> ' Returns the network login name
> Dim lngLen As Long, lngX As Long
> Dim strUserName As String
> strUserName = String$(254, 0)
> lngLen = 255
> lngX = apiGetUserName(strUserName, lngLen)
> If (lngX > 0) Then
> fOSUserName = UCase(Left$(strUserName, lngLen - 1))
> Else
> fOSUserName = vbNullString
> End If
> End Function
> '******************** Code End **************************
>
>
> --
> Jim



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing advapi32.dll in XP SP2 and XP SP3 Izyani Windows XP General 2 11th Dec 2008 06:24 AM
Using ConvertSidToStringSid() in advapi32.dll =?Utf-8?B?U2NvdHRpZV9kbw==?= Microsoft C# .NET 3 2nd Feb 2006 11:01 AM
Advapi32.dll Stephen Hartman Microsoft Windows 2000 1 16th Feb 2005 04:17 PM
IE6 SP1 error with ADVAPI32.dll David Microsoft Windows 2000 Windows Updates 0 7th Jun 2004 11:25 PM
Re: ADVAPI32.dll and spoolsv.exe Carey Gregory Microsoft Windows 2000 Printing 2 15th Sep 2003 05:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:52 AM.