asp调用自己写的DLL出错,高手指点,做在那里!
itfly 2006-02-28 12:00:50 dll内容:
Option Explicit
Private Const NO_ERROR = 0
Private Declare Function inet_addr Lib "wsock32.dll" _
(ByVal s As String) As Long
Private Declare Function SendARP Lib "iphlpapi.dll" _
(ByVal DestIP As Long, _
ByVal SrcIP As Long, _
pMacAddr As Long, _
PhyAddrLen As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(dst As Any, _
src As Any, _
ByVal bcount As Long)
Public Function GetRemoteMACAddress(ByVal sRemoteIP As String) As String
Dim dwRemoteIP As Long
Dim pMacAddr As Long
Dim bpMacAddr() As Byte
Dim PhyAddrLen As Long
Dim cnt As Long
Dim tmp As String
dwRemoteIP = inet_addr(sRemoteIP)
If dwRemoteIP <> 0 Then
'set PhyAddrLen to 6
PhyAddrLen = 6
'retrieve the remote MAC address
If SendARP(dwRemoteIP, 0&, pMacAddr, PhyAddrLen) = NO_ERROR Then
If pMacAddr <> 0 And PhyAddrLen <> 0 Then
'returned value is a long pointer
'to the mac address, so copy data
'to a byte array
ReDim bpMacAddr(0 To PhyAddrLen - 1)
CopyMemory bpMacAddr(0), pMacAddr, ByVal PhyAddrLen
'loop through array to build string
For cnt = 0 To PhyAddrLen - 1
If bpMacAddr(cnt) = 0 Then
tmp = tmp & "00-"
Else
tmp = tmp & Hex$(bpMacAddr(cnt)) & "-"
End If
Next
'remove the trailing dash
'added above and return True
If Len(tmp) > 0 Then
GetRemoteMACAddress = Left$(tmp, Len(tmp) - 1)
Else
GetRemoteMACAddress = ""
End If
Else
GetRemoteMACAddress = ""
End If
Else
GetRemoteMACAddress = ""
End If 'SendARP
Else
GetRemoteMACAddress = ""
End If 'dwRemoteIP
End Function
asp代码:
<%
set thismac = server.CreateObject( "H_MAC.GetMAC")
response.write "当前网卡IP:" & Request.Servervariables("LOCAL_ADDR")
response.Write " 对应的MAC为:" & thismac.GetRemoteMACAddress(Request.Servervariables("LOCAL_ADDR"))
set S_MAC = nothing
%>
错误代码:
当前网卡IP:192.168.1.6
Microsoft VBScript 编译器错误 错误 '800a03f6'
缺少 'End'
/iisHelp/common/500-100.asp,行242
Microsoft VBScript 运行时错误 错误 '800a01fb'
出现一个意外错误: 'GetRemoteMACAddress'
/index.asp,行13