advapi32.dll-Can't register it to use in form

G

Guest

I have an existing app running well on many machines.
One particular machine is giving an error that it cannot find a library.
I am using the advapi32.dll to get the user NT login name when they open my
main form, and that is where the program halts.

I searched the registry and found it in many locations, and showing from at
least two sources, win...\system and a .net folder. This machine does have
vs.net installed, while the other machines do not.

I tried to re-register it using regsvr32 c:\winnt\system\advapi32.dll and it
gave an error:
....was loaded but dllregisterserver entry point not found.

I saw the msgs here about registering an ocx, but the registry location does
not apply to me? And, after my last clean attempt to register it, it only
appears in the registry once, as noted below.

I did the obligatory reboots, both cold and warm, and even deleted all
references to this dll and re-registered again. I get the same error, but it
only appears in one area, windows, currentVersion, explorer, runmru, c, and
then advapi32.dll\1, where the dll name did not appear that way, (with a 1),
previously.

Anyone know how I can get this dll cooking on that machine?
 
D

Dan Artuso

Hi,
That DLL is a 'regular' one, not an ActiveX dll so you can't 'register' it.
It simply exports functions. What is the OS that app is running on?
Don't search the registry, search the system32 folder for it.
 
G

Guest

Hi Dan,

It -is- in winnt\system32.
The os (on all the machines) is Win 2000 pro.
Note, that dll does appear in my other machine's registry; that's why I
thought I had to register it.

When my form loads, I grab the nt user login name (on all the other
machines), and on the other machine, I get the error that the library cannot
be found.

MichaelM
 
D

Dan Artuso

Can you post your Declare? Are you sure that this is the library that
count be found?
 
G

Guest

Note: this all works on all my other users, except for this one machine

Bombing on this (X) line:
Private Sub Form_Open(Cancel As Integer)
Dim strUserName As String

(X) Select Case LCase(fOSUserName())

...Case statements follow.


Declaration is:


Option Compare Database
Option Explicit

Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long


Function is:

Public Function fOSUserName() As String
'returns the network login name

Dim lngLen As Long
Dim lngX As Long
Dim strUserName As String

strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen - 1)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen)
Else
fOSUserName = vbNullString
End If

End Function

MichaelM
 
D

Dan Artuso

Hi,
Okay, I'm not sure what to suggest. You can try going to
Tools->References and seeing if one is marked missing
or simply unchecking one then re-checking it.

Also, have you stepped through the code?
 
G

Guest

Not only is nothing missing from References, but all that are checked off on
a working machine are also checked off on the non working machine. And, all
the versions appear to be the same.

The code stops in the form open (highlighted yellow-cursor position), and
the Select Case line has LCase highlighted in blue.

MichaelM
 
G

Guest

References correction:

the -not working- machine has MS Access 11.0 Object Lib
and, the -working- machine has MS Access 9.0 Object Lib

MichaelM
 
D

Dan Artuso

Hi,
We need to see where in the fOSUserName function
it is failing. So, set a breakpoint and step through the code.
I suspect it's not because of the dll but some reference.
Do all the machines have the same version of Access?
 
G

Guest

Hi Dan,

SOLV-ED.
I went in again this morning to start stepping thru the code and ouella, I
got a different error upon first loading the form. It said that msadox.dll
wasn't working.
So, I jumped on that, unchecked it in References, saved and exited Access,
went back in and re-checked and saved it and exited again.

Upon loading the main form again, she worked.
Thanks for hanging in with me.

Only problem I have now is that I started getting 'unsafe blocking' is not
on and they want to install the jet 4 upgrade. But, When I go to windows
update, I can't drill down to it. Will keep trying.

MichaelM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top