Problème d'utilisation d'une DLL de type COM au niveau d'un programe C++

cs_japouni Messages postés 22 Date d'inscription jeudi 27 avril 2006 Statut Membre Dernière intervention 29 mai 2014 - 28 févr. 2013 à 11:51
cs_japouni Messages postés 22 Date d'inscription jeudi 27 avril 2006 Statut Membre Dernière intervention 29 mai 2014 - 5 mars 2013 à 21:09
onjour,

J'ai une dll de type COM (elle expose les quatre fonctions DllGetClassObject(), DllCanUnloadNow(), DllRegisterServer() et DllUnregisterServer()).

Comment je peut utiliser les autres fonctions via "Bibliothèque de types définissant les interfaces COM" de cette DLL au niveau d'un programme C++(je ne peut pas accéder au fonction directement par simple LoadLibrary et GetProcAddress).

J'ai ajouter un #import "path de mydll" au niveau du fichier .cpp et il y'a les fichiers .tlh et .tli qui sont générer automatiquement avec les non des interfaces et des méthodes de la dll.

mais mon problème c'est comment initialisé et appelé ces méthodes au niveau de mon .cpp.


J'ai déjà utiliser cette DLL sans aucun problème au niveau d'un programme VB par simple ajout de cette DLL comme REF au projet.

