Saturday, February 2, 2008

How to create a windows mobile (Smart Device) .Cab installer

This time I'm going back to a basic topic: How to create a windows mobile installer for our mobile (Pocket PC / Smartphone)application. I've already blogged before about how to build a .cab which registers the assemblies on the .Net CF GAC. But this time I'm focusing on the .cab installer itself.

A Cab file is the default setup format for Windows CE and Windows Mobile devices (similar to windows .msi files). You probably already have installed several application using .cab files, and are familiar with the concept. One point which is often unknown is that .cab files are processed by wceloader.exe, and it can only install one .cab file at a time. That means we cannot have nested .cab files. It doesn't mean we cannot have .cab files contained by another .cab, but the contained .cab files will not be installed during the installation of the container .cab. We should install it manually after the container .cab file installation has been completed.

There are two ways to create a cabinet (.Cab) file. The traditional one, and the friendly VS Smart Device Cab project which doesn't require additional coding, but which also relies on the traditional one at low-level.

Traditionally, the process to create a .cab file was tedious and totally unfriendly. There is a command line tool called CAB Wizard (cabwiz.exe) which still being used to create cabinet (.cab) files. If you follow this link, you can take a look at the documentation for this tool. What the .cab does, is defined on a rather cryptic and confused information (.inf) file which is *kind of* installation script.

The easiest way to build a .cab file is using Visual Studio. It allows us to create Smart Device CAB Projects, including internal project outputs, external files, resource files, required registry entries, shortcuts and more, resulting in a cabinet file after build. Let's see an example:

Walkthrough: How to create a Smart Device CAB Project

Assume we have the following solution:

image

and we want to include a project to create the cab installer for our application, which should:
1) Copy DeviceCoolApp.exe, the referenced assembly MyDeviceLibrary.dll and the resource file called SampleKindOfResourceFile.xml to the application folder.
2) Additionally, it should create a shortcut in the Programs folder on the device and
3) Set the string value HKLM\Software\Mobile Practices\DeviceCoolApp\Version to "1.0".

First of all, we need to add a new Smart Device CAB Project to the solution: Right click on the solution, Add - New Project...

image

Call it DeviceCoolAppInstaller and press OK. The new project will appear at the bottom in the Solution Explorer window.

Now, I recommend we change the project properties to get a *nice* product installation. Set the Manufacturer (Mobile Practices) and Product Name (DeviceCoolApp) as follows:

image

It's time to add DeviceCoolApp.exe (the DeviceCoolApp project output) to the CAB Project. Right click on DeviceCoolAppInstaller - Add - Project Output...

image

Select DeviceCoolApp on the Project selector, and Primary Output as follows, and press OK.

image

Visual Studio will detect automatically the DeviceCoolApp dependencies. In this case it will detect MyLibrary.dll

image 

**If the dependencies are not detected, you can rebuild the solution and then Right Click on Detected Dependencies - Refresh Dependencies.

As you can see, due to the automatic dependencies detection, we don't need to add MyDeviceLibrary as Project Output on DeviceCoolAppInstaller.

