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

Posted on 2004-11-16
Last Modified: 2013-11-18

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

Thank You.
Question by:natan1107
    LVL 48

    Expert Comment

    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();
    LVL 48

    Expert Comment


    Author Comment

    all DllImport are ok, but there is no fuction that know to open a database !
    I need the flowing funcitons:
     I need to call them by C#,
    I know that I can do it with C++
    Thank You
    LVL 48

    Accepted Solution

    [DllImport("rapi.dll", CharSet=CharSet.Unicode)]
    Public static extern CeOpenDatabase(  PCEOID poid,LPWSTR lpszName,CEPROPID propid,DWORD dwFlags,HWND hwndNotify);

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Android App Development

    This course will involve creating widgets, customize list view, grid view, spinners, etc. Creating applications using audio, video, and SQLite database. Ending with publication on Google Play.

    Suggested Solutions

    As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, ( because one time I did this and I essentially had a bricked …
    A short article about problems I had with the new location API and permissions in Marshmallow
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now