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.