Now it's time to add the resource file SampleKindOfResourceFile.xml which should be installed on the Installation folder. Let's use the File System Editor, having the DeviceCoolAppInstaller project selected press the File System Editor button (btw, it's probably already open).

image

Now, right click on Application Folder - Add - File....

image

Browse and find SampleKindOfResourceFile.xml and press OK.

image

Congrats!, now we have all the necessary files ready to be installed. The next step is to add the shortcut.

Unfortunately, the Programs Folder is not already included on the File System Editor, and we need to include it manually: Right click on File System on Target Machine - Add Special Folder - Programs Folder.

image

And now, select Programs Folder on the File System tree, and right click on the empty panel at right and select Create New Shortcut

image

And select Application Folder - Primary output from DeviceCoolApp (Active) and press OK.

image

And rename it to "Device Cool App"

image

This will be the application shortcut on the Programs group on the smart device after installation. Now we just have to add the registry entry. Press the Registry Editor button:

image

And add the string value "HKLM\Software\Mobile Practices\DeviceCoolApp\Version". You need to create the path key by key, and the add the string value on the right panel.

image

Name it "Version" and then, select it, and enter "1.0" into the Value field on the Properties Window

image

And *voila* the Smart Device CAB Project is done! We're ready to build the solution, right click on the DeviceCoolAppInstaller project and select Build.

You can find the DeviceCoolAppInstaller.cab file in the DeviceCoolAppInstaller\debug folder.

image

We are ready to ship our application and distributing it. If you want to test it (highly recommendable), you can copy it to the emulator (or share de folder to make it visible from the emulator as a Storage Card) or to the device and install it. You can also uninstall it thru the Remove Programs option.

As you can see, in the same folder, there is also a DeviceCoolAppInstaller.inf file. This file is generated by Visual Studio and passed to CabWiz.exe to generate the .cab file. As I've said before, Visual Studio still using the traditional way to build a cabinet file at low-level. But it DOESN'T mean that Visual Studio Smart Device CAB projects are just a graphical front-end for the cabwiz.exe tool. The main advantage of using a Smart device cab project is that it also integrates our development, it automatically updates the .inf file according with the changes we make to our projects, it includes renaming of output files (DeviceCoolApp.exe is not physically linked, if we change the assembly name setting in our project to DeviceCool.exe, we don't need to modify the DeviceCoolInstaller project) and dependencies which are automatically detected.

Well, work is done. Now you can start creating your own smart device cab projects and please don't forget to read my previous post about how to build a .cab which registers the assemblies on the .Net CF GAC which can be also very useful. Stay tuned!

Update (10/28/2008): You can also read a Setup.dll walkthrough for adding a Terms & Conditions dialog before the installation for further info about how to customize a cab installer.

93 comments:

Michael said...

Great article, thank you! This is also applicable to native C++ developers, which is useful for me. :)

I've read about 4-5 different articles on this topic, most of which were written a few years ago. I'm glad that you're article is recent and up-to-date.

Very nice walk-through.

Thanks again,
Michael

Anonymous said...

Thanks a lot!
Nice article, clear and precise. You have just saved me hours of work.

zenek333 said...

Is there aby way to add a shortcut to System tab on Settings window?

Jose Gallardo said...

zenek333, sorry for the delay.
The settings window is actually a control panel implementation for windows mobile. In order to do what you want, you should create a control panel applet. Try taking a look at the "My Backlight" sample included in WM6 SDK located in %ProgramFiles%\Windows Mobile 6 SDK\Samples\PocketPC\CPP\win32\myBackLight.
You can also read about the sample here:
http://msdn2.microsoft.com/en-us/library/bb158728.aspx
HTH!

aet said...

Is there a way to force softreset after the application was installed?

BTW, great article! Thanks a lot

Jose Gallardo said...
This comment has been removed by the author.
Jose Gallardo said...

I'm updating my previous comment regarding the app restart:
You can provide a Setup.dll which will be the responsible to perform the soft reset after installation.
A Setup.DLL is a Native DLL which should be included in the CAB file and it can be set using the "CE Setup DLL" property of the Smart Device CAB project.
To understand what a setup.dll file is, the following links can be helpful:
http://msdn2.microsoft.com/en-us/library/ms228717(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/aa924308.aspx

Once again, thanks for your feedback!

Leonard Lee said...

Hi,

Thanks for your nice article. Saves me few hours of researching.

However, anyone tried this on Windows CE?

I did not seem to get it working.

Thanks in advance.

Anonymous said...

Really good tutorial! Thanks!

/seriously noob developer

Kees Dijk said...

Hello,
Very nice article thanks a lot. We are running into a problem, maybe you can shed some light on it. We build our solutions on a TFS server. So basically every build is after a clean build. After a clean build the dependencies in the cab setup project are gone and need to be refreshed. Do you have any idea on how to do that programmatically ? Thanks.

Jemson Sentillas said...

Thanks, very nice article.

You da man!!!
--jemtech007--

sonicbaz said...

HI excellent article, worked first time!!

Thanks!!!

Jose Gallardo said...

Thanks everybody for your comments.
Kees Dijk, Sorry for the big delay, I was very busy lately.
Hope you already have a workaround for the issue, but just in case you don't, let me try to help you.
Smart Device Cab projects still being far from what ideally could be. Actually the build process not even laid in MSBuild tasks.
My recommendation is to keep the .inf file updated by refreshing dependencies manually, and include the updated .inf file (or files) as part of your versioned files on TFS. In your automated build process you can just launch "cabwiz.exe" for the latest version of your .inf in order to get the CAB installers.
HTH.

Kees Dijk said...

Thanks Jose and not a problem.

We have found a workaround. We add the output of the library’s that the code depends on also to the setup project. When we add new library’s we only have to remember that we also add the library to the setup. It's not perfect but it works.

Anonymous said...

Hi Jose
Nice article. Helped me a lot. I have one question here, when we install CAB file it asks where to install giving 3 options device or My storage or Bluetooth FTP.
Is there any way to avoid this screen when installing CAB file.
Please help me out

Jose Gallardo said...

You probably can do it using wceload.exe to manually launch the installer.
WCELOAD is also used by the shell to install cab files, so you can manually start it with the right parameters to avoid UI at all, or just to avoid asking for destination.
Follow this link for more information.
Be careful when using /noaskdest because it overrides the cab file path and destination parameters using a set of registry entries for one or more cabs files installation. i.e. if you want to install two cab files, your registry should look like:
[HKEY_LOCAL_MACHINE\Software\Apps\Microsoft Application Installer\Install]
"\Sample1.cab"="\\Program Files\\Sample Application One"
"\Sample2.cab"="\\Program Files\\Sample Application Two"

If the CAB installer you mentioned, aks for destination from a setup.dll instead of using the standard method, /noaskdest will not help.

HTH

Sravan said...

hi..i've a prob and though you might help me.

I need to show the user a "Terms & Conditions" and only when the user accepts those, the application needs to be installed. Is there a way to do this?

Please let me know ASAP.

Jose Gallardo said...

You need to create a Setup.dll for your installer.
This link could be useful:
http://msdn.microsoft.com/en-us/library/aa924308.aspx

You need to show the Terms & Conditions on the Install_Init function, and according with the user input, return codeINSTALL_INIT_CONTINUE or codeINSTALL_INIT_CANCEL.

This is a very good example of how useful a setup.dll could be.

Sravan said...

Hi Jose,

Thanks for the reply. I tried it. But when I place the code in the Install_INIT method, its not being executed. Should I put some code in the Main method as well?

Regards,
Sravan

Anonymous said...

Mr.Jose Gallardo,
i have difficult,i can't copy .exe to .xml..
Can you explain more of this??
I'm very newbie

Thank you very much..

Jose Gallardo said...

Sravan, you probably need to add a .def file (i.e. setup.def) in your c++ project with the following content :

LIBRARY "your dll name without extension"
EXPORTS
Install_Init

That's required for exporting the Install_Init method to the installer process.
I'll post an example about this soon.
HTH!

Jose Gallardo said...

Anonymous, could you please elaborate further on your question?
I don't get where do you need to copy an .exe to .xml in the article.
Thanks!

Sravan said...

thx Jose, it worked :)

