こんにちは。
昨日よりVB2008を勉強中です。
WndProc を使用しての Hamlogよりのデータ取得は出来る様になりました。
次にHDBに直接アクセスするテストをしていますが入り口でつまずいています。
下記のコードで ver = GetThdllVersion() に関してはVB6と同じ値が取れました。
C:\Windows\System32\Hamlog.dll
タイムスタンプ 値
2008-06-19 331776
2009-05-23 332544
しかしレコード件数の取得がダメです。
sd = dbf_open("C:\HAMLOG\Hamlog.hdb", Th)
recno = dbf_rcount(Th)
...では ゼロ件と表示されます。
sd = Vdbf_open("C:\HAMLOG\Hamlog.hdb", log)
recno = Vdbf_rcount(log)
...ではマイナスになったり極端に大きな数値になったりでダメです。
どなたか上手く動作しておられたらご指導お願いします。
(図表モードでもインデントが取れなくて見難いですね)
Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Public Class Form1
Structure TDBFh
<VBFixedArray(4)> Dim lupdt() As Byte
Dim Rcount As Integer
Dim hsize As Integer
Dim recnm As Integer
Dim fHdl As Integer
<VBFixedArray(260)> Dim Temp() As Byte
Public Sub Initialize()
ReDim lupdt(4)
ReDim Temp(260)
End Sub
End Structure
Structure TThLog
<VBFixedArray(3927)> Dim Qso() As Byte
Public Sub Initialize()
ReDim Qso(3927)
End Sub
End Structure
<DllImport("Hamlog50.dll")> _
Private Shared Function GetThdllVersion() As Integer
End Function
<DllImport("Hamlog50.dll")> _
Private Shared Function dbf_open(ByRef s As String, ByRef d As TDBFh) As Integer 'ByValをByRefに変更
End Function
<DllImport("Hamlog50.dll")> _
Private Shared Sub dbf_close(ByRef d As TDBFh)
End Sub
<DllImport("Hamlog50.dll")> _
Private Shared Function dbf_rcount(ByRef d As TDBFh) As Integer
End Function
<DllImport("Thdll2Vb.dll")> _
Private Shared Function Vdbf_open(ByRef s As String, ByRef d As TThLog) As Integer
End Function
<DllImport("Thdll2Vb.dll")> _
Private Shared Sub Vdbf_close(ByRef d As TThLog)
End Sub
<DllImport("Thdll2Vb.dll")> _
Private Shared Function Vdbf_rcount(ByRef d As TThLog) As Integer
End Function
Public log As TThLog
Public Th As TDBFh
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ver As Int32
Dim sd As Int32
Dim recno As Int32
ver = GetThdllVersion()
Label1.Text = ver
'dbf_close(Th)
'sd = dbf_open("C:\HAMLOG\Hamlog.hdb", Th)
'recno = dbf_rcount(Th)
'dbf_close(Th)
sd = Vdbf_open("C:\HAMLOG\Hamlog.hdb", log)
recno = Vdbf_rcount(log)
Vdbf_close(log)
Label2.Text = recno
End Sub
End Class