c.dll
c.c code
__declspec(dllexport)
void boxid_translate_mac_to_boxid(const char* mac_addr, char* boxid_str)+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VB activeX Dll modCdll.bas codeOption ExplicitPublic Declare Sub boxid_translate_mac_to_boxid Lib "c.dll" (ByVal MAC$, ByVal BoxID$)clsBoxID.clsOption ExplicitPublic MAC As StringPublic Function Get_BoxID() As String
Dim BoxID As String
'mac = String(256, 0)
BoxID = String(256, 0)
boxid_translate_mac_to_boxid MAC, BoxID
Get_BoxID = BoxID
End Function
Public Property Let vMAC(ByVal num As String)
MAC = num
End Property
Private Sub Class_Initialize()
MAC = String(256, 0)
End Sub+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
封装后生成新的DLL(BoxID.dll),并且regsvr32注册成功VB standed EXEform窗体上两个textbox(txtMAC,txtBoxID), 两个commandbutton(btnCal,btnEXIT)Private Sub btnCal_Click() Dim getBoxID As New BoxID.clsBoxID
getBoxID.vMAC = CStr(Trim(txtMAC.Text))
'txtBoxID.Text = getBoxID.strTest(mac)
txtBoxID.Text = getBoxID.Get_BoxID
End SubPrivate Sub btnExit_Click()
End
End SubPrivate Sub Form_Load()
btnCal.Enabled = False
End SubPrivate Sub txtMAC_Change()
If Len(txtMAC.Text) = 12 Then
btnCal.Enabled = True
txtBoxID.Text = ""
Else
btnCal.Enabled = False
txtBoxID.Text = ""
End If
End Sub测试数据
in : 004063E3291C
out: BUMAPMV9H9CSP我在vb上直接调试是通过的,但是生成的EXE却不能工作其实我最终的目的是ASP调用,我用ASP也进行了测试,但是报错,下面是
get_BoxID.asp code
<html>
<head><title>Reference DLL</title></head>
<body>
<%
Set BoxID=Server.Createobject("BoxID.clsBoxID")
%>
<form action="get_BoxID.asp" method="post">
<input type="text" name="mac" maxlength="12">
<input type="Submit" value="Submit">
<input type="hidden" value="1" name="hh">
</form>
<%
if request.Form("mac")<> "" then
dim mac
mac = (request.Form("mac"))
if request.Form("hh")=1 then
'response.write BoxID.strTest(mac)
BoxID.vMAC = mac
response.write BoxID.Get_BoxID
end if
else
response.write "please input a valid MAC."
end if
%> </body>
</html>
错误类型:
Response 对象, ASP 0106 (0x80020005)
遇到未处理的数据类型。
/boxid/get_BoxID.asp谢谢
c.c code
__declspec(dllexport)
void boxid_translate_mac_to_boxid(const char* mac_addr, char* boxid_str)+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VB activeX Dll modCdll.bas codeOption ExplicitPublic Declare Sub boxid_translate_mac_to_boxid Lib "c.dll" (ByVal MAC$, ByVal BoxID$)clsBoxID.clsOption ExplicitPublic MAC As StringPublic Function Get_BoxID() As String
Dim BoxID As String
'mac = String(256, 0)
BoxID = String(256, 0)
boxid_translate_mac_to_boxid MAC, BoxID
Get_BoxID = BoxID
End Function
Public Property Let vMAC(ByVal num As String)
MAC = num
End Property
Private Sub Class_Initialize()
MAC = String(256, 0)
End Sub+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
封装后生成新的DLL(BoxID.dll),并且regsvr32注册成功VB standed EXEform窗体上两个textbox(txtMAC,txtBoxID), 两个commandbutton(btnCal,btnEXIT)Private Sub btnCal_Click() Dim getBoxID As New BoxID.clsBoxID
getBoxID.vMAC = CStr(Trim(txtMAC.Text))
'txtBoxID.Text = getBoxID.strTest(mac)
txtBoxID.Text = getBoxID.Get_BoxID
End SubPrivate Sub btnExit_Click()
End
End SubPrivate Sub Form_Load()
btnCal.Enabled = False
End SubPrivate Sub txtMAC_Change()
If Len(txtMAC.Text) = 12 Then
btnCal.Enabled = True
txtBoxID.Text = ""
Else
btnCal.Enabled = False
txtBoxID.Text = ""
End If
End Sub测试数据
in : 004063E3291C
out: BUMAPMV9H9CSP我在vb上直接调试是通过的,但是生成的EXE却不能工作其实我最终的目的是ASP调用,我用ASP也进行了测试,但是报错,下面是
get_BoxID.asp code
<html>
<head><title>Reference DLL</title></head>
<body>
<%
Set BoxID=Server.Createobject("BoxID.clsBoxID")
%>
<form action="get_BoxID.asp" method="post">
<input type="text" name="mac" maxlength="12">
<input type="Submit" value="Submit">
<input type="hidden" value="1" name="hh">
</form>
<%
if request.Form("mac")<> "" then
dim mac
mac = (request.Form("mac"))
if request.Form("hh")=1 then
'response.write BoxID.strTest(mac)
BoxID.vMAC = mac
response.write BoxID.Get_BoxID
end if
else
response.write "please input a valid MAC."
end if
%> </body>
</html>
错误类型:
Response 对象, ASP 0106 (0x80020005)
遇到未处理的数据类型。
/boxid/get_BoxID.asp谢谢
非常的感谢
User: [email protected]
PWD : chelsea请不要随意修改我的密码
直接str=BoxID.Get_BoxID
response.write str试试
加str=BoxID.Get_BoxID
response.write str
试试
CathySun118(斯年) 我的DLL写的有问题,单步调的时候,
c
__declspec(dllexport)
void boxid_translate_mac_to_boxid(const char* mac_addr, char* boxid_str)vb
Public Declare Sub boxid_translate_mac_to_boxid Lib "c.dll" (ByVal MAC$, ByVal BoxID$)Private Sub Class_Initialize()
MAC = String(256, 0)
End Sub
初始化就出问题了试了很多方法,都不能解决,就是调用C指针的问题