Bonjour,

J'utilise ce petit bout de code ci-dessous:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
HRESULT reponse;
  reponse=CoGetClassObject(CLSID_TTestServeurCOM, CLSCTX_REMOTE_SERVER, NULL, IID_ITestServeurCOM, &distributedObject);
 
  switch(reponse){
                  case S_OK:
                       std::cout << "Location and connection to the specified class object was successful." << std::endl;
                       break;  
                  case REGDB_E_CLASSNOTREG:
                       std::cout << "CLSID is not properly registered. Can also indicate that the value you specified in dwClsContext is not in the registry." << std::endl;
                       break;
                  case E_NOINTERFACE:
                       std::cout << "Either the object pointed to by ppv does not support the interface identified by riid, or the QueryInterface operation on the class object returned E_NOINTERFACE." << std::endl;
                       break;
                  case REGDB_E_READREGDB:
                       std::cout << "Error reading the registration database." << std::endl;
                       break;
                  case CO_E_DLLNOTFOUND:
                       std::cout << "In-process DLL or handler DLL not found (depends on context)." << std::endl;
                       break;
                  case CO_E_APPNOTFOUND:
                       std::cout << "EXE not found (CLSCTX_LOCAL_SERVER only)." << std::endl;
                       break;
                  case E_ACCESSDENIED:
                       std::cout << "General access failure (returned from LoadLib/CreateProcess)." << std::endl;
                       break;
                  case CO_E_ERRORINDLL:
                       std::cout << "EXE has error in image." << std::endl;
                       break; 
                  case CO_E_APPDIDNTREG:
                       std::cout << "EXE was launched, but it didn't register class object (may or may not have shut down)." << std::endl;
                       break;
                  default:
                       std::cout << "Reponse inconnue???: " << reponse << std::endl;
                       break;
  }
La fonction CoGetClassObject vient d'une librairie Microsoft. D'apres la doc en ligne, elle renvoi des codes d'erreurs HRESULT. Tous ce qu'elle peut renvoyée est dans le switch.

Probleme: je passe toujours dans le default.

Quelqu'un a-t-il une idée?