Sravan said...

Hi Jose,

Is there anyway to do the same using C#?

Jose Gallardo said...

Unfortunately a setup.dll should be a native dll. So you can not write it using c#.

chuby said...

Gracias Jose ! Excelente me quedo lo mas bien el cab se agradece

Jeremy said...

Hi, When you create a CAB file also installs the compact Framework or do I have to install it separately? Thanks...

Sravan said...

Hi Jose,

Thanks for the reply. But is there a way to show that message box in full screen mode and always use soft keys like in Pocket PC on Smart Phones also?

rishi said...

hi..

hve a prob..need to show the user "accept terms and cond" before installation..and according to this,the application should install..i tried it by using messagebox but we need to use soft keys not messagebox button..is it posible? if it is,please provide me a solution as soon as possible..

Jose Gallardo said...

For showing a Full Screen window and handle soft keys in Pocket PC from Visual C++ you'll need something more elaborated. A MessageBox is not enough.
Please have a look at CreateWindow and RegisterClass for more info.
A good pointer could be going thru the VC++ Smart Device Win 32 App Wizard for creating an application instead of a DLL and see the app skeleton generated. You need most of that skeleton for your dll.
I'll try to make the time for posting a PocketPC version of this, and spike a potential .Net CF alternative, but this is a very busy week, so it probably won't be soon. Sorry about that!

Jose Gallardo said...

Jeremy, some devices already have installed .Net CF 2.0 in ROM so you probably don't need to install it.
If that's not your scenario, you do have to install it separately.
Please check this two posts for further info:
How to deploy the .Net Compact Framework and SQL Server Compact Edition
Detecting what .Net CF version is installed on your device

