Hello all,
I have to do a program in borland builder c++ 6 which have to copy a file from PDA/pocket pc/smartphone to a computer. This application will run on a computer, not on the mobile device... After many searches on the web, I saw that I have to use RAPID.DLL but after my application has loaded this dll, I have problem using the differents functions like : CeRapiInitEx, CecopyFile... ! I found differents code sample for VB ou other language but I have problems to adapt in builder C++.
After execute the program I always have the message : "CeRapiInitEx : error"
So, I think that if the init of RAPI does not work correctly, I can't use the other function as deletefile, or copyfile !
If anyone have an idea about the errors in my code...
Thanks in advance !
steci
September 19th, 2007, 11:04 AM
Hello all,
I have not found the solution for my problem....
nobody can help me ??
CBasicNet
September 20th, 2007, 12:41 AM
You have to plug in the PDA/pocket pc/smartphone to your computer before calling CeRapiInitEx()
steci
September 20th, 2007, 02:55 AM
Yes, I know, but it does not work !
CBasicNet
September 20th, 2007, 04:26 AM
Then use CeRapiInit() instead, in a thread. because CeRapiInit() blocks until you connect the mobile device which will make as though your application hangs.
steci
September 20th, 2007, 07:37 AM
I have already tried with CeRapiInit, and the problem is that the app blocks a long time, and the connection fail !
That's the reason that I try CeRapiInitEx instead CeRapiInit...
Ther is something in my code which is not ok, and I don't know what it is !
Other ideas ?
kirants
September 20th, 2007, 12:35 PM
I was assuming you are supposed to pass in a valid handle in struRapiInit.heRapiInit, but you are passing NULL. Why don't you try with struRapiInit.heRapiInit = CreateEvent(...); ?
Please use code tags to post code snippets. Makes code reading that much easier
You are not following the documentation recommendation.
First off, before you call WaitForSingleObject, you should check for hRapiResult. Only if that succeeded, you proceed to do other things.
steci
September 20th, 2007, 01:09 PM
Thank you Kirants,
I created a new method to init RAPI, but it still doesn't work anymore :
I have always the message "CeRapiInitEx error !!"
I don't know how to use exactly the CreateEventA() function, and I don't know why I have to do it. In the samples I found on the web, it was always set to NULL...
I don't understand what you mean by "use code tags to post code snippets." Sorry, I am not habitué (regular ?) to post sample code on this forum. Quite often I read some posts, but it is my first one, so I'm sorry !
Moreover, I'm not very good in english speaking and writing, so I'm sorry for my language too...
If you have more ideas or recommendation, don't hesitate !
kirants
September 20th, 2007, 01:15 PM
I don't understand what you mean by "use code tags to post code snippets."
Please check my signature. There is a link that explains how to use it. It is simple. Just surround the code with [code ] and [/code ] without those spaces after 'e'.
steci
September 20th, 2007, 04:18 PM
Thank you Kirants,
now I use code tags to post code snippets. Here's my function :
After running my app, I have message "ok" and after : always the message "CeRapiInitEx error !!", so it means that I have a time out...
Where is the problem ???
Please help me...
kirants
September 21st, 2007, 12:47 AM
Still quite a few problems with code. Although, I am not sure if that itself is the reason you are having problems.
Anyways, here goes:
if ( hRapiResult != NULL )
Not good. Per documentation
CeRapiInitEx Return Values
S_OK indicates success. E_FAIL indicates failure. E_INVALIDARG indicates that an invalid value was encountered.
You are checking against NULL, which is none of the possible values per documentation.
if ( struRapiInit.heRapiInit != NULL && struRapiInit.heRapiInit != 0 )
Here, you are checking the same condition ( NULL is defined as 0 ). So, that && is redundant.
You should call WaitForSingleObject only if CeRapiInitEx returns S_OK. Your code should reflect that. Right now, you call it unconditionally.
BTW, you may also be posting in the wrong forum, since this is not really a forum for mobile device development and related issues. There is another forum for that.
CBasicNet
September 21st, 2007, 04:56 AM
I have already tried with CeRapiInit, and the problem is that the app blocks a long time, and the connection fail !
That's the reason that I try CeRapiInitEx instead CeRapiInit...
Ther is something in my code which is not ok, and I don't know what it is !
Other ideas ?
If CeRapiInit() fails, CeRapiInitEx() will fail as well. I know CeRapiInit() will block for some time, there is why I tell you to call that function in a worker thread. Did you install the ActiveSync software? If you connect your device and ActiveSync shows it is connected before calling initialization functions, the connection will not fail, unless if it is not a Windows Mobile device or the mobile OS is an old one which needs an older API to work.
steci
September 21st, 2007, 01:12 PM
Thanks for the answers.
Well, I think that this post is in the right forum, because my code is for an application which runs on a computer and not on a mobile device ! Ok I try to do communication with mobile device, but it is an app which runs on the PC.
But if it is not the good forum for this post, thanks to the moderator to move it...
Now I will do some changes and test differents things !
I hope I will find a solution...
Have a nice day...
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.