T
Tiger_Dxj
Unregistered / Unconfirmed
GUEST, unregistred user!
DLL调用VB,VC都实现了,为什么Delphi就不行了????
这是我的delphi程序,调用InitializeWinIo就可以,调用GetPortVal就出错,说
'Access Violation at address 1000143c in WinIo.dll. Write of address 0000000'
请问为什么,我的程序有问题吗?
implementation
Function InitializeWinIo() : Bool;Cdecl;external 'WinIo.Dll'
Function GetPortVal(wPortAddr:WORD; pdwPortValDWord; bSize:BYTE) : Bool;Cdecl;external 'WinIo.Dll'
Function ShutdownWinIo() : Bool;Cdecl;external 'WinIo.Dll'
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
Var
AA : PDWord;
begin
if InitializeWinIo() Then
Begin
AA := Nil;
ShowMessage('Init Success!');
if GetPortVal($500,AA,1) Then
ShowMessage('ReadOk')
Else
ShowMessage('ReadError');
End;
if ShutdownWinIo() Then
ShowMessage('CloseOk')
Else
ShowMessage('CloseError');
end;
这是VB的程序
Private Sub BtnGet_Click()
Dim Result As Boolean
Dim PortVal As Long
Result = GetPortVal(Val("&H" + TxtPortAddr), PortVal, 1)
If (Result = False) Then
MsgBox "Whoops ! There is a problem with GetPortByte.", vbOKOnly + vbCritical, "VBDumpPort32"
Unload FrmVBDumpPort32
Else
TxtPortByte = Hex$(PortVal And &HFF)
End If
End Sub
Private Sub BtnQuit_Click()
Unload FrmVBDumpPort32
End Sub
Private Sub BtnSet_Click()
Dim Result As Boolean
Result = SetPortVal(Val("&H" + TxtPortAddr), Val("&H" + TxtPortByte), 1)
If (Result = False) Then
MsgBox "Whoops ! There is a problem with SetPortByte.", vbOKOnly + vbCritical, "VBDumpPort32"
Unload FrmVBDumpPort32
End If
End Sub
这是我的delphi程序,调用InitializeWinIo就可以,调用GetPortVal就出错,说
'Access Violation at address 1000143c in WinIo.dll. Write of address 0000000'
请问为什么,我的程序有问题吗?
implementation
Function InitializeWinIo() : Bool;Cdecl;external 'WinIo.Dll'
Function GetPortVal(wPortAddr:WORD; pdwPortValDWord; bSize:BYTE) : Bool;Cdecl;external 'WinIo.Dll'
Function ShutdownWinIo() : Bool;Cdecl;external 'WinIo.Dll'
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
Var
AA : PDWord;
begin
if InitializeWinIo() Then
Begin
AA := Nil;
ShowMessage('Init Success!');
if GetPortVal($500,AA,1) Then
ShowMessage('ReadOk')
Else
ShowMessage('ReadError');
End;
if ShutdownWinIo() Then
ShowMessage('CloseOk')
Else
ShowMessage('CloseError');
end;
这是VB的程序
Private Sub BtnGet_Click()
Dim Result As Boolean
Dim PortVal As Long
Result = GetPortVal(Val("&H" + TxtPortAddr), PortVal, 1)
If (Result = False) Then
MsgBox "Whoops ! There is a problem with GetPortByte.", vbOKOnly + vbCritical, "VBDumpPort32"
Unload FrmVBDumpPort32
Else
TxtPortByte = Hex$(PortVal And &HFF)
End If
End Sub
Private Sub BtnQuit_Click()
Unload FrmVBDumpPort32
End Sub
Private Sub BtnSet_Click()
Dim Result As Boolean
Result = SetPortVal(Val("&H" + TxtPortAddr), Val("&H" + TxtPortByte), 1)
If (Result = False) Then
MsgBox "Whoops ! There is a problem with SetPortByte.", vbOKOnly + vbCritical, "VBDumpPort32"
Unload FrmVBDumpPort32
End If
End Sub