Sravan said...

thx Jose, that would be very helpful :)

Pappu said...

Hi jose...
have a problem..am working on windows mobile5.0. accidently i deleted certificate for C# projects in my applications.now i am unable to add certificate.so can you pls explain the procedure for the same..its little urgent..pls give me solution as soon as possible.

Jose Gallardo said...

Try installing:
"Program Files\Windows Mobile 5.0 SDK R2\Tools\SdkCerts.cab".
If you have permissions to uninstall certificates you do have permissions to install it

pappu said...

Thnak jose...it's working fine... :-)

Stefan said...

Thanks for article?

Any idea how to add directory to installer instead of single file?

I see the source code option, but I really need to do is install bunch of xml, bmp samples in in three directory structure.

Stefan said...

Ok i did following:

1) Created Empty project in my solution containing directory structure i want to put on device
2) Marked all files as Content
3) Add Project Output(Content Files) of newly added project 'Samples' to destination directory of installer.

This makes sense since installers does install files that are contained in solution.

Luca said...

Thanks a lot. Works fine with Windows Mobile 6 too.

ranch said...

Thanks a lot!!
Great article, helped me a lot :)

I have a question.. maybe you have stumbled in it..

I work with vs2008 c#, writing a CF application

I've created a cab for deployment, and was surprised to find
that almost all the DLLs the application make a use of were
copied to the cab file, instead of copying only the ones I add
(like device dll..)
(microsoft .net CF 3.5 is installed on the device)

the cab file is now up to 35 MB!!

how can I solve this???

bloodhard said...

just a question here..

in my solution,

i have a ce app project, a cab create project, custom installer project. and a setup project.

however i am not be able to install multiple cab files at the same time..

i would like to install NETCFv2 and other 3rd party cab files before installing my app.

any hints?

i tried to put all the cab file names (separated by ",") in the CabFiles section of my setup.ini.

thanks~

Mrudula said...

Your blog is amazing...!!
I am very much interested at learning windows mobile.

Can you please suggest me some referances regarding windows mobile like online websites,online books etc....
Thanks in advance..!!

Anonymous said...

Thank you! I've been trying for ages to work out how to create shortcuts via the CAB file installed.

Jay.Livestrong said...

whoever wrote this article did a wonderful job, I got it the first time thru. But just wondering what's in the SampleKindOfResourceFile.xml?? I did not have this resource file in my development, anyone can help ??

Jose Gallardo said...

Thanks Jay!, I'm glad you like it.
The SampleKindOfResourceFile.xml is just a way to show you how to include content files in your cab installer. In this case, the application should be deployed including a xml file in the same folder. In the same way you can include configuration files, resource files like pictures, media or whatever you need.

HTH.
Cheers,

Anonymous said...

Hi!

I have a question for you...

Is there a way to install my root.cer to the Certificate Store from tha same cabinet file with my application?

I meean:
From a single cabinet file which contains my project install and my certificate file too?
How should I do this?

Thanks a lot!
Bruno

Julio César said...

Excellent article!!!

but one question, is there a way to choose the icon that will appear once the application is installed?

Jose Gallardo said...

The shortcut will have the application icon. If you want to change the default icon for your app, you can do it by right clicking on the Project - "Properties" and from the Application tab, in the "Resources" section just select the icon you want!
HTH

Anonymous said...

Awesome tutorial, Thanks A LOT!

Niyazi said...

Hi Jose,

1. I went to Properties of my project.
2. In Resources tab, I added Icon1 and redesigned the default BMP.
3. Filename shows ..\Resources\Icon1.ico
4. In CAB project's File System Editor, I added this icon to the Application Folder like the XML file in your following sample:
http://www.mobilepractices.com/2008/02/how-to-create-windows-mobile-smart.html

When I created the CAB file and installed in my WM cell phone, the icon is still the same; not the one that I redesigned.

Am I missing a step?

Thanks for your help.

Jose Gallardo said...

Please notice that I said "Application tab" not "Resources tab". In that tab, at the bottom, you have a "Resources" area where you can find an "Icon and manifest" option for selecting the application Icon.
You don't need to include any extra resource as part of the Cab project for doing this, it will be pulled from the application file directly.
HTH

Niyazi said...

Thank you Jose. Your description really helped.

Anonymous said...

Very good article and comments !!!
Some times ago I asked 'Is there aby way to add a shortcut to System tab on Settings window?' You answered this post:
http://msdn2.microsoft.com/en-us/library/bb158728.aspx.
Is there any way to do it with Windows Mobile 5.0?

zenek333 said...

Is there any way to remove icon from Settings - System tab? Is there any way to change the program which will be executed after tapping e.g. 'Audio' icon?

Jose Gallardo said...

Thanks.
You should create a Control Panel Applet for Windows Mobile 5.0 as well. This is a link to the WM5.0 doc on CPlApplet:
http://msdn.microsoft.com/en-us/library/aa454658.aspx

Anonymous said...

I'am using VS2008 with 'Windows Mobile 5.0 Pocket PC SDK' installed. I cant' compile 'myBackLight' project. When I try to compile it, i get the following error:

Error 1 error LNK2019: unresolved external symbol __GSHandlerCheck referenced in function "long __cdecl GetFromRegistry(enum tagRegistryOp,unsigned long *,unsigned long *)" (?GetFromRegistry@@YAJW4tagRegistryOp@@PAK1@Z) mybacklight.obj myBackLight

Error 2 fatal error LNK1120: 1 unresolved externals Windows Mobile 5.0 Pocket PC SDK myBackLight

How can I reslove these errors?

Anonymous said...

Man you rules!
on the MS site I found info only about freaky Cabwiz.

Nidya said...

Thanks Jose, your article really helped... it works :)

Anonymous said...

hi, great article... congrats for that.. I have 2 questions
1) I am trying to incorporate dll files which are meant for Windows Xp. Is it possible to register these dll files in the emulator the way you have depicted above?
2)If not, is there a way I can convert these ready made dll files into the Windows CE compatible ones and register them the way you mentioned above? or I will need the source code for these dlls?

I am a beginner in this area. Please help.
Thank You

Jose Gallardo said...

Well, you need DLLs built for Windows CE/ Windows Mobile.

If your DLLs are .Net Managed Code, the .Net CF assemblies are binary compatible with full framework assemblies, but as the .Net CF is basically a subset o the full framework, even in that case it will mostly fail.

Actually, even if you have the source code, depending on how Desktop oriented is the codebase you may need to change it before building it for mobile.

HTH!

ear said...

I am trying to show my own dialog. It shows the dialog but when I click on a button in it SetupDLL exits! Here is code

// SetupHelperDLL.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "ce_setup.h"
#include "resource.h"


HINSTANCE hInstance;
HMODULE hModule;
LPCTSTR pszInstallationDir;

LPCTSTR GetLicenseAgreement();
codeINSTALL_INIT ShowDialog(HWND hwnd, LPCTSTR pszInstallDir );
int CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

void ShowError(DWORD err);

BOOL APIENTRY DllMain( HANDLE handle,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
hInstance = (HINSTANCE)handle;
hModule = (HMODULE)handle;
}

return TRUE;
}

codeINSTALL_INIT Install_Init(HWND hwndParent,
BOOL fFirstCall,
BOOL fPreviouslyInstalled,
LPCTSTR pszInstallDir )
{
return ShowDialog(hwndParent, pszInstallDir);

//if (!fFirstCall
// ||
// ::MessageBoxW(0, Message,
// _T("SplashScreenSample")
// , MB_YESNO) == IDYES)
// return codeINSTALL_INIT_CONTINUE;
//else
// return codeINSTALL_INIT_CANCEL;
}

HWND mainHwnd;
codeINSTALL_INIT ShowDialog(HWND hWndParent, LPCTSTR pszInstallDir )
{
mainHwnd = hWndParent;
pszInstallationDir = pszInstallDir;
//MessageBox(mainHwnd, _T("Enter ShowDilaog"), _T("ShowDilaog"), MB_OK);
int result = (codeINSTALL_INIT) DialogBox(hInstance, MAKEINTRESOURCE(IDD_POCKETPC_LANDSCAPE), hWndParent, (DLGPROC)DlgProc);
if (result == IDOK)
{
MessageBox(0, _T("ShowDialog"), _T("DlgProc.Results=OK"), MB_OK);
return codeINSTALL_INIT_CONTINUE;
}
else
{
MessageBox(0, _T("ShowDialog"), _T("DlgProc.Results=CANCEL"), MB_OK);
return codeINSTALL_INIT_CANCEL;
}
}

int CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
//UNREFERENCED_PARAMETER(lParam); //lParam is usually never used, so just unreference it
int wmId, wmEvent;

switch(uMsg) //the command that the dialogbox receives
{
case WM_INITDIALOG:
SetDlgItemText(hWnd, IDC_AGREEMENT_TEXT, GetLicenseAgreement());
MessageBox(mainHwnd, _T("DlgProc()-2"), _T("DlgProc"), MB_OK);
return TRUE;

case WM_COMMAND: //A button has been pressed ! Something has happened ! Let’s check what it was !
wmId = LOWORD(wParam);//makes life easier
wmEvent = HIWORD(wParam);//makes life easier
switch (wmId) //find out which button was pressed
{
case IDC_AGREE_BUTTON:
EndDialog(hWnd, IDOK);
return true;

case IDC_CANCEL_BUTTON:
EndDialog(hWnd, IDCANCEL);
return true;
}
break;

case WM_CLOSE: //EndDialog must be called to close a DialogBox
EndDialog(hWnd, codeINSTALL_INIT_CANCEL);
break;

case WM_DESTROY: //PostQuitMessage sends the dialog a signal to close
PostQuitMessage(0);
break;

default://just do nothing if none of those are the message
;
}
return 0;
}

LPCTSTR GetLicenseAgreement()
{
LPCTSTR message = _T("TERMS & CONDITIONS\n")
_T("Selecting YES you're accepting our terms & conditions.\n")
_T("This is just a sample application.\n")
_T("You can replace this text with your own\n")
_T("We're using a setup.dll to show this dialog.\n")
_T("Last line.\r\n");

return message;
}

Jose Gallardo said...

Ear,

Your code is almost ready to work.
Just remove the PostQuitMessage line and the message boxes you're showing to check if the return value is the expected.

Remember to validate the firstCall flag to avoid potential annoying multiple showing of the dialog if the original target has not enough space.

HTH!

sunnyboy said...

Thank you very much! I'm new in mobile application developing, so this article is very useful for me.
I followed your guide setp by step and I was very happy when the .cab file was created. I would like to use my application with Windows CE 5.0 professional, but unfortunately after the sucesfully installation on the device the application doesn't start and I got this error message:
"Cannot find 'MyFirstApp' (or one of this components) Make sure the path and filename are correct and all the required libaries are available." I'm sure that I didn't miss anything when I created the .cab file. Should I copy other dlls or install any tool on my device?
Thnk you in advance!

Jose Gallardo said...

If your application is a .Net CF app, your device may not have the Compact Framework installed on it.
Please take a look at:
Detecting what .Net CF version is installed on your device
and
How to deploy the .Net Compact Framework and SQL Server Compact Edition

sunnyboy said...

Dear Jose Gallardo,

thanks for your advices, after installation of .Net CFW on the device my test application is running without any problem. Thanky a lot again!

Anonymous said...

Thaks a lot! Very nice artice. Its clear and precise.

Nishith said...

Great Article! Thanks for your post.
Moreover, I have one question, like, is it possible to show our custom progress bar in Install_init.
Custom progress bar will show progress of my cab which is getting installed on device. Because what i doubt is unless you no return codeINSTALL_INIT_CONTINUE, cab will not get install.
Could you please share your expertise in this?

Nishith said...

Thanks for your great article. Moreover, i have one question in Install_Init.
Question is, I wanted to show my custom progress bar to notify user that my applications cab is getting installed and to promote my brand. For this i tried in install_Exit and was successfull. Now I wanted to do the same in Install_Init, but I doubt that unless we do not return codeINSTALL_INIT_CONTINUE, installation will not start.
So could you please share your expertise in this, how can i achieve this.

Nishith said...

It is a great article. Thanks for your post.
I have one question in relation to Install_Init(). Is it possible for me to find what .netcf version and which SQL CE version is installed on device in Install Init(). So using this information, I can show my custom dialog and proceed my end user to relevant link from where he can download .netcf version and SQL CE cabs.

Thanks again for your time.

Nish

Jose Gallardo said...

Hi Nishith,

