Click here to Skip to main content
Email Password   helpLost your password?

Introduction

This utility (rcmd.exe) can copy files and folders (with subfolders) to PocketPC or from PocketPC to desktop PC. I integrated this tool into "Send To" menu. And now I am able to copy any file/folder to my device without opening ActiveSync's browser. This tool is also useful for some kind of automation.

This is a command-line Win32 application which uses RAPI to work with PocketPC. To run this utility, you should have ActiveSync installed in Desktop PC.

Windows CE Remote API

With RAPI, you can write data to or read data from a Windows CE-based device remotely with a desktop computer. This API support various functions:

This API also allows to execute applications and call a function from a DLL inside PocketPC. I think it's a great API for automating PocketPC from Desktop.

Using the sources

To build the project, you need to setup eMbedded Visual Tools (or PocketPC SDK), and setup directories in Visual C++ 6.0. Add ActiveSync inc\ and lib\ folders. Use menu Tools -> Options -> directories tab. In my case, I added C:\Windows CE Tools\wce300\MS Pocket PC\support\ActiveSync\inc (and \lib) folders.

The sources consist of a CRapi class and main module. CRapi.cpp has some public methods:

//

// copy files (with subfolders, by mask) between Destop <-> PocketPC.

//

// parameters:

//  par1 - path to copy from 

//  par2 - path to copy to

//

//  The paths may be from Desktop or PockePC

// (but both can not be from one target)

int CRapi::copy(LPCTSTR par1, LPCTSTR par2, LPCTSTR par3, LPCTSTR par4)
...
...

//

// Delete files by mask

//

//

int CRapi::del(LPCTSTR par1, LPCTSTR par2, LPCTSTR par3, LPCTSTR par4)
...
...

//

// Show files and folders

//

// dir c:\*

// dir \temp\*

// dir "\my documents\*" 

//

int CRapi::dir(LPCTSTR par1, LPCTSTR par2, LPCTSTR par3, LPCTSTR par4)
...
...

//

// Rinning application in PPC 

//

int CRapi::run(LPCTSTR par1, LPCTSTR par2, LPCTSTR par3, LPCTSTR par4)
...
...

//

// enumerates DataBases in PPC

//

int CRapi::db(LPCTSTR par1, LPCTSTR par2, LPCTSTR par3, LPCTSTR par4)
...
...

History

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralThanks
Alexander Gorshkov
7:43 17 Jan '09  
Спасибо, Александр, очень полезная программа!
Thanks a lot!Wink
GeneralBuffer overun
Member 4145128
21:23 7 Mar '08  
This is a great program and I am finding it very helpful.
Thanks Alexander.

Am I right in saying that in Rapi1.cpp

