Hello all. I am consuming WBTRV32.dll in C# with only one external call. The call is defined like so:
To collect a record, I am making the following two calls:
In the old C++ code, the struct for this record looks like this:
The Data Buffer for my calls, as I show above, is an object called RecordBuffer, which looks like this:
In a command line, when I call butil -recover users.btr userRecover.txt, I get the following:
265,[SOH][NUL]TEST1, USERNAME1 [NUL]1234 TEST AVE, CITY BLAH BLAH . . . . . . . . . . . . .
265,[STX][NUL]TEST2, USERNAME2 [NUL]1234 TEST AVE, CITY BLAH BLAH . . . . . . . . . . . . .
265,[ETX][NUL]TEST3, USERNAME3 [NUL]1234 TEST AVE, CITY BLAH BLAH . . . . . . . . . . . . .
And if I call this in the command line: butil -stat users.btr, I am told:
I am near certain that the first two bytes (e.g.: [ETX][NUL]) is the RecordNo, while the next 21 (null-terminated) is the UserName, etc. It aligns with my struct perfectly.
But when I run my application, my dataBuffer comes back with a "RecordBuffer" which has a DocDescPlural value like so:
The entire record for the GetFirst, and subsequent GetNext calls comes back, EXCEPT For the RecordNo. The first two bytes are skipped for some reason. I've tried this with multiple tables and all of the tables return the records exactly as expected, Sans the AutoInc Key.
Code:
[DllImport("WBTRV32.dll", CharSet = CharSet.Ansi)]
internal static extern short BTRCALL(
ushort operation,
[MarshalAs(UnmanagedType.LPArray, SizeConst = 128)] byte[] posBlk,
[MarshalAs(UnmanagedType.Struct, SizeConst = 255)] ref RecordBuffer databuffer,
ref int dataLength,
[MarshalAs(UnmanagedType.LPArray, SizeConst = 255)] char[] keyBffer,
ushort keyLength,
ushort keyNum);
To collect a record, I am making the following two calls:
Code:
byte[] positionBlock = new byte[128];
var dataBuffer = new RecordBuffer();
int bufferLength = Marshal.SizeOf(dataBuffer);
var status = BTRCALL((ushort)BtrvOperation.Open, positionBlock, ref dataBuffer, ref bufferLength, _fileNameArray, 0, 0); // BtrvOperation.Open == 0
if (status == 0) {
status = BTRCALL((ushort)BtrvOperation.GetFirst, positionBlock, ref dataBuffer, ref bufferLength, _fileNameArray, 0, 0); // BtrvOperation.GetFirst == 12
}
In the old C++ code, the struct for this record looks like this:
Code:
struct myRecord {
int RecordNo;
char UserName[21];
char Address[51];
. . . .
};
The Data Buffer for my calls, as I show above, is an object called RecordBuffer, which looks like this:
Code:
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
public struct RecordBuffer
{
public short DocType;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2500)] public char[] DocDescPlural;
public short Sorting;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2500)] public char[] DocDescSingle;
public short CopyOtherThanSrc;
public double DefaultNotebookNo;
}
In a command line, when I call butil -recover users.btr userRecover.txt, I get the following:
265,[SOH][NUL]TEST1, USERNAME1 [NUL]1234 TEST AVE, CITY BLAH BLAH . . . . . . . . . . . . .
265,[STX][NUL]TEST2, USERNAME2 [NUL]1234 TEST AVE, CITY BLAH BLAH . . . . . . . . . . . . .
265,[ETX][NUL]TEST3, USERNAME3 [NUL]1234 TEST AVE, CITY BLAH BLAH . . . . . . . . . . . . .
And if I call this in the command line: butil -stat users.btr, I am told:
Code:
File Version = 9.50
Page Size = 2048
Page Preallocation = No
Key Only = No
Extended = No
Total Number of Records = 1190
Record Length = 265
Record Compression = No
Page Compression = No
Variable Records = No
Available Linked Duplicate Keys = 0
Balanced Key = No
Log Key = 0
System Data = No
Total Number of Keys = 7
Total Number of Segments = 8
Key Position Type Null Values* ACS
Segment Length Flags Unique Values
0 1 1 2 AutoInc M -- 1190 --
1 1 3 20 String MD -- 1139 --
2 1 . . . . . etc etc
I am near certain that the first two bytes (e.g.: [ETX][NUL]) is the RecordNo, while the next 21 (null-terminated) is the UserName, etc. It aligns with my struct perfectly.
But when I run my application, my dataBuffer comes back with a "RecordBuffer" which has a DocDescPlural value like so:
Code:
[0]: 84 'T'
[1]: 69 'E'
[2]: 83 'S'
[3]: 84 'T'
. . . . . .
The entire record for the GetFirst, and subsequent GetNext calls comes back, EXCEPT For the RecordNo. The first two bytes are skipped for some reason. I've tried this with multiple tables and all of the tables return the records exactly as expected, Sans the AutoInc Key.