Thread: API functions
View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
ALEX ALEX is offline
external usenet poster
 
Posts: 493
Default API functions

On my machine I have these DLLs in the System32 and in the I386 folders but
on the not working machines there is no I386 folder.

However, the username can be the case as well. On the not working machine
the username exists but it's a group username without actual full name.

Thanks everybody. I'll research it further.

"AnExpertNovice" wrote:

Also, "netapi32.dll" may not exist or it may not be available. I'm not sure
if it has to be registered or just in a specific folder or any folder within
the path statement. Start by making sure it is in the same folder as the
other computers

(Mine is in C:\Windows\System32)

--
My handle should tell you enough about me. I am not an MVP, expert, guru,
etc. but I do like to help.


"AnExpertNovice" wrote in message
...
The code only works on 32 bit machines. Ok, there are not many 16 bit
machines left and I don't know of any 64 bit, but still, it is a nit pick
that had to be plucked.

There will be no user name if there is no such environment variable.

Check
in a DOS Command prompt by typing "Set Username". If the message says it

is
not defined then it needs to be created. Of course, this is an

opportunity
to fix the code so that it works when the Username variable doesn't exist.

--
My handle should tell you enough about me. I am not an MVP, expert, guru,
etc. but I do like to help.


"Alex" wrote in message
...
The code with API functions below is working perfectly almost on all
computers but on a few ones is not working. It's from the code to get a

full
user name.
What could be the cause of this?
Thanks
.....
Private Declare Function apiNetGetDCName _
Lib "netapi32.dll" Alias "NetGetDCName" _
(ByVal servername As Long, _
ByVal DomainName As Long, _
bufptr As Long) As Long

' function frees the memory that the NetApiBufferAllocate
' function allocates.
Private Declare Function apiNetAPIBufferFree _
Lib "netapi32.dll" Alias "NetApiBufferFree" _
(ByVal buffer As Long) _
As Long

' Retrieves the length of the specified wide string.
Private Declare Function apilstrlenW _
Lib "kernel32" Alias "lstrlenW" _
(ByVal lpString As Long) _
As Long

Private Declare Function apiNetUserGetInfo _
Lib "netapi32.dll" Alias "NetUserGetInfo" _
(servername As Any, _
UserName As Any, _
ByVal level As Long, _
bufptr As Long) As Long

' moves memory either forward or backward, aligned or unaligned,
' in 4-byte blocks, followed by any remaining bytes
Private Declare Sub sapiCopyMem _
Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, _
Source As Any, _
ByVal Length As Long)

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

Private Const MAXCOMMENTSZ = 256
Private Const NERR_SUCCESS = 0
Private Const ERROR_MORE_DATA = 234&
Private Const MAX_CHUNK = 25
Private Const ERROR_SUCCESS = 0&
....