// 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(); }
// 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); }
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)
#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 . . . . . .
// 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(); }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionvoid 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"); }
pFastAddAlgorithm.CreateInstance( __uuidof( MYLib::MyInterface));
// 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(); }
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)
#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(); }
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)
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"); } }