code au niveau VB (pour l'accée au fonction de la dll) :
Dim myclasse As New myREFDLL.myclasse
myclasse.myfonction


Merci par avance pour votre aide.

11 réponses

yann_lo_san Messages postés 1137 Date d'inscription lundi 17 novembre 2003 Statut Membre Dernière intervention 23 janvier 2016 26
1 mars 2013 à 20:40
Salut,

normalement VS crée une classe "wrapper" basé sur le tli et tlh,
mais on peut utiliser sans avec un code du style :

// dans le tlh (inclu par le tli) :
struct __declspec(uuid("00000550-0000-0010-8000-00aa006d2ea4"))
/* dual interface */ _leTypePtr;

// dans le main
#include <ole2.h>
#import "C:\...\....dll"

main()
{
    CoInitialize(NULL);
    _leTypePtr p = NULL;
    p.CreateInstance(__uuidof(_leTypePtr));
    _leTypePtr->Method();
}


bye...
0
cs_japouni Messages postés 22 Date d'inscription jeudi 27 avril 2006 Statut Membre Dernière intervention 29 mai 2014
1 mars 2013 à 23:27
Merci beaucoup pour votre réponse je testerais ta solution encore merci
0
cs_japouni Messages postés 22 Date d'inscription jeudi 27 avril 2006 Statut Membre Dernière intervention 29 mai 2014
4 mars 2013 à 09:44
Bonjour,

Encore merci pour votre réponse.J'ai toujours un problème j'arrive même pas a compiler ma classe .cpp .Ci joint le détails de mon code (mon .cpp les erreurs de compilation et mon .tlh).


>>>>>>>>>Code au niveau de ma classe cpp:

// dans le main
#include <ole2.h>
#include "stdafx.h"
#import "E:\\Program Files\\BFI\\APICapture\\MYdll.dll"
struct __declspec(uuid("504569d4-7746-11d4-a428-0010b5463a40"))
/* dispinterface */ IMyInterface;
void main()
{ 
    CoInitialize(NULL);
    IMyInterface p = NULL;
    p.CreateInstance(__uuidof(IMyInterface));	
   IMyInterface->MYMETHODE1(0);

}


>>>>>>>>>>>>Erreurs:(pourtant quand je clique sur "gotoDeffinition.." au niveau " IMyInterface" dans le fichier cpp il mouvre bien le tlh' )

E:\2012_Projects\test sur les dll\tt\tt.cpp(15) : error C2079: 'p' uses undefined struct 'IMyInterface' 
E:\2012_Projects\test sur les dll\tt\tt.cpp(16) : error C2228: left of '.CreateInstance' must have class/struct/union type
E:\2012_Projects\test sur les dll\tt\tt.cpp(18) : error C2143: syntax error : missing ';' before '->'
E:\2012_Projects\test sur les dll\tt\tt.cpp(18) : error C2143: syntax error : missing ';' before '->'
Error executing cl.exe.

tt.exe - 4 error(s), 0 warning(s)



>>>>>>>>>MYdll.tlh:

#pragma once
#pragma pack(push, 8)

#include <comdef.h>

namespace MYLib {

//
// Forward references and typedefs
//

struct __declspec(uuid("504569d4-7746-11d4-a428-0010b5463a40"))
/* dispinterface */ _IMyInterfaceEvents;
struct /* coclass */ MyInterface;
struct __declspec(uuid("504569d3-7746-11d4-a428-0010b5463a40"))
/* dual interface */ IMyInterface;
struct __declspec(uuid("9f78474f-773d-11d4-a428-0010b5463a40"))
/* dual interface */ IAutreInterface;

//
// Smart pointer typedef declarations
//

_COM_SMARTPTR_TYPEDEF(_IMyInterfaceEvents, __uuidof(IDispatch));
_COM_SMARTPTR_TYPEDEF(IMyInterface, __uuidof(IAPICapture));
_COM_SMARTPTR_TYPEDEF(IAutreInterface, __uuidof(ICheque));

//
// Type library items
//

struct __declspec(uuid("504569d4-7746-11d4-a428-0010b5463a40"))
_IMyInterfaceEvents: IDispatch
{};

struct __declspec(uuid("f6479964-37cb-11d4-a40c-0010b5463a40"))
MyInterface;
    // [ default ] interface IMyInterface
    // [ default, source ] dispinterface _IMyInterfaceEvents

struct __declspec(uuid("504569d3-7746-11d4-a428-0010b5463a40"))
IMyInterface: IDispatch
{
    //
    // Property data
    //

    __declspec(property(get=GetDsn,put=PutDsn))
    _bstr_t Dsn;
    __declspec(property(get=GetUser,put=PutUser))
    _bstr_t User;
    __declspec(property(get=GetPassWord,put=PutPassWord))
    _bstr_t PassWord;

    //
    // Wrapper methods for error-handling
    //

    int MYMETHODE1 (
        int Type );

Ensemble de méthode de l'interface
.
.
.
.
.
.
0
yann_lo_san Messages postés 1137 Date d'inscription lundi 17 novembre 2003 Statut Membre Dernière intervention 23 janvier 2016 26
4 mars 2013 à 19:46
Salut,

Pas la peine de redéclarer les struct,
De plus j'avais fait une erreur de saisie sur IMyInterface->Method();
il faut utiliser le pointeur alloué p.
De plus tu utilises un namespace, il faut l'utiliser
essayes ça :

// a mettre dans "stdafx.h"
///////////////#include <ole2.h> 
///////////////#import "E:\\Program Files\\BFI\\APICapture\\MYdll.dll"

// dans le main
#include "stdafx.h"

void main()
{ 
    CoInitialize(NULL);

    MYLib::IMyInterface p = NULL;
    p.CreateInstance(__uuidof(MYLib::IMyInterface));	

    p->MYMETHODE1(0);

    /// p->Release();  // a voir si utile

    CoUninitialize();
}


bye...
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_japouni Messages postés 22 Date d'inscription jeudi 27 avril 2006 Statut Membre Dernière intervention 29 mai 2014
4 mars 2013 à 21:33
Merci beaucoup je le testerai demain matin(j ai pas acces a mon Pc maintenant)encore merci pour votre aide vous me sauvez je suis perdu avec le c++ et les dll.
0
cs_japouni Messages postés 22 Date d'inscription jeudi 27 avril 2006 Statut Membre Dernière intervention 29 mai 2014
5 mars 2013 à 10:59
Bonjour ;

j'ai testé le code que vous avez proposer mais j'ai toujours des erreurs de compilation.J'ai aussi testé un autre code et j'ai plus des erreurs de compilation mais j'ai un échec d'initialisation de la classe.

1.1. le code que j'ai testé dont l'échec d'initialisation de la classe:


void main()
    {
 
  printf("Start");  
   HRESULT hrfromcoinit = E_FAIL;	 
   HRESULT hRes= E_FAIL;

   int retVal=0;
   hrfromcoinit = CoInitialize(NULL);


if(SUCCEEDED(hrfromcoinit)) {
 printf("success to CoInitialize");
}else{
 printf("Failed to CoInitialize");
}

  MYLib::IMyInterfacePtr pFastAddAlgorithm;
    //
    //IAddPtr is not the actual interface IAdd, but a template C++ class (_com_ptr_t)
    //that contains an embedded instance of the raw IAdd pointer
    //While destructing , the destructor makes sure to invoke Release() on the internal
    //raw interface pointer. Further, the operator -> has been overloaded to direct all
    //method invocations to the internal raw interface pointer.
    //

    pFastAddAlgorithm.CreateInstance( __uuidof( MYLib::IMyInterfacePtr));
 //j'ai aussi testé pFastAddAlgorithm.CreateInstance( __uuidof( //MYLib::IMyInterface));  et pFastAddAlgorithm.CreateInstance( __uuidof( //MYLib::MyInterface));

if(SUCCEEDED(hRes))
 {  printf("success to Create Instance");
  retVal = pFastAddAlgorithm->InitScanner(0);
  printf("success to Create Instance%i",retVal);
 }
 else
 {
 printf("Failed to Create Instance");
  
}
  
 


1.2. Résultat:
- "Start success to CoInitialize Failed to Create Instance".
-Quand je fait appelle a la classe directement (code1) :"Start success to CoInitialize" aprés un message d'erreur "Cette application n'a pas pu démarrer car LTEFX13N.dll est introuvable.La réinstalation de cette....." et quand je valide le message d'erreur il complété "Failed to Create Instance" sur la console.

code1:
pFastAddAlgorithm.CreateInstance( __uuidof( MYLib::MyInterface));



2.1. le code de votre proposition:

// a mettre dans "stdafx.h"
///////////////#include <ole2.h> 
///////////////#import "E:\\Program Files\\BFI\\APICapture\\MYdll.dll"

// dans le main
#include "stdafx.h"

void main()
{ 
    CoInitialize(NULL);

    MYLib::IMyInterface p = NULL;
    p.CreateInstance(__uuidof(MYLib::IMyInterface));	

    p->MYMETHODE1(0);

    /// p->Release();  // a voir si utile

    CoUninitialize();
}



2.2. Erreurs de compilation:

E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : error C2259: 'IMyInterface' : cannot instantiate abstract class due to following members:
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(49) : see declaration of 'IMyInterface'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall IUnknown::QueryInterface(const struct _GUID &,void ** )' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\include\unknwn.h(109) : see declaration of 'QueryInterface'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'unsigned long __stdcall IUnknown::AddRef(void)' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\include\unknwn.h(113) : see declaration of 'AddRef'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'unsigned long __stdcall IUnknown::Release(void)' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\include\unknwn.h(115) : see declaration of 'Release'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall IDispatch::GetTypeInfoCount(unsigned int *)' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\include\oaidl.h(2697) : see declaration of 'GetTypeInfoCount'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall IDispatch::GetTypeInfo(unsigned int,unsigned long,struct ITypeInfo ** )' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\include\oaidl.h(2700) : see declaration of 'GetTypeInfo'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall IDispatch::GetIDsOfNames(const struct _GUID &,unsigned short ** ,unsigned int,unsigned long,long *)' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\include\oaidl.h(2705) : see declaration of 'GetIDsOfNames'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall IDispatch::Invoke(long,const struct _GUID &,unsigned long,unsigned short,struct tagDISPPARAMS *,struct tagVARIANT *,struct tagEXCEPINFO *,unsigned int *)' : pure virtua
l function was not defined
        c:\program files\microsoft visual studio\vc98\include\oaidl.h(2712) : see declaration of 'Invoke'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_MYMETHODE1(int,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(137) : see declaration of 'raw_MYMETHODE1'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_Capture(int,unsigned short *,struct MYLib::ICheque *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(140) : see declaration of 'raw_Capture'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_InitCleFromFile(int,unsigned short *,unsigned short *,unsigned short *,unsigned short ** ,unsigned short ** ,unsigned short ** ,int *
)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(145) : see declaration of 'raw_InitCleFromFile'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_AuthentifierSigner(struct MYLib::ICheque *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(154) : see declaration of 'raw_AuthentifierSigner'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_Controler(unsigned short *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(157) : see declaration of 'raw_Controler'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_SaveDataInFile(int,unsigned short *,struct MYLib::ICheque *,long,long,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(160) : see declaration of 'raw_SaveDataInFile'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_Reconciliation1(unsigned short *,unsigned short *,unsigned short *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(167) : see declaration of 'raw_Reconciliation1'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_Reconciliation2(unsigned short *,unsigned short *,unsigned short *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(172) : see declaration of 'raw_Reconciliation2'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_Reconciliation3(unsigned short *,unsigned short *,unsigned short *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(177) : see declaration of 'raw_Reconciliation3'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_SaveImageInFile(int,int,unsigned short *,struct MYLib::ICheque *,long *,long *,int *)' : pure virtual function was not def
ined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(182) : see declaration of 'raw_SaveImageInFile'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_ConsommerCle(unsigned short *,unsigned short *,unsigned short *,unsigned short *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(190) : see declaration of 'raw_ConsommerCle'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_ChargerClePrivee(unsigned short *,unsigned short ** ,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(196) : see declaration of 'raw_ChargerClePrivee'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_ChargerClePublique(unsigned short *,unsigned short ** ,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(200) : see declaration of 'raw_ChargerClePublique'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::get_Dsn(unsigned short ** )' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(204) : see declaration of 'get_Dsn'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::put_Dsn(unsigned short *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(206) : see declaration of 'put_Dsn'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::get_User(unsigned short ** )' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(208) : see declaration of 'get_User'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::put_User(unsigned short *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(210) : see declaration of 'put_User'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::get_PassWord(unsigned short ** )' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(212) : see declaration of 'get_PassWord'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::put_PassWord(unsigned short *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(214) : see declaration of 'put_PassWord'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_SaveTypeCompteInFile(unsigned short *,struct MYLib::ICheque *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(216) : see declaration of 'raw_SaveTypeCompteInFile'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : error C2259: 'IMyInterface' : cannot instantiate abstract class due to following members:
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(49) : see declaration of 'IMyInterface'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall IUnknown::QueryInterface(const struct _GUID &,void ** )' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\include\unknwn.h(109) : see declaration of 'QueryInterface'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'unsigned long __stdcall IUnknown::AddRef(void)' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\include\unknwn.h(113) : see declaration of 'AddRef'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'unsigned long __stdcall IUnknown::Release(void)' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\include\unknwn.h(115) : see declaration of 'Release'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall IDispatch::GetTypeInfoCount(unsigned int *)' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\include\oaidl.h(2697) : see declaration of 'GetTypeInfoCount'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall IDispatch::GetTypeInfo(unsigned int,unsigned long,struct ITypeInfo ** )' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\include\oaidl.h(2700) : see declaration of 'GetTypeInfo'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall IDispatch::GetIDsOfNames(const struct _GUID &,unsigned short ** ,unsigned int,unsigned long,long *)' : pure virtual function was not defined
        c:\program files\microsoft visual studio\vc98\include\oaidl.h(2705) : see declaration of 'GetIDsOfNames'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall IDispatch::Invoke(long,const struct _GUID &,unsigned long,unsigned short,struct tagDISPPARAMS *,struct tagVARIANT *,struct tagEXCEPINFO *,unsigned int *)' : pure virtua
l function was not defined
        c:\program files\microsoft visual studio\vc98\include\oaidl.h(2712) : see declaration of 'Invoke'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_MYMETHODE1(int,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(137) : see declaration of 'raw_MYMETHODE1'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_Capture(int,unsigned short *,struct MYLib::ICheque *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(140) : see declaration of 'raw_Capture'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_InitCleFromFile(int,unsigned short *,unsigned short *,unsigned short *,unsigned short ** ,unsigned short ** ,unsigned short ** ,int *
)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(145) : see declaration of 'raw_InitCleFromFile'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_AuthentifierSigner(struct MYLib::ICheque *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(154) : see declaration of 'raw_AuthentifierSigner'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_Controler(unsigned short *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(157) : see declaration of 'raw_Controler'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_SaveDataInFile(int,unsigned short *,struct MYLib::ICheque *,long,long,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(160) : see declaration of 'raw_SaveDataInFile'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_Reconciliation1(unsigned short *,unsigned short *,unsigned short *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(167) : see declaration of 'raw_Reconciliation1'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_Reconciliation2(unsigned short *,unsigned short *,unsigned short *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(172) : see declaration of 'raw_Reconciliation2'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_Reconciliation3(unsigned short *,unsigned short *,unsigned short *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(177) : see declaration of 'raw_Reconciliation3'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_SaveImageInFile(int,int,unsigned short *,struct MYLib::ICheque *,long *,long *,int *)' : pure virtual function was not def
ined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(182) : see declaration of 'raw_SaveImageInFile'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_ConsommerCle(unsigned short *,unsigned short *,unsigned short *,unsigned short *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(190) : see declaration of 'raw_ConsommerCle'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_ChargerClePrivee(unsigned short *,unsigned short ** ,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(196) : see declaration of 'raw_ChargerClePrivee'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_ChargerClePublique(unsigned short *,unsigned short ** ,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(200) : see declaration of 'raw_ChargerClePublique'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::get_Dsn(unsigned short ** )' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(204) : see declaration of 'get_Dsn'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::put_Dsn(unsigned short *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(206) : see declaration of 'put_Dsn'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::get_User(unsigned short ** )' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(208) : see declaration of 'get_User'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::put_User(unsigned short *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(210) : see declaration of 'put_User'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::get_PassWord(unsigned short ** )' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(212) : see declaration of 'get_PassWord'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::put_PassWord(unsigned short *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(214) : see declaration of 'put_PassWord'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : warning C4259: 'long __stdcall MYLib::IMyInterface::raw_SaveTypeCompteInFile(unsigned short *,struct MYLib::ICheque *,int *)' : pure virtual function was not defined
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(216) : see declaration of 'raw_SaveTypeCompteInFile'
E:\2012_Projects\test sur les dll\tt\tt.cpp(10) : error C2440: 'initializing' : cannot convert from 'const int' to 'struct MYLib::IMyInterface'
        No constructor could take the source type, or constructor overload resolution was ambiguous
E:\2012_Projects\test sur les dll\tt\tt.cpp(11) : error C2039: 'CreateInstance' : is not a member of 'IMyInterface'
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(49) : see declaration of 'IMyInterface'
E:\2012_Projects\test sur les dll\tt\tt.cpp(13) : error C2819: type 'MYLib::IMyInterface' does not have an overloaded member 'operator ->'
        e:\2012_projects\test sur les dll\tt\debug\MYLib.tlh(49) : see declaration of 'IMyInterface'
E:\2012_Projects\test sur les dll\tt\tt.cpp(13) : error C2227: left of '->MYMETHODE1' must point to class/struct/union
Error executing cl.exe.

tt.exe - 6 error(s), 54 warning(s)



Encore merci pour votre aide.
0
yann_lo_san Messages postés 1137 Date d'inscription lundi 17 novembre 2003 Statut Membre Dernière intervention 23 janvier 2016 26
5 mars 2013 à 13:30
Re,

Les erreurs viennent d'une erreur de frappe :

il faut écrire le ptr avec * :

MYLib::IMyInterface * p = NULL;

bye...
0
cs_japouni Messages postés 22 Date d'inscription jeudi 27 avril 2006 Statut Membre Dernière intervention 29 mai 2014
5 mars 2013 à 14:24
Bonjour,

Toujours des erreurs de compilation :


Code1:
#include "stdafx.h"

void main()
{ 
    CoInitialize(NULL);

    MYLib::IMyInterface* p = NULL; 
 // j'ai aussi tester  MYLib::IMyInterfacePtr* p = NULL; mais toujour la même erreur
    p.CreateInstance(__uuidof(MYLib::IMyInterface));	
// j'ai aussi tester p.CreateInstance(__uuidof(MYLib::IMyInterface*))même erreur
    p->MYMETHODE1(0);

    /// p->Release();  // a voir si utile

    CoUninitialize();
}

Erreur:
Compiling...
tt.cpp
E:\2012_Projects\test sur les dll\tt\tt.cpp(115) : error C2228: left of '.CreateInstance' must have class/struct/union type
Error executing cl.exe.

tt.exe - 1 error(s), 0 warning(s)
0
cs_japouni Messages postés 22 Date d'inscription jeudi 27 avril 2006 Statut Membre Dernière intervention 29 mai 2014
5 mars 2013 à 15:43
yann_lo_san 10000 merci pour votre aide enfin ca marche merci merci merci

void main()
    {
 
  printf("Start");  
   HRESULT hrfromcoinit = E_FAIL;	 
   HRESULT hRes= E_FAIL;

   int retVal=0;
   hrfromcoinit = CoInitialize(NULL);


if(SUCCEEDED(hrfromcoinit)) {
 printf("success to CoInitialize");
}else{
 printf("Failed to CoInitialize");
}

  MYLib::IMyInterface pFastAddAlgorithm;
    //
    //IAddPtr is not the actual interface IAdd, but a template C++ class (_com_ptr_t)
    //that contains an embedded instance of the raw IAdd pointer
    //While destructing , the destructor makes sure to invoke Release() on the internal
    //raw interface pointer. Further, the operator -> has been overloaded to direct all
    //method invocations to the internal raw interface pointer.
    //

  hRes=  pFastAddAlgorithm.CreateInstance( __uuidof(MYLib::MyInterface));
 

if(SUCCEEDED(hRes))
 {  printf("success to Create Instance");
  retVal = pFastAddAlgorithm->MYMETHODE1(0);
  printf("success to Create Instance%i",retVal);
 }
 else
 {
 printf("Failed to Create Instance");
  
}
  
}
0
yann_lo_san Messages postés 1137 Date d'inscription lundi 17 novembre 2003 Statut Membre Dernière intervention 23 janvier 2016 26
5 mars 2013 à 20:07
Salut,

et bien je suis très content pout toi.

Bonne continuation.
0
cs_japouni Messages postés 22 Date d'inscription jeudi 27 avril 2006 Statut Membre Dernière intervention 29 mai 2014
5 mars 2013 à 21:09
Merci beaucoup
0
Rejoignez-nous