IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MFC Discussion :

[COM]remote component


Sujet :

MFC

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Janvier 2005
    Messages : 26
    Points : 14
    Points
    14
    Par défaut [COM]remote component
    Bonjour,

    J'aimerai utiliser un composant COM (serveur OPC) qui est situe sur un ordinateur distant (ici il s'agit du poste fictif dont l'adresse IP est : 198.256.254.45).
    J'ai essaye le code suivant pour me connecter au composant, mais cela echoue : E_NOINTERFACE.


    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
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
     
    // The remote machine
    CString strRemoteMachine;
    strRemoteMachine = "198.256.254.45";
     
    // array of interfaces we will query for each server
    MULTI_QI m_arrMultiQI [7];
     
    // Re-intialize Multi-Query Interface:
    for (int i = 0; i < sizeof (m_arrMultiQI) / sizeof (MULTI_QI); i++)
    {
      m_arrMultiQI [i].pItf = NULL;
      m_arrMultiQI [i].hr = 0;
    }
     
    // Load up the Interface ID's we hope to get pointers for when we
    // call CoCreateInstanceEx():
    m_arrMultiQI [0].pIID	= &IID_IOPCServer;
    m_arrMultiQI [1].pIID	= &IID_IOPCCommon;
    m_arrMultiQI [2].pIID	= &IID_IConnectionPointContainer;
    m_arrMultiQI [3].pIID	= &IID_IOPCItemProperties;
    m_arrMultiQI [4].pIID	= &IID_IOPCBrowseServerAddressSpace;
    m_arrMultiQI [5].pIID	= &IID_IOPCServerPublicGroups;
    m_arrMultiQI [6].pIID	= &IID_IPersistFile;
     
     
    // First we need to initialize a server info structure:
    COSERVERINFO tCoServerInfo;
    ZeroMemory (&tCoServerInfo, sizeof (tCoServerInfo));
     
    // Allocate memory for the machine name string:
    int nSize = strRemoteMachine.GetLength () * sizeof (WCHAR);
    tCoServerInfo.pwszName = new WCHAR [nSize];
     
    // Copy the machine name string into the server info structure:
    #ifdef _UNICODE
    // For Unicode builds, the contents of m_strRemoteMachine will
    // already be in wide character format, as demanded by COM, so
    // copy it as is.
    lstrcpyn (tCoServerInfo.pwszName, strRemoteMachine, nSize);
    #else 
    // For ANSI builds, the contents of m_strRemoteMachine will not
    // be in wide character format, as demanded by COM, so we need
    // to reformat:
    mbstowcs (tCoServerInfo.pwszName, strRemoteMachine, nSize);
    #endif//_UNICODE
     
    // CoCreateInstanceEx will launch the OPC Server if necessary, and
    // call its QueryInterface for us (bumping its reference count):
    hr = CoCreateInstanceEx (
      CLSID_StdComponentCategoriesMgr,	// CLSID
      NULL,  // No aggregation
      CLSCTX_REMOTE_SERVER, // remote servers
      &tCoServerInfo,	// remote machine name 
      sizeof (m_arrMultiQI) / sizeof (MULTI_QI),	// number of IIDS to query 
      m_arrMultiQI);  	// array of IID pointers to query
     
    // COM requires us to free memory allocated for [out] and [in/out]
    // arguments (i.e. name string).
    delete [] tCoServerInfo.pwszName;
     
    switch(hr) {
    case S_OK : TRACE("S_OK"); break;
    case REGDB_E_CLASSNOTREG  : TRACE("REGDB_E_CLASSNOTREG"); break;
    case CLASS_E_NOAGGREGATION : TRACE("CLASS_E_NOAGGREGATION"); break;
    case CO_S_NOTALLINTERFACES : TRACE("CO_S_NOTALLINTERFACES"); break;
    case E_NOINTERFACE  : TRACE("E_NOINTERFACE  "); break;
    }

    Est-ce que quelqu'un aurait-deja t-il ete confronte a ce genre de probleme ?
    Et si oui, comment a t-il fait pour le resoudre ?????????

    Merci

  2. #2
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    731
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 731
    Points : 574
    Points
    574
    Par défaut
    Il te manque peut-être le CoInitialize

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Janvier 2005
    Messages : 26
    Points : 14
    Points
    14
    Par défaut [COM]remote component
    Merci ep31,

    Mais j'effectue bel et bien le CoInitialize avant d'executer le precedent code.


  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    731
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 731
    Points : 574
    Points
    574
    Par défaut
    essaie de voir à partir de ton poste avec Ethereal si la connexion à ton serveur distant se fait.

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Janvier 2005
    Messages : 26
    Points : 14
    Points
    14
    Par défaut [COM]remote component
    Finalement, il y a vait en effet un petit probleme de communication avec le serveur OPC. (merci ep31 )

    Mais maintenant, j'obtient une nouvelle erreur : erreur 0x80070005.
    Apparemment, il s'agirait de l'erreur "ERROR_ACCESS_DENIED".

    Quelqu'un a t-il une info a ce propos ????

    Merci

  6. #6
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Points : 17 323
    Points
    17 323
    Par défaut
    tu ne dois pas avoir les droits d'acces suffisants sur ce serveur...

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Janvier 2005
    Messages : 26
    Points : 14
    Points
    14
    Par défaut [COM]remote component
    Apparemment, il s'agit bel et bien d'un probleme de droits d'acces.

    Mais, la je ne sais vraiment pas quoi faire bien que j'ai tente ceci :

    + Client
    ---------
    DCOMCNFG.EXE -> Selection du composant ScadaOPCServer -> Proprietes ->
    1-> Location tab -> Selection de Run Application On This Computer -> Selection du serveur sur lequel est installe le composant ScadaOPCServer
    2-> Identity tab -> Selection de Interactive User
    3-> Security tab -> Use Default


    + Serveur :
    --------------
    DCOMCNFG.EXE -> Selection du composant ScadaOPCServer -> Proprietes -> Security tab -> Use Default



    Des idees ????

    Merci !!!

  8. #8
    Membre actif Avatar de Grulim
    Profil pro
    Inscrit en
    Juillet 2004
    Messages
    234
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2004
    Messages : 234
    Points : 288
    Points
    288
    Par défaut Re: [COM]remote component
    Citation Envoyé par aurel89
    2-> Identity tab -> Selection de Interactive User
    L'utilisateur est-il connu du serveur (est-il déclaré dans le domaine ? le poste aussi ? quel OS ?)
    Citation Envoyé par aurel89
    3-> Security tab -> Use Default
    Pour voir, j'essaierai de mettre 'None' sur le client ET le serveur.

    Bonne chance !

  9. #9
    Membre habitué

    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    26
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : Canada

    Informations forums :
    Inscription : Décembre 2005
    Messages : 26
    Points : 145
    Points
    145
    Par défaut Alternative
    Salut,
    moi aussi j'essaie d'accéder à un serveur OPC pour y lire des données, et j'ai peut être ûne piste pour te simplifier la vie si ton serveur tourne sous Twincat.

    Si c'est le cas, tu pourras te passer de DCOM qui est connu pour être
    1) ultra dur à configurer (pour pas dire autre chose)
    2) pas sécurisé

    L'astuce consiste à créer une passerelle via Twincat à ton serveur distant, afin que tu traites ton serveur OPC comme s'il était en local.

    Si t'es en twincat je t'envoie la procédure, sinon je peux t'envoyer le peu de doc que j'ai sur la config DCOM.

  10. #10
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Janvier 2005
    Messages : 26
    Points : 14
    Points
    14
    Par défaut [COM]remote component
    Merci a tous pour les idees !!!!

    Alors, etant donne que je ne savais pas trop ou etait le probleme niveau config DCOM, depuis mon PC client, j'ai essaye de me connecter a un autre service utilisant DCOM : j'ai configure ce service sur le serveur et le client (utiliser le service dispo sur le serveur), y ai mis mes droits d'acces, et la ca fonctionne : le client arrive a se connecter au serveur et a faire son boulot normalement.

    Content de cela, j'ai fait de meme pour le serveur OPC : mais la misere, a chaque fois que je tente de me connecter au serveur, j'ai un message d'erreur.

    Donc Nalfouille, je te serais reellement reconnaissant si tu pouvais m'envoyer la procedure de config avec DCOM !!!!!!!

    Merci a tous !

  11. #11
    Membre habitué

    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    26
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : Canada

    Informations forums :
    Inscription : Décembre 2005
    Messages : 26
    Points : 145
    Points
    145
    Par défaut DCOM
    Envoyez moi un mail et je vous renvoie :

    1) ConfigurationDCOM.pdf : décrit comment configurer le composant DCOM dans Windows (attention je ne garantis pas que ça marche, le DCOMM est vraiment TRES DUR à configurer). Ce document est issu de la documentation Twincat, aprés une recherche suivant le mot clef "DCOM". C'est dispo chez ftp://ftp.beckhoff.com/Software/TwinCAT/InfoSystem/All/install/
    332 Mo !
    vaux mieu m'envoyer un mail alors

    2) ConnectionTCProcedure.pdf : s'applique à Twincat, décrit comment accéder à un serveur OPC distant comme s'il était en local.


    : Juste pour savoir, quels sont les composants qui vous permet d'accéder à vos serveurs OPC ? Sont ils gratuits ?

  12. #12
    Membre habitué

    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    26
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : Canada

    Informations forums :
    Inscription : Décembre 2005
    Messages : 26
    Points : 145
    Points
    145
    Par défaut [COM] Documentation pour configuration de COM
    Document issu de "Communicating across Networks Using DCOM"

    en espérant que ça aide.

    OPC Data Control allows you to communicate across networks using Windows NT's Distributed Component Object Model (DCOM). Before you can use OPC Data Control with DCOM, you must use DCOM Configuration to set application properties, such as security and location. On the computer running the OPC Data Control , you must specify the location of the OPC server application (the application which responds to requests from the OPC Data Control) that will be accessed or started. For the OPC server application, you must specify the user account that will have permission to access or start the application, and the user accounts that will be used to run the application.

    Configuring OPC Data Control to Use DCOM

    1. Install the OPC data control on one PC (the client PC) and the OPC server on another (the server PC).

    Configure the server PC as follows:

    2. In the Windows Start menu, select Run..., type in dcomcnfg and click on the "OK" button. This starts the Distributed COM Configuration Properties application. (Or, to open the DCOM Configuration application now, click here: )

    3. In the "Default Properties" tab:

    a) Select "Enable Distributed COM on this computer."

    b) Set the "Default Authentication Level" to "Connect."

    c) Set the "Impersonation Level" to "Identify." (This is the default setting.)

    4. In the "Default Security" tab, for both "Default Access Permissions" and "Default Launch Permissions":

    a.) Click on "Edit Default...".

    b.) In the "Registry Value Permissions" dialog, click on "Add...".

    c.) Select "Everyone" (or the appropriate subset of users) and click on "Add."

    d.) Select "INTERACTIVE" and click on "Add."

    e.) Select "SYSTEM" and click on "Add."

    f.) Click on "OK" to return to the "Registry Value Permissions" dialog.

    g.) Click on "OK" to return to the "Distributed COM Configuration Properties" application.

    5. In the Applications tab, select "Running Class" and click on the "Properties" button.

    6. In the "Running Class Properties" dialog box:

    a.) In the "Security" tab, select "Use custom access permissions" and click on the "Edit" button.

    b.) If "Everyone" (or the appropriate subset of users) is not shown in the Permissions dialog "Name" list, click on the "Add" button. Use the "Add Users and Groups" dialog to add users/groups as required, and return to the "Running Class Properties" dialog box.

    In the "Identity" tab...

    - Select "The interactive user." (That is, the user who is currently logged on to the computer.)

    c.) Repeat steps 6a and 6b for the OPC Server you intend to use; for example, "OPC_WinAC".

    7. Start the OPC server.

    Configure the client PC as follows:

    8. In the Windows Start menu, select Run..., type in dcomcnfg and click on the "OK" button. This starts the Distributed COM Configuration Properties application. (Or, to open the DCOM Configuration application now, click here: )

    9. In the "Default Properties" tab:

    a) Select "Enable Distributed COM on this computer."

    b) Set the "Default Authentication Level" to "Connect."

    c) Set the "Impersonation Level" to "Identify." (This is the default setting.)

    10. In the "Default Security" tab, for both "Default Access Permissions" and "Default Launch Permissions":

    a.) Click on "Edit Default...".

    b.) In the "Registry Value Permissions" dialog, click on "Add...".

    c.) Select "Everyone" (or the appropriate subset of users) and click on "Add."

    d.) Select "INTERACTIVE" and click on "Add."

    e.) Select "SYSTEM" and click on "Add."

    f.) Click on "OK" to return to the "Registry Value Permissions" dialog.

    g.) Click on "OK" to return to the "Distributed COM Configuration Properties" application.

  13. #13
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Janvier 2005
    Messages : 26
    Points : 14
    Points
    14
    Par défaut [COM]remote component
    Merci Nalfouille.


    Mais j'ai trouve le probleme : il s'agissait de configurer le modele de partage et de securite pour les comptes locaux :

    Au cas ou cela pourrait aider :

    Control Panel
    -> Administrative Tools
    -> Local Security Policy :
    Secutity Settings -> Local Policies -> Security Options :
    Network Access : Sharing and security model for local account
    -> Selectionner : Classic - local users authenticate as themselves


    Pour ceux qui arrivent en cours de route, reprenez la demarche que Nalfouille a expose precedemment et si vous constatez des problemes, configurez le modele de partage et de securite pour les comptes locaux.

    Et le tour est joue !!!


    Merci a tous pour les idees et conseils

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [.net 3.5] remoting + com + events
    Par zeavan dans le forum Framework .NET
    Réponses: 0
    Dernier message: 24/10/2009, 21h20
  2. Réponses: 0
    Dernier message: 27/07/2009, 15h00
  3. Réponses: 3
    Dernier message: 11/08/2008, 16h36
  4. Réponses: 1
    Dernier message: 16/07/2008, 14h37
  5. Utilisations de flash remoting et com servers
    Par bolo dans le forum Flash
    Réponses: 8
    Dernier message: 11/07/2006, 10h04

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo