PocketPC CAB setup

From ISXKB

Revision as of 22:24, 10 April 2007 by Markus (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Original post on Inno Setup Newsgroup http://news.jrsoftware.org/news/innosetup/msg62796.html

In case you have a PocketPC CAB file (that would normally be copied to the PocketPC and run there) and you want to create a setup that runs on the PC, copies and runs the CAB - here it goes

Note: VS2005 can create those CAB files for you automatically, or use MakeCAB.exe

Step 1

Create and add a SETUP.INI file

[CEAppManager]
Version=1.0
Component=App
[App]
Description=Whatever you want to say here
CabFiles=MyPocketPCSetup.CAB

Add a "After install" to this file

InstallOnPocketPC('Setup.ini')

Step 2

Add this [Code]

(Note: You can also accomplish the same functionality with the {REG:...} macro, but I preferred to have control over error handling)

procedure RunAppManager(arg : string);
  var
    RegPath : string;
    ResultCode : Integer;
begin
  // get path to the app manager
  if not RegQueryStringValue(
    HKEY_LOCAL_MACHINE,
    'Software\Microsoft\Windows\CurrentVersion\App Paths\CEAppMgr.exe',
     '',
     RegPath) then
  begin
    Log('Count not find the path to CEAppMgr.exe');
    MsgBox('Could not find a component needed to connect to the PocketPC. Aborting...', mbError, MB_OK);
    exit;
  end;
  Log('Launching "' + RegPath + '" ' + arg + ' ...');
  if Exec(RegPath, arg, '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
  begin
    Log('Succeeded... rc=' + IntToStr(ResultCode));
  end
  else begin
    Log('Failed ' + IntToStr(ResultCode));
    MsgBox('PocketPC setup manager failed...', mbError, MB_OK);
  end;
end;

procedure InstallOnPocketPC(INIFile : String);
  var arg : String;
begin
	// get fullpath to .ini file
	arg := ExpandConstant('"{app}\' + INIFile + '"');

	// run WinCE App Manager to install .cab file on device
	RunAppManager(arg);
end;

procedure UninstallFromPocketPC;
begin
	// run WinCE App Manager to install .cab file on device
	RunAppManager('');
end;

Step 3

call UninstallFromPocketPC on your UninstallRun section

Credits: Modified from a MS sample

Personal tools
Ads: