[Lazarus] Reading files in a Windows Mobile device.

Sven Barth pascaldragon at googlemail.com
Fri Nov 11 13:15:21 CET 2011


Am 10.11.2011 23:57, schrieb Zaher Dirkey:
>     In fact I have no idea of how to use RAPI.DLL(if it is the only way)
>     in Lazarus since Lazarus is a pascal environment and RAPI.DLL tun in
>     .NET Framework. Additionally I souppose that RAPI.DLL was write in C
>     or C++.

The RAPI DLL is a C DLL and for C DLLs you simply need to import the 
functions correctly, so that you can use it (see the example by Zaher). 
Otherwise you wouldn't be able to interface with other Windows DLLs like 
kernel32 as well. ;)

>
>
> I am not tested it yet, RAPI have functions on PC similar to the
> original functions, you can open and read files over ActiveSync from PC
> to WINCE

At work we are using RAPI (with Free Pascal) extensively to copy a 
SQLite database from and to the device. I'm also using a little "cp" 
like tool to copy the freshly compiled program directly onto the device 
after compilation :)

>
> You need to cal the CeRapiInit once before use this functions
>
>    function CeCloseHandle(hObject: THandle): bool; stdcall external
> 'rapi.dll';
>    function CeCreateFile(lpFileName: LPCWSTR; dwDesiredAccess: dword;
> dwShareMode: dword; lpSecurityAttributes: PSecurityAttributes;
> dwCreationDistribution: dword; dwFlagsAndAttributes: dword;
> hTemplateFile: THandle): THandle; stdcall external 'rapi.dll';
>    function CeGetFileSize(hFile: THandle; lpFileSizeHigh: PDWORD):
> dword; stdcall external 'rapi.dll';
>    function CeGetLastError: dword; stdcall external 'rapi.dll';
>    function CeRapiInitEx(var RapiInit: RapiInitRec): longint; stdcall
> external 'rapi.dll';
>    function CeRapiUninit: longint; external 'rapi.dll';
>    function CeReadFile(hFile: THandle; const lpBuffer;
> nNumberOfBytesToRead: dword; var NumberOfBytesRead :dword; Overlapped:
> POVERLAPPED): bool; stdcall external 'rapi.dll';
>
[snip]

Please note that all RAPI functions are already available in the unit 
"rapi" which is normally compiled for Windows.

Regards,
Sven




More information about the Lazarus mailing list