Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem using rapi cedeletefile in visual foxpro

Status
Not open for further replies.

wayne52

Programmer
Mar 29, 2004
4
US
I am trying to use the function CeDeleteFile in the Win CE / ActiveSync RAPI.DLL without success.

I declare the functions with:

declare integer CeRapiInit in rapi.dll
declare integer CeDeletefile in rapi.dll string filename

I first initialize the RAPI with:

result = CeRapiInit()

The value of zero is returned.

I then try to delete the file with:

result = CeDeleteFile("\My Documents\mydatabase.cdb")

Again, the value of zero is returned. According to the documentation, success will return a value greater than zero.

I then call CeRapiGetError() to get the error code. It returns -2147014795 I do not have access to or know how to get the description of this error.

Any suggestions?

Thanks.
 
Any file name located on the CE device needs a Unicode string.
CEDeleteFile, CEMoveFile, CECopyFile, and so on.
Try using it this way:
Code:
&&... convert filename to unicode string
cFileName = STRCONV("\My Documents\mydatabase.cdb", 5)  
result = CeDeleteFile(cFileName)
As for the error, you were trying to retrieve an error from CERapi as opposed to CEDeleteFile, which, CERapi probably had no error, whereas CEDeleteFile probably did.
Try using CeGetLastError instead. It will still return an error code number, which you may find by Googling around, however, I have a table of Win32 error codes I use to look up error codes. Follow the link by signature, scroll down until you find "Win 32 Error Code Table" and download the .zip file.

-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Oops. I forgot to add one little tidbit. When you get an error code returned which is negative, try converting it to hex, then convert the last four digits of the value to decimal and look it up in the table.
Example:
Code:
nErrorNumber = -2147014795
?Transform(nErrorNumber, '@0x')
*... returns 0x80072775
?0x2775
*... returns 10101
USE win32err
LOCATE FOR errno = 10101
Of course this all goes without saying it could be written to be automated, or more elegantly, but I wanted to show more of an example than an error routine.

-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Hi Dave,

Thanks for your help. I am now able to decode the error that I am getting with CeDeleteFile(), which reveals another odd problem.

Sometimes, CeDeleteFile() returns via CeGetLastError() the value of 2, which decodes to "file not found" even when the file exists on the device. This does not happen every time, but most of the time.

I am converting the file name/path to unicode as you suggested. The file is located on the device in My Documents. The complete path is
"\My Documents\pocketds_sys.cdb"

Do you have any experience with this type of problem?

Wayne Wilson



This function is returning "file not found" even though the file is on the device. Apparently I am not specifying the location correctly.
 
Does it happen during the same RAPI session?

In other words, if you have the unit connected, perform the CeRapiInit(), CeDeleteFile(), CeRapiUnInit(), then disconnect the unit, it should work.
But if you for instance, perform CeRapiInit(), CeDeleteFile(), disconnect, do stuff, reconnect, CeDeleteFile(), it probably won't work.
Also, and this may be an obvious statement, but make sure there is no error being returned from the CeRapiInit() function prior to using any other RAPI functions.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top