Archive: Windows CE / Pocket PC Installer


Windows CE / Pocket PC Installer
I was wondering if anyone had any examples of a Windows CE or Pocket PC installer. Basically a Win32 program (runs on a desktop computer) and copies its CAB files through ActiveSync to the handheld device where they are unpacked and installed. Any help on this topic would be greatly appreciated.


Well I only can give you a clue how I (that is me) would do it:

1) I use Delphi http://www.borland.com/delphi/ to create a plugin
2) I already have created CAB compress/decompres libraries myself
3) I buy the http://www.tmssoftware.com/cecompidx.htm Ssource library version TMS CETools to speed up my work...
4) Then program the rest that is left into the plugin...

But indeed if I do this I did not need NSIS anyhow...

NOTE: This is not the only way, only MY way.

Success in your quest.


This doesn't really help me out. Is there a way to just get NSIS to copy the file through activesync and also for it to make it unpack over there or call another exe on the CE device?


If you look into the source of TMS CSTools you will see all the neeed OS calls, and that will be a lot of them sadly...

In these tools the Delphi function:

TCEFileOperations.CopyFileWinToCE(WinFilename,CEFilename: string): Bool;

will do what you want to do.

Or follow this path...

With Win32AS there is this thing called the Remote Application Programming Interface, or, RAPI. See MSDN site for some buggy documentation.

RAPI encapsulates the old file function functionality:

Old C function RAPI Function
CreateFile() CeCreateFile()
WriteFile() CeWriteFile()
ReadFile() CeReadFile()
etc...

How to I call these RAPI functions..

1. download the source files: RencherRAPI.cpp and RencherRAPI.h
2. And you could start off with converting them to NSIS via the system::whatevercall $R0 $R1 etc. etc.
3. To transfer a file from the PC to the Pocket PC, call the CopyFiletoWinCE() function.

Whatever way, it's will be a lot of work for you to do.

Success


The include file must get you started, or someone else for that mather. You could start to convert it to a NSIS plugin to be use by others.


Thanks
Hey onad,

Thanks so much for your help but I actually figured out a way to do it without going outside of NSIS. I'll post it here so other people can read it but also on NSIS's page where I would think to look for it.

//Make a desktop installer that only installs its contense to a Windows CE device
//You can add what ever you like to the rest of the program but these are the only steps you need to pass the CAB to ActiveSync and let it do the rest.
//Obviously fill in where it makes sense

;This is just a place to hold your files, it can be anything but your program name works best as the folder shouldn't already exist
InstallDir "$TEMP\YourProgram'sName"

;Var to hold the location of CeAppMgr.exe
var CeAppMgrLocation

Section PathObtain
;It can be obtained from the registry at this location always
ReadRegStr $CeAppMgrLocation HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\CEAPPMGR.EXE" ""
SectionEnd

Section CEInstallAndDelete
;This calls the program and passes to it the program's ini file which tells it which CAB file(s) it needs and sets it up to install
ExecWait '"$CeAppMgrLocation" "$INSTDIR\YourProgram'sINIfile.ini"' $0
;Changes the output path so the temporary folder can be deleted
SetOutPath $TEMP
;Remove the directory and all the files put into it
RMDir /r /REBOOTOK $INSTDIR
SectionEnd

//Thats all you need for it to be a very clean install process
//Feel free to post any questions
//The only two things in my install are a CAB file that is referenced in the ini file I pass to CeAppMgr


Wow, have't thought of that since I'm an API geek ;), this info will be helpfull for others too, Thanks!


The scary thing is:

var CeAppMgrLocation
Is *exactly* letter for letter, capitalisation for capitalisation, the variable name I use :)

Could I possibly ask why you've added the "$0" to the end of the ExecWait line? In my own installers, I've always used the syntax:
ExecWait '${CeAppMgrLocation} "$INSTDIR\${APPFILENAME}.ini"'
(The odd variable name for the ini file is because I have to build so many PPC/Smartphone scripts that I ended up turning it into a template based on a few defines at the start :) )

There are a few other registry keys that hold some useful information about the last/currently connected device which you might also find handy:
"HKCU\Software\Microsoft\Windows CE Services"

"DeviceProcessorType" (DWORD value containing numeric processor ID, e.g. 2577 for ARM based devices)
"DeviceType" = "PocketPC" or "Smartphone" (String value, used in the UnsupportedPlatforms/PlatformString of the .inf file)
"DeviceVersion" = DWORD value, seems to be a mangle of the OS version and build number, but you might be able to use it to identify the OS version with a little finagling.

These get updated whenever a Windows Mobile device connects and Activesync fires up, so it's a reasonable record of the last connected or currently connected Pocket PC.

Kieren

Crazy coincidence on the var name but it makes sense as it holds the location of the file CeAppMgr.exe.

I have the $0 at the end because that was in the help files and I didn't think to take it out. It actually doesn't do anything as long as the $0 var is never used.

I kinda just jumped into the companies install project so I wasn't looking at all the possibilities of using variables but we basically have many CAB files, each one specific to the device its being installed on and ini that all have the same name. I just copied and pasted the nsi file into each device's directory and changed the device name so it makes the correct exe file. Then to make things easier I wrote a batch file to call makensis.exe with each one of these nsi files. Just a tip, if you're thinking of doing this, definitely take advantage of the fact that in a bat file you can use a replace all to change something used many times. Our example would be that I have makensis.exe /DPRODUCT_VERSION = "1.75" bla/bla/something.nsi for each nsi file so I can use the same bat file if I just replace 1.75 when we go to 2.0. In the nsi file it is just safe to put
!ifndef PRODUCT_VERSION
!define PRODUCT_VERSION = "2.0"
!endif
just so you don't have a missing variable.

This way I just run my bat file and it does all the work of making the cabs, the exes, and moving them to our server. Isn't DOS great?