|
分類:[VB.NET/VB2005 以降]
お世話になっております。ソフト技術者様のアドバイスを お願い致します。どうかお助け下さい。
言語:VB2008(Pro) OS:Win−XP(Pro)
メーカ様のDLLを使用してVB2008でプログラムを作成しているのですが、どうしても戻り値(文字型のデータは戻ってきますが、整数型のデータは0のままです。)が戻ってきません。 海外の機器メーカーに問い合わせても連絡は有りません。
このGetCardRecord2を使用して、メーカー機器にカード番号情報を送ると既に登録されている該当データが戻り値として返ってくる関数です。
C言語のサンプルプログラムを参考にVB2008に置き換えたのですが無理でした。 いろいろとHP等を参考にして制作したのですが、お手上げ状態です。
ヘッダファイルです。
VEXPORT int CALLBACK GetCardRecord2(char *macAddress,int *cardSetID,int *noFormat, char *cardNumber,int cardNumberSize, char *pin,int pinSize,int *accessType, unsigned int *uniqueID,int *accessGroup1, int *accessGroup2,int *accessGroup3, int *accessGroup4,int *accessGroup5, int *accessGroup6,int *accessGroup7, int *accessGroup8,int *extendedAccess, int *passbackExempt,int *pinCmds, char *startDate,int startDateSize, char *startTime,int startTimeSize, char *endDate,int endDateSize, char *endTime,int endTimeSize, unsigned int *escortID, int *inScheduleElevatorGroup, int *outScheduleElevatorGroup, int *deleted,int *pinExempt);
C言語のサンプルプログラム
[DllImport("VertX.DLL")] public static extern int GetCardRecord2(string macAddr, ref int cardSetID, ref int noFormat, System.Text.StringBuilder cardNumber, int cardNumberSize, System.Text.StringBuilder pin, int pinSize, ref int accessType, ref uint uniqueID, ref int accessGroup1, ref int accessGroup2, ref int accessGroup3, ref int accessGroup4, ref int accessGroup5, ref int accessGroup6, ref int accessGroup7, ref int accessGroup8, ref int extendedAccess, ref int passbackExempt, ref int pinCmds, System.Text.StringBuilder startDate, int startDateSize, System.Text.StringBuilder startTime, int startTimeSize, System.Text.StringBuilder endDate, int endDateSize, System.Text.StringBuilder endTime, int endTimeSize, ref uint escortID, ref int inElevGroup, ref int outElevGroup, ref int deleted, ref int pinExempt);
int ident; int result; string macAddr; int cardset; int nofmt; string noFmt; System.Text.StringBuilder cardNumber; System.Text.StringBuilder pin; int accessType = 0; uint unique = 0; int level1 = 0; int level2 = 0; int level3 = 0; int level4 = 0; int level5 = 0; int level6 = 0; int level7 = 0; int level8 = 0; int extended = 0; int passback = 0; int pincmd = 0; System.Text.StringBuilder startDate; System.Text.StringBuilder startTime; System.Text.StringBuilder endDate; System.Text.StringBuilder endTime; uint escort = 0; int inelev = 0; int outelev = 0; int deleted = 0; int pinexempt = 0;
result = GetCardRecord2(macAddr,ref cardset,ref nofmt,cardNumber,ARRLEN, pin,ARRLEN,ref accessType,ref unique,ref level1,ref level2,ref level3, ref level4,ref level5,ref level6,ref level7,ref level8,ref extended, ref passback,ref pincmd,startDate,ARRLEN,startTime,ARRLEN, endDate,ARRLEN,endTime,ARRLEN,ref escort,ref inelev,ref outelev,ref deleted,ref pinexempt ); if (result == 0)
textBoxCRUniqueID.Text = unique.ToString();
上記のプログラムでは、uniqueの変数には(戻り値:20386)データは返ってきています。
下記がサンプルプログラムをVBに変更して作成したプログラムです。
<DllImport("VertX.DLL")> _ Public Shared Function GetCardRecord2(ByVal macAddr As String, ByRef cardSetID As Integer, ByRef noFormat As Integer, ByVal cardNumber As StringBuilder, ByVal cardNumberSize As Integer, ByVal pin As StringBuilder, ByVal pinSize As Integer, ByRef accessType As Integer, <MarshalAs(UnmanagedType.U4)> ByRef uniqueID As UInteger, ByRef accessGroup1 As Integer, ByRef accessGroup2 As UInteger, ByRef accessGroup3 As Integer, ByRef accessGroup4 As Integer, ByRef accessGroup5 As Integer, ByRef accessGroup6 As Integer, ByRef accessGroup7 As Integer, ByRef accessGroup8 As Integer, ByRef extendedAccess As Integer, ByRef passbackExempt As Integer, ByRef pinCmds As Integer, ByVal startDate As StringBuilder, ByVal startDateSize As Integer, ByVal startTime As StringBuilder, ByVal startTimeSize As Integer, ByVal endDate As StringBuilder, ByVal endDateSize As Integer, ByVal endTime As StringBuilder, ByVal endTimeSize As Integer, ByRef escortID As UInt32, ByRef inElevGroup As Integer, ByRef outElevGroup As Integer, ByRef deleted As Integer, ByRef pinExempt As Integer) As Integer End Function
Dim accessType As Integer = 0 Dim unique As UInteger = 0 Dim level1 As Integer = 0 Dim level2 As Integer = 0 Dim level3 As Integer = 0 Dim level4 As Integer = 0 Dim level5 As Integer = 0 Dim level6 As Integer = 0 Dim level7 As Integer = 0 Dim level8 As Integer = 0 Dim extended As Integer = 0 Dim passback As Integer = 0 Dim pincmd As Integer = 0 Dim escort As UInt32 = 0 Dim inelev As Integer = 0 Dim outelev As Integer = 0 Dim deleted As Integer = 0 Dim pinexempt As Integer = 0 Dim result As Integer Dim cardset As Integer Dim nofmt As Integer = 1
Dim startDate As New StringBuilder(200) Dim startTime As New StringBuilder(200) Dim endDate As New StringBuilder(200) Dim endTime As New StringBuilder(200)
result = GetCardRecord2(vertx_macaddress(ii), (cardset), (nofmt), cardno, 200, pincode, 200, (accessType), (unique), (level1), (level2), (level3), (level4), (level5), (level6), (level7), (level8), (extended), (passback), (pincmd), startDate, 200, startTime, 200, endDate, 200, endTime, 200, (escort), (inelev), (outelev), (deleted), (pinexempt))
resultの変数は0で返ってきます。この0は成功の意味ですが、成功したにも関わらず、(unique)の戻り値は0です。 また、startDate、startTime、endDate、endTimeには機器に登録されているデータ値が返ってきております。
何が悪いのでしょうか? お助け下さい。(2週間悩んでおります。)
構造体、マーシャリング等うを使用して作成は可能なんでしょうか?
|