Manfred Jehle
Manfred Jehle

Reputation: 1

use W3BTRV7.DLL BTrieve in c# code

I'm looking for a short sample to Access directly to BTrieve 6.15 Files using W3BTRV7.DLL in c# code.

Thanks for any sugestions

Upvotes: -4

Views: 952

Answers (1)

user5514770
user5514770

Reputation: 59

Here a sample:

[System.Runtime.InteropServices.DllImport("WBTRV32.dll", CharSet = System.Runtime.InteropServices.CharSet.Ansi)]
    static extern short BTRCALL(ushort operation,
    [System.Runtime.InteropServices.MarshalAs  (System.Runtime.InteropServices.UnmanagedType.LPArray, SizeConst = 128)] byte[] posBlk,
    [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Struct, SizeConst = 255)]
    ref RecordBuffer databuffer,
    ref int dataLength,
    [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPArray, SizeConst = 255)] char[] keyBffer,
    ushort keyLength, ushort keyNum);

[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 1, CharSet = System.Runtime.InteropServices.CharSet.Ansi)]
    public struct RecordBuffer
    {
        public short docType;
        [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 2500)]
        public char[] docDescPlural;
        public short sorting;
        [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 2500)]
        public char[] docDescSingle;
        public short copyOtherThanSrc;
        public double defaultNotebookNo;
    }

private void PopulateAllRecords(string fileName)
    {
        byte[] positionBlock = new byte[128];
        char[] fileNameArray = fileName.ToCharArray();

        // Open file
        RecordBuffer dataBuffer = new RecordBuffer();
        int bufferLength = System.Runtime.InteropServices.Marshal.SizeOf(dataBuffer);
        short status = (short)BTRCALL((ushort)OPCODE.BOPEN, positionBlock, ref dataBuffer, ref bufferLength, fileNameArray, 0, 0);

        if (status == 0)
        {
         .....
         }
   }

Upvotes: 2

Related Questions