About showing your logo while installing, unfortunatelly that's not possible. You should return codeINSTALL_INIT_CONTINUE b/c the hook is for pre-installation.
Btw, answering your second question, you do have a way to check the SQLCE version.
In your device registry, you can check for
[HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SQL Server Compact Edition\v3.5]
If you're looking for a specific build you can also look for
[HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SQL Server Compact Edition v3.5 [EN]]
which includes MajorVersion, MinorVersion and BldNum values.

HTH!

Anonymous said...

I found this site using [url=http://google.com]google.com[/url] And i want to thank you for your work. You have done really very good site. Great work, great site! Thank you!

Sorry for offtopic

vikash said...

iam working on windows application, while creating project setup iam unable to set application icon. by default iam getting file type icon but not the selected one in application tab properties(in resources)....can any one help

Anonymous said...

Thanks a lot man! Really helpful!

Just to finish the task, another pal wrote about registering file extensions on the mobile device: http://dalelane.co.uk/blog/?p=211

Zah00r Ahmad G0rsi said...

Very nice article!!
I have 2 questions regarding cab file.

1) in my application user may wish to re Start the application on device reboot. e.g i have setting page where user pay check/uncheck option "Start On Boot". so how can i make a cab file which may do this functionality.

Previously what i did was i just put it into start up and it was restarting always on rebooting.

2)how can i make it autorun. e.g if user downloads/copy when downloading/coping is complete it should automatically start installing.


Thanks.

Hiren said...

Fantastic Article.
Thanks.

Jose Gallardo said...

Thank u again for your comments.

@Zah00r:
1) You can create a special Folder on the File System view called "Startup Folder", the same way you create a Start Menu Folder or a Programs Folder.

2) To make that possible you need to build your own downloader, but it only makes sense if your downloader can be previously installed on the device.

Aaron said...

great article, thanks for the help.

Raghav said...

Excellent and detailed article helped me to have quick understanding of cab building process.

I have a question we are using Visual Studio 2008, .Net CF 3.5 with SDK 6.1.

But cab building is failing always. We tried on multiple machines but still unable to resolve. Any pointers. We tried few suggestions in web like short path name, .inf file in same folder as wizard but nothing seems to be working.

Any ideas on this will help me to take this to closure

Kacper said...

Great article, thank you!
I have done everything what You wrote, but one error still occur.
The error is "cab file "..." could not be created" and I have no idea what to do with this :/
Do You have any idea?

Bernard said...

Great article Thanks you!
My problem is that under Registry tab, HKEY_LOCAL_MACHINE doesn't have subfolders as described in the article. Am i missing something? Any idea? I am a newbie so pardon my ignorance.

Somnath said...

Great article, thank you!

James said...

Hi,

I need to know how to create a localized CAB. This means my application should have another name, install path and link based on the system language. Does anybody have a clue?

Anonymous said...

neat, nice & going

thanks for the tutorial...

ambily said...

Nice Articles

ambily said...

Nice Article

Anonymous said...

Jose as some one said above you rule

makramdjerba said...

Hy, I follow your steps but when i try to create shrtcut i can not found the right empty panel your talking about , it doesnot show in my VS!!
Please help.

Ravi Patel said...

i am trying all steps same as given above but when i try to run my cab on emulator it shows an error create an entry for non-executable project cannot started directly....

rudeman said...

thanks!!!

Anonymous said...

Very nicce!

Mayur said...

Greate article.This one is very helpful for me amongst other.

thank you
Mayur

Ishay said...

Great post it helped alot.
One Question: Is there a way to control the installation directory on the target device.

Ishay

Ishay said...

Great Post. It helped alot.

I am still looking for a way to change the installation directory on the target device.

Thanks
Ishay

Waseem said...

Hi Jose,

I read your article. It was very well written and helped me a lot. I really appreciate your work.
I am new to mobile application development and developing an application for the platform Win CE 6.0 in C#.NET. After reading your article I was quite able to create the cab installer
of my application and it has been deployed successfully as well. Thanks to you once again.

I would like to extend my application further by giving it the functionality of Auto Update:
1) Whenever a new versions of my application becomes available it starts updating my application without losing the existing saved data.
2) During the update process if any error occurs it should be roll back to the previous state.

Can you please help me in this regard. Assume that my application has all the access to newly available updates and can download it.

I have sent you an email too.

Regards,
Waseem