0

To implement the copy and paste functionnality in a MFC application, we invoke the AfxOleInit() method.

We also use RAPI to communicate with Windows Mobile devices.

When AfxOleInit is not used, we have no problems.

But as soon as AfxOleInit is actually executed, we reproduce the following sequence:

  • The mobile device is in its cradle and correctly connected via Windows Mobile Device Center (WMDC) to the PC, CeRapiInitEx and then CeRapiUninit complete successfully
  • We remove the mobile from the cradle which deconnects from WMDC
  • We reput the mobile in the cradle and, a second time, CeRapiInitEx and then CeRapiUninit complete successfully
  • We remove the mobile from the cradle which deconnects from WMDC
  • At that moment, a message appears in the "Output" tab of Visual Studio: "the RPC server is unavailable"
  • We reput the mobile in the cradle and this time CeRapiInitEx fails with the return value "the RPC server is unavailable"

We have tried to put the code which contains the calls to the RAPI dll functions:

  • directly in a MFC application,

  • in a DLL,

  • in an ActiveX

we reproduce the error in all cases.

Note that, if this code is put in another process launched via a CreateProcess from the MFC application, there are no errors.

You can download the application which reproduces this error at the following address:http://iode-informatique.com/tests/winmob_mfc/rapi_test_app.zip

Note that if you comment the call to AfxOleInit, the error doesn't occur.

Best regards.

Léa Massiot
  • 1,928
  • 6
  • 25
  • 43
  • Plugging and un-plugging the Windows Mobile device in fast order will confuse driver manager. Wait at least 15 seconds in between your connect/disconnet tests. – josef Jul 25 '15 at 16:19
  • Hello josef, thank you for the advice. I try to be patient with the PDA, WMDC and the connection process. I re-described the problem completely with a brand new application. Please have a look at it. Thanks. – Léa Massiot Jul 26 '15 at 14:30
  • When I unplug the device (remove it from its cradle), I rather have to wait approximately 1 minute which is much more than 15 seconds... Is there any tool that can tell whether the device is ready to be plugged/unplugged? Thx – Léa Massiot Jul 26 '15 at 16:14
  • And also, is there any documentation that explains either in details or roughly what happens when a Windows Mobile device is plugged/unplugged? Thx. – Léa Massiot Jul 26 '15 at 16:19
  • I did not have these issues in writing my WMDCstate2 (http://www.hjgode.de/wp/2012/03/28/mobile-development-autohide-windows-mobile-device-center-2/). It simply inits RAPI and then waits for the connected event... – josef Jul 26 '15 at 17:58
  • I just edited my post. – Léa Massiot Jul 29 '15 at 14:02

0 Answers0