简体   繁体   English

在 C# 代码中使用 W3BTRV7.DLL BTrieve

[英]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.我正在寻找一个简短的示例,以在 C# 代码中使用 W3BTRV7.DLL 直接访问 BTrieve 6.15 文件。

Thanks for any sugestions感谢您的任何建议

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)
        {
         .....
         }
   }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM