VB调用dll出错
PublicDeclareFunctionGetHardwareIDLib"HardwareID.DLL"(ByValHDDAsBoolean,ByValNICAsBoo...
Public Declare Function GetHardwareID Lib "HardwareID.DLL" (ByVal HDD As Boolean, ByVal NIC As Boolean, ByVal CPU As Boolean, ByVal BIOS As Boolean, ByVal RegCode As String) As String
Public Declare Function GetHardwareIDWithAppID Lib "HardwareID.DLL" (ByVal AppID As String, ByVal HDD As Boolean, ByVal NIC As Boolean, ByVal CPU As Boolean, ByVal BIOS As Boolean, ByVal RegCode As String) As String
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub Main()
Dim b_HDD As Boolean
Dim b_NIC As Boolean
Dim b_CPU As Boolean
Dim b_BIOS As Boolean
Dim n As String
Dim m As String
Dim x As String
Dim y As String
b_HDD = False
b_NIC = False
b_CPU = False
b_BIOS = False
Shell "regsvr32 /s HardwareID.dll"
n = CStr(GetHardwareID(b_HDD, b_NIC, b_CPU, b_BIOS, "R5LR-S4TQ"))
m = CStr(App.EXEName)
x = "本程序的名字(Appname)=" & CStr(m) & "/硬件识别码(mid)=" & CStr(n)
MsgBox x
End Sub
本程序要调用一个dll(就是GetHardwareID.dll),我在本机里用VB 6.0调试可以用,但是我生成exer了就报错发生故障。实在不得其解。望各路神仙指点迷经。鄙人先谢过。 展开
Public Declare Function GetHardwareIDWithAppID Lib "HardwareID.DLL" (ByVal AppID As String, ByVal HDD As Boolean, ByVal NIC As Boolean, ByVal CPU As Boolean, ByVal BIOS As Boolean, ByVal RegCode As String) As String
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub Main()
Dim b_HDD As Boolean
Dim b_NIC As Boolean
Dim b_CPU As Boolean
Dim b_BIOS As Boolean
Dim n As String
Dim m As String
Dim x As String
Dim y As String
b_HDD = False
b_NIC = False
b_CPU = False
b_BIOS = False
Shell "regsvr32 /s HardwareID.dll"
n = CStr(GetHardwareID(b_HDD, b_NIC, b_CPU, b_BIOS, "R5LR-S4TQ"))
m = CStr(App.EXEName)
x = "本程序的名字(Appname)=" & CStr(m) & "/硬件识别码(mid)=" & CStr(n)
MsgBox x
End Sub
本程序要调用一个dll(就是GetHardwareID.dll),我在本机里用VB 6.0调试可以用,但是我生成exer了就报错发生故障。实在不得其解。望各路神仙指点迷经。鄙人先谢过。 展开
3个回答
展开全部
你程序开头的两个API函数声明(就是涉及HardwareID.DLL的那两个)要求HardwareID.DLL已经注册才行,否则就出错。而你程序中的Shell "regsvr32 /s HardwareID.dll"已经是马后炮了!换句话说就是API函数的声明是先于程序代码运行的。
你必须把你的exe文件和dll文件打包生成setup安装程序,在安装过程中对dll文件进行注册才行。或者你用其他方法也行,只要保证dll的注册是先于程序的运行的。
你必须把你的exe文件和dll文件打包生成setup安装程序,在安装过程中对dll文件进行注册才行。或者你用其他方法也行,只要保证dll的注册是先于程序的运行的。
展开全部
GetHardwareID.dll插件放exe程序旁边就行,注册那句命令,可以去掉
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
重新注册下SkinH_VB6.dll,或将其放入system32 regsvr32 /s DLL路径
希望能解决您的问题。
希望能解决您的问题。
追问
不行的。要不369352029 + 我,帮我下好吗
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询