Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / February 2006

Tip: Looking for answers? Try searching our database.

API functions isn't working on some computers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex - 02 Feb 2006 18:33 GMT
The code with API functions below is working perfectly almost on all
computers  but on a few ones is not working.
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&
....
Dirk Goldgar - 03 Feb 2006 04:10 GMT
> The code with API functions below is working perfectly almost on all
> computers  but on a few ones is not working.
[quoted text clipped - 47 lines]
> Private Const ERROR_SUCCESS = 0&
> ....

Not all API functions are supported on all versions of the Windows
operating system.  In particular, several of the netapi32.dll functions
are listed in my documentation as not supported in Windows 95, 98, and
ME, though I haven't ever checked that myself.  Can you identify OS
differences between the computers where the code is working and those
where it isn't?

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Wayne Morgan - 03 Feb 2006 04:57 GMT
Adding to what Dirk said, I show that

NetApiBufferFree, NetUserGetInfo, NetGetDCName all require WinNT 3.1 or
newer. They don't work on Win9x.

lstrlenW, RtlMoveMemory will work on Win95 or newer and WinNT 3.1 or newer.

I also found this article which may help with Win9x. It appears to be using
some of the functions above that are listed as not working, but it says it
is calling 16 bit versions of these.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/netmgmt
/determining_the_validating_server_on_windows_95_98_me.asp


Signature

Wayne Morgan
MS Access MVP

> The code with API functions below is working perfectly almost on all
> computers  but on a few ones is not working.
[quoted text clipped - 47 lines]
> Private Const ERROR_SUCCESS = 0&
> ....
Alex - 03 Feb 2006 17:11 GMT
Thank you very much for your responses, guys.
It's Win XP Pro.
On some computers I've identified that they use the group login that of
course doesn't return the full name (the purpose of this function). I'll need
to look at it (if it's NULL case).

> Adding to what Dirk said, I show that
>
[quoted text clipped - 60 lines]
> > Private Const ERROR_SUCCESS = 0&
> > ....
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.