Windows CE RAPI Functions

Windows CE RAPI Functions

Postby Bill Simmeth » Fri Oct 20, 2006 1:02 pm

I hope Antonio doesn't mind me posting this question...

Has anyone here worked with the RAPI functions to interact with your FWPPC app? I am trying to invoke a maintenance routine from the desktop using Rapi, but with little success. Specifically, I am trying to use the CeCreateProcess function to start this. I am able to successfully initialize/uninitialize the Rapi session, but when I call CeCreateProcess, I consistently get a Winerror #2 -- File Not Found.

I am using Xbase++ on the desktop. Here's a sample trying to invoke the calculator. I get error #2 regardless of the way I specify the app name (ie; "calc.exe", "\\My Device\Windows\calc.exe", "calc", etc)
Code: Select all  Expand view
#include "DLL.CH"

#define NULL 0

Procedure Main
Local xVal

   xVal := CeRapiInit()
   ? xVal

   If xVal <> 0
      QUIT
   Endif

   xVal := CeCreateProcess( "\Windows\calc.exe", ;
                            "", ;
                            NULL, ;
                            NULL, ;
                            .f., ;
                            NULL, ;
                            NULL, ;
                            NULL, ;
                            NULL, ;
                            NULL )
   ? xVal
   ? CeRapiGetError()
   ? CeGetLastError()

   xVal := CERapiUninit()
   ? xVal

RETURN

DLLFUNCTION CeRapiGetError() USING STDCALL FROM RAPI.DLL
DLLFUNCTION CeGetLastError() USING STDCALL FROM RAPI.DLL
DLLFUNCTION CeRapiInit() USING STDCALL FROM RAPI.DLL
DLLFUNCTION CeRapiUninit() USING STDCALL FROM RAPI.DLL
DLLFUNCTION CeRapiInvoke( cPath, ;
                 cFunction, ;
                 nInputBytes, ;
                 nInput, ;
                 nOutPutBytes, ;
                 nOutput, ;
                 nNull ) USING STDCALL FROM RAPI.DLL
DLLFUNCTION CeCreateProcess(cApp, ;
                            cParm, ;
                            nZip1, ;
                            nZip2, ;
                            lFalse, ;
                            nZero, ;
                            nZip3, ;
                            nZip4, ;
                            nZip5, ;
                            nZip6 ) USING STDCALL FROM RAPI.DLL


Thanks in advance for any ideas.
Bill Simmeth
Merchant Software Corp
Marshall, Virginia USA
Bill Simmeth
 
Posts: 42
Joined: Wed Oct 26, 2005 1:20 pm
Location: Marshall, Virginia, USA

Postby Bill Simmeth » Fri Oct 20, 2006 7:24 pm

It appears that the problem is the way I specify the file name that cuases file not found. Today I played with the CeCreateFile function and it works, but the resulting file on the PPC is placed at the root with a filename of "????????". Here's the function prototype:
Code: Select all  Expand view
CeCreateFile(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);

I call this function as follows in Xbase++...
Code: Select all  Expand view
   nHnd := CeCreateFile( "\Temp\regmanip.txt", ;
                         GENERIC_WRITE, ;
                         FILE_SHARE_WRITE, ;
                         0, ;
                         CREATE_ALWAYS, ;
                         FILE_ATTRIBUTE_ARCHIVE, ;
                         0 )

Any suggestions on how the file name should be passed?
Bill Simmeth
Merchant Software Corp
Marshall, Virginia USA
Bill Simmeth
 
Posts: 42
Joined: Wed Oct 26, 2005 1:20 pm
Location: Marshall, Virginia, USA

Postby Antonio Linares » Sat Oct 21, 2006 5:58 pm

Bill,

LPCWSTR means an unicode string not an ansi one.

Try with AnsiToWide( <cAnsiText> ) --> cUnicodeText
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 11 guests