LPCTSTR itoaFileSize(DWORD size, LPTSTR out = NULL)
{
... TCHAR postfix[5];

Needs to be

... TCHAR postfix[6];

to make room for the string delimiter after "bytes"?

Martin
GeneralCopying
fdgf
12:20 16 Dec '07  
Hello,

Your application copies files a lot slower than active synch, any idea why?

Thanks!
danutz_cr

Generalwhy buffer size is 5006
AgunJ
23:51 27 Aug '07  
Hi Alexander,

Thank you.
Why you use 5006 as the buffer size in CopyFile1 and CopyFile2.
D'Oh!

CODE with me

QuestionSD card directory
ugroczkycs
4:22 14 Nov '06  
I'd like to copy files to PPCs SD card, how can i find SD card directory?
thanx
AnswerRe: SD card directory
Alexander Shilonosov
3:57 15 Nov '06  
Sorry I cannt help you. Because now I am using non MS device.

--
Alexander Shilonosov

Questionpossible to convert to vb .net
athinarayanan
4:26 2 Nov '06  
Hi this is really great tool. however, I would like to have this in vb .net version of it.
is anyone can convert will be great.

GeneralBug fix : memory leak [modified]
Vincent_RICHOMME
5:56 10 Jul '06  
Hi, there is a bug in Rapi1.cpp in itoaFileSize

In debug mode and when transferring big files I got stack corruption.
Postfix variable should be declared as an array > 5 because bytes needs 6 car to be stored : 5+ backslash 0
I have declared it as an array of 64 elements and it seems to fix all my issues.






GeneralHow to add to "Send to" meu ??
julian_hung
0:47 10 Jun '06  
Hi,
This is a great tool, I love it. I used it all the time when I want to copy files from PC to PPC.

You mentioned you have add this to "Send To" menu.
Could you share with us how you do it ??

Thanks.

GeneralRe: How to add to "Send to" meu ??
Alexander Shilonosov
4:01 15 Nov '06  
Hm. Let me to recall... It's seems that I created *.bat file. that uses %1 parameter and call rcmd.exe with it. rcmd.exe should be on the c:\windows\ folders. Bat file should be in "%your profile dir%\send to" folder.

You should only correctly setup this BAT file. and play-around a bit to get it works.

--
Alexander Shilonosov

GeneralThank you!
hepan
22:11 19 Jan '06  
It is very useful for me!
Thanks a lot!
GeneralHow to avoid memory read error exceptions?
Carlos Eugênio X. Torres
0:37 23 Jun '05  
Hi, I'm using your code on desktop application in VC++ to copy files from PC->PPC and PPC->PC. But, in the middle of a copy process, if I take the windows ce device off from the cradle (disconnect it) the program fails in a windows memory read error and the program exits!! I tryied to use try-catch into my code, but it couldn't avoid that error. What solution do you advise?
Thanks!

Carlos Eugênio Torres
Software Analyst and Developer
Microsoft Certified Application Developer (MCAD.NET)
email: carloseugeniotorres@gmail.com
GeneralRe: How to avoid memory read error exceptions?
Alexander Shilonosov
2:32 23 Jun '05  
1. Try to use _set_se_translator() in your app;
It's even interesting to me. whether it can detect the fatal error.

2. Check the code for correct processing return values
on Ce* functions.





--
Alexander Shilonosov

GeneralRe: How to avoid memory read error exceptions?
Carlos Eugênio X. Torres
5:24 23 Jun '05  
Excuse my ignorance, but what's _set_se_translator() ? Smile
I'm just using the functions from your CRapi class, no using Ce* functions directly. I'm using dir, copy and del functions most.

Carlos Eugênio Torres
Software Analyst and Developer
Microsoft Certified Application Developer (MCAD.NET)
email: carloseugeniotorres@gmail.com
GeneralRe: How to avoid memory read error exceptions?
Alexander Shilonosov
6:06 23 Jun '05  
You can use it within your VC Application to define an exception handler.
It's a way to get control when your App is fataling but before closing it.
So you can pop-up a message to user to exuse for error ))
See MSDN for the info.

I advice you to check all return values of Ce* functions in the class .

When I make the class, I did not take into account that user can plug out a PocketPC while copying. Smile


--
Alexander Shilonosov

Generalcreating directory
hadaf9
0:42 18 Apr '05  
Your utility is great and I need it

But is there away to add creating a directory as well

I need to transfer files to a new directory like \Storage Card\Temp for example.

I noticed a bug in CAB files that if it is handling more than 1000 files, the installation generate error , So I am thinking of using you utility to transfer all my files manulay by my Scripit in NSIS setup application , but it fails to copy in uncreated directory ,,, could u help please ,,

Best regards
Wink
GeneralRe: creating directory
Alexander Shilonosov
21:17 18 Apr '05  
Hello,

Just now, I take a look at rcmd.exe sources and notice that new directory should be created when copy files to PocketPC->PC (and PC->PPC).

As I get from sources now , you cant copy to unexisting folder.
Instead you may copy from "c:\my data\" to PPC (try with slash or without) , in this case "my data" folder will be created at destination and all folder content will be copyed.

Another way is to add some code for creating folders to rcmd.exe sources and compile it and share it with codeproject Smile .



--
Alexander Shilonosov

GeneralRe: creating directory
quentinsiraut
6:17 19 Apr '05  
Yeah that's what I did : update the code in order to create directories Smile

I will look how to share this...


GeneralTelnet and RCMD
quentinsiraut
9:12 15 Apr '05  
Hi guys,

I have a machine, let's call it TESTMACHINE, where is plugged in my pocketpc device. I wrote a script to run some tests on my device from TESTMACHINE (that calls rcmd to create/del files/dir). It works fine.

But, I need now to lauch my script from a remote machine, using telnet. It seems that rcmd can not connect to the device then...

Any knowledge about this ?

Thanks a lot.

Quentin
GeneralRe: Telnet and RCMD
Alexander Shilonosov
21:33 15 Apr '05  
I have no idea why it isn't working.

--
Alexander Shilonosov

GeneralRe: Telnet and RCMD
quentinsiraut
6:20 19 Apr '05  
Ok...

Well, some Microsoft guys seem to say that they are not surprised that it doesn't work Mad . Something with the difference between the authentification used in the RAPI and the one used for telnet/ssh... So they told us to give up trying to do this :->
Anyway, I found another way, not very nice that works : from telnet, schedule a task on the remote machine which will be executed at t+1 and that launches basically the script I was trying to launch directly from telnet...



Last Updated 27 Jan 2004 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010