Prueba asi:
msginfo( CChex_Update( Anviz_handle, iDx, tipo, aDatos, nLen ) )
int CChex_Update(IntPtr CchexHandle, int[] DevIdx, int[] Type, IntPtr Buff, int Len)
int ret = 0;
int[] Type = new int[1];
int[] dev_idx = new int[1];
IntPtr pBuff;
int len = 32000;
pBuff = Marshal.AllocHGlobal(len);
CChex_Update(anviz_handle, dev_idx, Type, pBuff, len);
HB_FUNC( CCHEX_UPDATE )
{
int DevIdx = hb_parni( 2 );
int Type = hb_parni( 3 );
hb_retnl( CChex_Update( ( void * ) hb_parnl( 1 ), &DevIdx, &Type, ( char * ) hb_parc( 4 ), hb_parni( 5 ) ) );
}
{
AnvizNew.CCHEX_RET_RECORD_INFO_STRU_CARD_ID_LEN_7 record_info;
record_info = (AnvizNew.CCHEX_RET_RECORD_INFO_STRU_CARD_ID_LEN_7)Marshal.PtrToStructure(pBuff, typeof(AnvizNew.CCHEX_RET_RECORD_INFO_STRU_CARD_ID_LEN_7));
DateTime date = new DateTime(2000, 1, 2).AddSeconds(swapInt32(BitConverter.ToUInt32(record_info.Date, 0)));
string dateStr = date.ToString("yyyy-MM-dd HH:mm:ss");
string info_buff = "Record Info ----[ Mid:" + record_info.MachineId
+ " Date:" + dateStr
+ "PersonID: " + CardId_array_to_string(record_info.CardId)
+ " RecType:" + record_info.RecordType.ToString()
+ " ]" + "(" + record_info.CurIdx.ToString() + "/" + record_info.TotalCnt.ToString() + ")";
log_add_string(info_buff);
}
vRet:=CChex_DownloadAllRecords(Anviz_handle,1)
syswait(2)
vCual:=0
do while .t.
aDatos:=space(32000)
nLen:=len(aDatos)
vRet:=(CChex_Update(Anviz_handle,iDx,tipo,aDatos,32000))
syswait(2)
if vRet > 0
vCual++
nomf = "Fichero"+strzero(vCual,3)+".txt"
handle = fcreate(nomf)
for x=1 to len(aDatos)
fwrite(handle,substr(aDatos,x,1),1)
next x
fclose(handle)
else
exit
end if
end do
public struct CCHEX_RET_RECORD_INFO_STRU_CARD_ID_LEN_7
{
public uint MachineId; //机器号
public byte NewRecordFlag; //是否是新记录
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 7)]
public byte[] CardId; //
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] Date; //日期时间
public byte BackId; //备份号
public byte RecordType; //记录类型
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 3)]
public byte[] WorkType; //工种 (ONLY use 3bytes )
public byte Rsv;
public uint CurIdx; //add VER 22
public uint TotalCnt; //add VER 22
}
#include "FiveWin.ch"
function Main()
local aInfo := StructToArray( hb_memoRead( "Fichero001.txt" ) )
MsgInfo( StructLen(), "CardId struct length" )
MsgInfo( aInfo[ 1 ], "MachineId" )
MsgInfo( aInfo[ 2 ], "NewRecordFlag" )
MsgInfo( hb_hexToNum( hb_strToHex( aInfo[ 3 ] ) ), "CardId" )
MsgInfo( hb_strToHex( aInfo[ 4 ] ), "Date" )
MsgInfo( aInfo[ 5 ], "BackId" )
MsgInfo( aInfo[ 6 ], "RecordType" )
MsgInfo( hb_hexToNum( hb_strToHex( aInfo[ 7 ] ) ), "WorkType" )
MsgInfo( aInfo[ 8 ], "Rsv" )
MsgInfo( aInfo[ 9 ], "CurIdx" )
MsgInfo( aInfo[ 10 ], "TotalCnt" )
return nil
#pragma BEGINDUMP
#include <hbapi.h>
typedef struct CCHEX_RET_RECORD_INFO_STRU_CARD_ID_LEN_7
{
unsigned int MachineId;
unsigned char NewRecordFlag;
unsigned char CardId[ 7 ]; // ademas en el nombre de la estructura se especifica CARD_ID_LEN_7
unsigned char Date[ 4 ];
unsigned char BackId;
unsigned char RecordType;
unsigned char WorkType[ 3 ];
unsigned char Rsv;
unsigned int CurIdx;
unsigned int TotalCnt;
} CARDINFO;
HB_FUNC( STRUCTLEN )
{
hb_retnl( sizeof( CARDINFO ) );
}
HB_FUNC( STRUCTTOARRAY )
{
CARDINFO * data = ( CARDINFO * ) hb_parc( 1 );
hb_reta( 10 );
hb_storvni( data->MachineId, -1, 1 );
hb_storvni( data->NewRecordFlag, -1, 2 );
hb_storvclen( ( const char * ) data->CardId, 7, -1, 3 );
hb_storvclen( ( const char * ) data->Date, 4, -1, 4 );
hb_storvni( data->BackId, -1, 5 );
hb_storvni( data->RecordType, -1, 6 );
hb_storvclen( ( const char * ) data->WorkType, 3, -1, 7 );
hb_storvni( data->Rsv, -1, 8 );
hb_storvni( data->CurIdx, -1, 9 );
hb_storvni( data->TotalCnt, -1, 10 );
}
#pragma ENDDUMP
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 67 guests