Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2003 Api calls return ZERO 1

Status
Not open for further replies.

rpierpie

Programmer
Apr 9, 2008
3
0
0
NL
I am using Access 2003 and no Api call will work??
All my Api calls return EMPTY .

Some examples I tried:
[blue]
Declare Function apiGetVersion Lib "kernel32" Alias "GetVersion" () As Long

Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Declare Function api_GetUserName Lib "c:\windows\system32\advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Declare Function gethostbyname Lib "WSOCK32.DLL" (ByVal hostname As String) As Long

Private Declare Function inet_addr Lib "WSOCK32.DLL" (ByVal s As String) As Long[/blue]

When calling no errors (err.LastDllError=0) occur but the return value is always zero.
Like in the next simple example where lngPC will be set to 0:

[blue]1. Private Declare Function GetComputerName Lib "Kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
2.
3. Public Function GetPcName() As String
4. Dim strBuf As String * 16, strPcName As String, lngPc As Long
5. lngPc = GetComputerName(strBuf, Len(strBuf))
6. If lngPc <> 0 Then
7. strPcName = Left(strBuf, InStr(strBuf, vbNullChar) - 1)
8. GetPcName = strPcName
9. Else
10. GetPcName = vbNullString
11. End If
12. End Function[/blue]

I use MS Access 2003 and my computer(s) run Windows XP Pro (SP2).

The last time I needed to use Api calls was with Access 8 and Windows 95, can’t remember that is was such a struggle.

I really hope someone can help me with this.

Thanks,
Raymond


 
The code that you posted works fine for me so I would say that you have environmental issues.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
You are completely right.
I re-installed Windows XP and MsAccess 2003 on new computer and now everything works fine.

Don't now what happened to my other systems.

Thanks!
 
Apparently the anti virus software from Kaspersky seems to be the problem.

Always the Russians! ;-)

Raymond
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top