I am writing an MSI installer in C# application that installs multiple CAB files to a Windows Mobile device. It does this by checking for various registry keys in the device, and then uses ActiveSync to install the needed CAB files one at a time. This is all done in a DLL file with CustomInstaller.BeforeInstall.
I have the code for this completed, and I am trying to test it out. I didn't make it very far! When I make a call to CeRapiInit() it always fails. The MSDN help says it should return S_OK (0) for success, E_FAIL (0x80004005) for a failure, E_INVALIDARG (0x80070057) for invalid arguments, or CERAPI_E_ALREADYINITIALIZED (0x8004101) if it is already initialized. I got the values for these constants from a Google search.
I am always getting the value 2148007941 (0x80080005) back from this call. What does this value mean? What could be wrong? When I check CeGetLastError and CeRapiGetError both return 0. Also, Marshal.GetLastWin32Error() returns 183, however it does this BEFORE the CeRapiInit call also, so I don't think I'm actually getting an error there.
// Declaration is the following
public static extern uint CeRapiInit();
// It's being called in a procedure as:
uint iResult = CeRapiInit();
After trying this, I gave the CeRapiInitEx() method a try. This gave the same result.
Also, when using Vista or Windows 7, and the Windows Mobile Device Center, this works fine. This only fails on Windows XP or older using ActiveSync. Other applications are able to use RAPI such as CeRegEdit. I have reinstalled ActiveSync without success.
Lastly, this MUST work on Windows Mobile 4, 5, and 6. I don't believe I can declare an IRapiSession interface.
Any help would be much appreciated!