Private Type Smc_Event
called As String
length As Integer
data As String
End Type
Private Declare Function receiveshortmessage Lib "smcdll.dll" () As Smc_EventPrivate Sub Command2_Click() Dim smcevent As Smc_Event
smcevent = receiveshortmessage()
Text3.Text = smcevent.called
Text4.Text = smcevent.data
c = smcevent.length
Text1 = cEnd Sub为什么老是提示“DLL调用约定错误”
called As String
length As Integer
data As String
End Type
Private Declare Function receiveshortmessage Lib "smcdll.dll" () As Smc_EventPrivate Sub Command2_Click() Dim smcevent As Smc_Event
smcevent = receiveshortmessage()
Text3.Text = smcevent.called
Text4.Text = smcevent.data
c = smcevent.length
Text1 = cEnd Sub为什么老是提示“DLL调用约定错误”
传送给动态链接库 (DLL)的参数必须符合例程的需要。调用约定要检查个数、类型、参数的顺序等。此错误有以下的原因和解决方法: 程序调用被传递了错误的参数类型的 DLL中的例程时。
确保所有的参数的类型和调用的例程中指定的声明符合。程序调用被传递了错误的参数数目的 DLL中的例程时。
请确保参数数目和所调用的例程的声明符合。程序调用 DLL 的例程,但没有使用 StdCall 调用约定。
如果 DLL 例程需要的是按值参数,那么请在例程的声明中确保这些参数是以 ByVal 进行了声明。对于Windows DLL的Declare 语句包括了 CDecl。 来源于:mk:@MSITStore:C:\Program%20Files\Microsoft%20Visual%20Studio\MSDN98\98VS\2052\vbenlr98.chm::/HTML/vamsgdllbadcallingconv.htm
Private Type Smc_Event
called As String
length As Integer
data As String
End TypeString 类型其实是一个 4字节的指针而已,应该要确定 字符的长度
譬如这样定义:
Private Type Smc_Event
called As String * 20 '20个字符空间
length As Integer
data As String * 20 '20个字符空间
End Type
怎么是这种形式呢?很难理解Private Declare Function receiveshortmessage Lib "smcdll.dll" (byval Smc As Smc_Event) As long
这样,才可以进行参数值啊。