Link to home
Start Free TrialLog in
Avatar of natan1107
natan1107

asked on

RAPI - CeOpenDatabase,CeReadRecordProps,CeCreateDatabase - DllImport with C#

Hello,

Can someone show me how can i import thoose functions (DataBase functions) with DllImport in C#

Thank You.
Avatar of Mikal613
Mikal613
Flag of United States of America image

public const short FILE_ATTRIBUTE_NORMAL = 0x80;public const short INVALID_HANDLE_VALUE = -1;public const uint GENERIC_READ = 0x80000000;public const uint GENERIC_WRITE = 0x40000000;public const short CREATE_NEW = 1;public const short CREATE_ALWAYS = 2;public const short OPEN_EXISTING = 3;public const short ERROR_FILE_EXISTS = 80;public const short ERROR_INVALID_PARAMETER = 87;public const short ERROR_DISK_FULL = 112;[StructLayout(LayoutKind.Sequential)]public struct OSVERSIONINFO{public int dwOSVersionInfoSize;public int dwMajorVersion;public int dwMinorVersion;public int dwBuildNumber;public int dwPlatformId;[MarshalAs(UnmanagedType.ByValTStr,SizeConst= 128)]public string szCSDVersion;}[StructLayout(LayoutKind.Sequential)]public struct RAPIINIT{int cbSize;int heRapiInit;int hrRapiInit;}[StructLayout(LayoutKind.Sequential)]public struct SECURITY_ATTRIBUTES{public int nLength;public int lpSecurityDescriptor;public int bInheritHandle;}[DllImport("rapi.dll", CharSet=CharSet.Unicode)]public static extern int CeCloseHandle(int hObject);[DllImport("rapi.dll", CharSet=CharSet.Unicode)]public static extern int CeCreateFile(string lpFileName,uint dwDesiredAccess,int dwShareMode,int lpSecurityAttributes,intdwCreationDisposition,int dwFlagsAndAttributes,int hTemplateFile);[DllImport("rapi.dll", CharSet=CharSet.Unicode)]public static extern int CeRapiInitEx ([MarshalAs(UnmanagedType.Struct)] ref RAPIINIT pRapiInit);[DllImport("rapi.dll", CharSet=CharSet.Unicode)]public static extern int CeRapiInit ();[DllImport("rapi.dll", CharSet=CharSet.Unicode)]public static extern int CeRapiUninit ();[DllImport("rapi.dll", CharSet=CharSet.Unicode)]public static extern int CeReadFile(int hFile,StringBuilder lpBuffer,int nNumberOfbytesToRead, out int lpNumberOfbytesRead, int lpOverlapped);[DllImport("rapi.dll", CharSet=CharSet.Unicode)]public static extern int CeWriteFile(int hFile,StringBuilder lpBuffer, int nNumberOfbytesToWrite, out int lpNumberOfbytesWritten, int lpOverlapped);[DllImport("rapi.dll", CharSet=CharSet.Unicode)]public static extern int GetLastError();[DllImport("rapi.dll", CharSet=CharSet.Unicode)]public static extern int CeSetEndOfFile(int hFile);[DllImport("rapi.dll", CharSet=CharSet.Unicode)]public static extern int CeGetFileSize(int hFile,int lpFileSizeHigh);[DllImport("rapi.dll", CharSet=CharSet.Unicode)]public static extern int CeGetLastError();
Avatar of natan1107
natan1107

ASKER

all DllImport are ok, but there is no fuction that know to open a database !
I need the flowing funcitons:
CeOpenDatabase,CeReadRecordProps,CeCreateDatabase.
 I need to call them by C#,
I know that I can do it with C++
Thank You
ASKER CERTIFIED SOLUTION
Avatar of Mikal613
Mikal613
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial