Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

cerapiinvoke (rapi)
 

rapi is for smart devices, not desktop Windows. Therefore, this information only applies to code using the .NET Compact Framework. To see if information for cerapiinvoke in other DLLs exists, click on Find References to the right.

.
Summary
Call custom function contained in DLL on Windows CE Device via the RAPI.

C# Signature:

[DllImport("rapi.dll", CharSet = CharSet.Unicode, SetLastError = true)]

internal extern static int CeRapiInvoke(

   string pDllPath,
   string pFunctionName,
   uint cbInput,
   IntPtr pInput,
   out uint pcbOutput,
   out IntPtr ppOutput,
   IntPtr ppIRAPIStream,
   uint dwReserved);

User-Defined Types:

None.

Notes:

sDllPath must be in the MSDOS 8.3 filename format. Any other format that results in a larger filename will

fail. You can use this to access records in databases on the Windows CE Device. Therefore, no platform

invoke for the CeDatabase functions are needed.

Sample Code: [C#]

string sDllPath = @"\dbaccess.dll";

string sFunction = @"MyFunction";

int hResult = CeRapiInvoke(sDllPath, sFunction, 0, IntPtr.Zero, out uiOutput, out pOutput, IntPtr.Zero, 0);

if ( hResult != 0 )

{

   // Execution Failed

}

unsafe

{

   retOutput = new string((char*)pOutput.ToPointer());

}

Sample DLL: [C++]

[dbaccess.h]

#ifndef DBACCESS_H

#define DBACCESS_H

#ifndef RAPISTREAMFLAG

typedef enum tagRAPISTREAMFLAG

{

    STREAM_TIMEOUT_READ

} RAPISTREAMFLAG;

DECLARE_INTERFACE_ (IRAPIStream, IStream )

{

    STDMETHOD(SetRapiStat)(THIS_ RAPISTREAMFLAG Flag, DWORD dwValue) PURE;
    STDMETHOD(GetRapiStat)(THIS_ RAPISTREAMFLAG Flag, DWORD *pdwValue) PURE;

};

#endif

#ifdef __cplusplus

extern "C"{

#endif

__declspec (dllexport) INT MyFunction( DWORD, BYTE*, DWORD*, BYTE*, IRAPIStream *, PVOID );

#ifdef __cplusplus

}

#endif

#endif

[dbaccess.cpp]

#include "dbaccess.h"

#define MAXSTRINGLENGTH 1024

BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)

{

    return TRUE;

}

INT MyFunction( DWORD cbInput, BYTE pInput, DWORD pcbOutput, BYTE *ppOutput, IRAPIStream *pStream, PVOID reserved )

{

    LPTSTR outBuffer;

    outBuffer = (LPTSTR) LocalAlloc( LPTR, sizeof(TCHAR) * MAXSTRINGLENGTH );

    wsprintf( outBuffer, _T("This is just a Test!") );

pcbOutput = sizeof(TCHAR) MAXSTRINGLENGTH;

  • ppOutput = (PBYTE) outBuffer;

    LocalFree( pInput );
    return 0;

}

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions