Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open BTRieve in code with Owner

Status
Not open for further replies.

Shaga

Programmer
Apr 1, 2003
11
0
0
GB
I need to open a BTRieve file which has the OWNER set in C#. I know what the owner is I would like to know what to pass through in the 3rd param for the Open (0) operation. At present I pass through an IntPtr.Zero.
 
For the record I have solved it thus:

Create a structure in which to store the Owner Name:

[StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Ansi, Size=8)]
public struct BTR_OWNER_NAME
{
public string OwenerName;
}

//Declare a struct var:

BTR_OWNER_NAME ownerBuf;

//Assign the constant in which the Owner Name is held (this contains 6 chars):

ownerBuf.OwenerName = OWNER_NAME;

//Pass the length of the Owner Name +1 for the trailing Binary 0 into var:

dataLen = 7;

// move our owner structure into unmanaged memory block
dataBuffer = Marshal.StringToHGlobalAnsi(ownerBuf.OwenerName);

// and finally issue OPEN (0) operation to Btrieve with the dataBuffer containg the Owner Name:

try
{
bStat = BtrCall.BTRCALL( (ushort)BTROPS.B_OPEN, posBlock, dataBuffer, ref dataLen, keyBuffer, keyLen, keyNum );
}
catch( Exception e )

bStat has been assigned 0, so all is fine and the Btrieve file which has an Owner Name set with access level 0 is now open.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top