Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

Juergen_80

@Juergen_80
About
Posts
18
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • C# COM Server should be called by a C++ client...
    J Juergen_80

    Yes, I've read this page and it works also for another project. But this time I have another one and I don't know exactly how I can go on with this one :-(. Could you take a look at the project I have? Just a few minutes. That would be really great!!!

    COM com help question csharp c++

  • C# COM Server should be called by a C++ client...
    J Juergen_80

    Hi all, I'm absolutely no expert with COM but I have a (maybe very easy) question to you. I have a .dll file and would like to call some functions out of that. So I've created now a .tlb file out of the .dll with the command: regasm XYZ.dll /tlb This worked great and now I could also create the .tlh file out of this .tlb If I add this line in my C++ code: #import "XYZ.tlb" named_guids raw_interfaces_only and recompile the project. That all worked great right now. But now I have the problem how I must call this part in my code to use the functions out of this .dll file? I know that it should work with the CoCreateInstance(...) function but I don't know what parameters I must set there exactly? Maybe I could send to someone my little example and he could help me? I thinks this should be no problem for an expert? In this forum it's not possible to add a little attachment :-(. Thanks for any help!!! Regards, Jürgen

    COM com help question csharp c++

  • Get Events from an COM Server
    J Juergen_80

    Stuart, thanks for your help. Now it seems to work. The problem was that the Connection (Advise) must be done before I open the programm. If I do this Advise after the program start I didn't get any events.

    COM question c++ com sysadmin help

  • Get Events from an COM Server
    J Juergen_80

    I tried it now with the breakpoints. The functions QueryInterface / AddRef and Release (IUnknown) will be called. But all the four IDispatch methods (GetTypeInfoCount / GetTypeInfo / GetIDsOfNames / Invoke) will not be called. So now if I understood you correct, I must implement (call the method) GetIDsOfNames by myself? I tried the implementation of the method GetIDsOfNames a little bit but my application crashed down anytime. Please give me a note if I understood you correctly that the solution must be to implement this function. If so, I must search for some better examples about that and try it again. :-D Thanks for your help.

    COM question c++ com sysadmin help

  • Get Events from an COM Server
    J Juergen_80

    I set now also some breakpoints in the AddRef and QueryInterface Methods. These methods will be called. Only the Invoke function will not be called. Do you know what I can do to test if I did something wrong or if the COM server works correct?

    COM question c++ com sysadmin help

  • Get Events from an COM Server
    J Juergen_80

    The problem I have before is that the Invoke Function will not be called. What must I do that this function will be called from the Server when an event is raised? I can see that an event is raised from the server because an dialog will be opended. But the invoke function will not be called.

    COM question c++ com sysadmin help

  • Get Events from an COM Server
    J Juergen_80

    Hi Stuart, thanks a lot for your reply. Do you know if there will be an example about the invoke theme? I didn't know how this function will/must be called and how my functions then will be called / how I can get a message from the COM server above this invoke functions. I know and I heared also from other people :) that it will be easier to work with ATL. But in this project I can't use ATL.

    COM question c++ com sysadmin help

  • Get Events from an COM Server
    J Juergen_80

    Hi All, now I get connected in my main.cpp file to the server. I hope this will be correct. But how can I get now an event from the server? The server sends some events. I can see that because an Message Dialog will be opened from the server. Now my questions are the following: a) Is the code until now correct? Is it possible to make a test if I get the correct connection or anything else? b) How can I get in the main.cpp an event (OnShowMessageDlg) or any message from the server? Do I need to add something to the sink class? c) Must I add something in the Sink class to get the an event in the invoke function? Or how should this work? Let me know If you need any more information. Once more, thanks for any help. Juergen main.cpp File

    CComPtr<ICWOLE2> tCWOLE;
    HRESULT hr;
    hr = CoInitialize(0);

    hr = CoCreateInstance(CLSID_CWOLEv2, 0, CLSCTX_LOCAL_SERVER, IID_ICWOLE2, (void**)&tCWOLE);
    IConnectionPointContainer * pConnPtContainer;
    hr = tCWOLE->QueryInterface(IID_IConnectionPointContainer,(void**)&pConnPtContainer);
    if(FAILED(hr)){
    CoUninitialize();
    return false;
    }
    CComPtr<IConnectionPoint> ICPoint;
    hr = pConnPtContainer->FindConnectionPoint(DIID_ICWOLEEvents,&m_pConnectionPoint);
    if(FAILED(hr)){
    CoUninitialize();
    return false;
    }

    m_sink = new CSink;
    LPUNKNOWN pUnk = NULL;
    m_sink->QueryInterface(IID_IUnknown,(void**)&pUnk);
    hr = m_pConnectionPoint->Advise(pUnk,&m_sink->cookie);
    if(FAILED(hr)){
    CoUninitialize();
    return false;
    }
    pConnPtContainer->Release();
    .
    .
    .
    // Here I must get the event from the COM Server, but how can this be done???
    // How can I test if I get the information from the correct class??
    .
    .
    .

    m_pConnectionPoint->Unadvise(m_sink->cookie);
    m_pConnectionPoint->Release();
    m_sink->Release();

    CSink.h

    class CSink : public ICWOLEEvents
    {
    public:

    	CSink::CSink() {m\_refCount = 1, cookie = 0;}
    	CSink::~CSink()	{}
    	
    	STDMETHODIMP QueryInterface(REFIID riid, void \*\* ppvObj); //HRESULT \_stdcall
    	STDMETHODIMP\_(ULONG) AddRef();  // Note the underscore
    	STDMETHODIMP\_(ULONG) Release();
    
    	
    	STDMETHODIMP GetTypeInfoCount(UINT \*iTInfo);
    	STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo \*\*ppTInfo);
    	STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR \*\*rgszNames, UINT cNames,  LCID lcid, DISPID \*rgDispId);
    	STDMETHODIMP Invoke(DISPID dispIdMember, 
    						REFIID riid, 
    						LCID lcid,
    						WORD wFlags, DISPPARAMS
    
    COM question c++ com sysadmin help

  • Call an COM Server dispinterface C++
    J Juergen_80

    Is nobody out there who can help me? A link to a complete tutorial or anything else?

    COM c++ com help question csharp

  • Call an COM Server dispinterface C++
    J Juergen_80

    Hi All, I have a little tricky question for you all. Maybe (I hope so) someone can help me with my problem. I work in Visual Studio 2005 with an C++ project. This project does not support ATL + MFC and it should not be changed, if it’s possible. Now I should call an function / get an information out of an COM (.exe) server that is still running. Below you can see the code that was created by the MIDL Compiler / by the OLE/COM Object Viewer from my test_programm.exe(COM server). In the code of the Test.idl file you can see the following: dispinterface ICWOLEEvents { properties: methods: [id(0x00000001)] void OnConfigurationApply([in, out] VARIANT_BOOL* pAccept); [id(0x00000002)] void OnShowMessageDlg( [in] IMsgDlg* pIMsg, [out, retval] VARIANT_BOOL* Result); }; The problem now I have is that I must call / work with the OnConfigurationApply and the OnShowMessageDlg functions in my C++ project. I’ve implemented the three (Test_h.h / Test_i.c / Test.idl) files in my project and I could recompile it without any error messages. Now my questions are: - How can I work with these two functions(OnConfigurationApply and the OnShowMessageDlg) in my C++ project? - Is there anywhere an simple/complete c++ example project? - Can someone explain me how I must start to work / get some information with these functions? I’ve posted a few weeks a similar question. But now after my holiday I will post this question a little bit more detailed again. Let me know if you need any more information about these files. MANY MANY thanks for any hints. Juergen Test_h.h

    .
    .
    .
    MIDL_INTERFACE("6775FB91-B5BE-11D6-A996-0050BA24C7B9")
    ICWOLEEvents : public IDispatch
    {
    };
    .
    .
    .

    Test_i.c //Created with the MIDL Compiler

    .
    .
    .
    MIDL_DEFINE_GUID(IID, IID_ICWOLE2,0xF560F761,0x2948,0x11D7,0xA9,0xBF,0x00,0x50,0xBA,0x24,0xC7,0xB9);
    MIDL_DEFINE_GUID(CLSID, CLSID_CWOLEv2,0xF560F763,0x2948,0x11D7,0xA9,0xBF,0x00,0x50,0xBA,0x24,0xC7,0xB9);
    .
    .
    .

    Test.idl // Generated .IDL file (by the OLE/COM Object Viewer) // // typelib filename: test_programm.exe

    [
    uuid(90B4344B-90CD-4527-BC00-4F4D45C793D6),
    version(2.13),
    helpstring("CW CWOLE")
    ]
    library CW_CWOLE
    {
    // TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
    importlib("stdole2.tlb");

    // Forward declare all types d
    
    COM c++ com help question csharp

  • Using a COM Server in an Visual Studio .vcproj
    J Juergen_80

    Yes, you understand it correct. I want to catch events from this server in the .exe file. At first I worked with an .c / .h / .idl file that have been created from the .exe server. With these I could create an ComPtr and I could call some methods with this pointer. This step works in my old project: CComPtr tCOLE; hr = CoInitialize(0); hr = CoCreateInstance(CLSID_COLEv2, 0, CLSCTX_LOCAL_SERVER, IID_ICOLE2, (void**)&tCOLE); tCole->.... //here I could call the methods out of the ICOLE2. This worked also perfect. Now I had the problem that I must catch also some events from the server. And here I didn't know how I should go on. Some people on different forums called me to work with atl because this should be easier. So now I tried to do that all with ATL. The main problem now is, that I didn't exactly know what I must do. I didn't found anywhere an example / tutorial that explains everything step by step.

    COM tutorial c++ question csharp visual-studio

  • Using a COM Server in an Visual Studio .vcproj
    J Juergen_80

    ok, thanks. Now I made the following steps in Visual Studio: -> Add Class --->Simple ATL-Object with Connection Points. With that the ATL support was added to my project. After that the project could be compiled without any problem. Now I click with the right mouse on the new class I've created with the ATL OBject and choose "Implement interface". With that I can now navigate to the .exe file and implement all the interfaces I need. And now after that I got the following message after I tried to compile it: Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\atlcom.h(1868) : error C2259: 'ATL::CComObject<Base>': Instance of abstract class could not be built1> with 1> [ 1> Base=CEGR_COM 1> ] 1> because of the following member: 1> "HRESULT ICOLE::cSetLanguage(BSTR,VARIANT_BOOL *)": is abstract 1> c:\dev\cw_source\vitra scene\release\configurator.tlh(605): Siehe Deklaration von 'ICOLE::cSetLanguage' 1> "HRESULT ICOLE::cSetDefaultCurrency(BSTR,VARIANT_BOOL *)": ist abstract . . . . . Ok, all these function bodys are now in an TEST_COM.h and in the configurator.tlh file. The TEST_COM.cpp is empty. I don't know why this error message now will come up. The error message will come only for a few of the functions in the .tlh file, not for all. . . . virtual HRESULT __stdcall get_DimensionZ ( /*[out,retval]*/ double * Value ) = 0; virtual HRESULT __stdcall put_DimensionZ ( /*[in]*/ double Value ) = 0; virtual HRESULT __stdcall get_ErrorCode ( /*[out,retval]*/ short * Value ) = 0; virtual HRESULT __stdcall put_ErrorCode ( /*[in]*/ short Value ) = 0; virtual HRESULT __stdcall cInitializeProperties ( ) = 0; // All the functions below will cause an error message virtual HRESULT __stdcall cSetLanguage ( /*[in]*/ BSTR pLanguage, /*[out,retval]*/ VARIANT_BOOL * Result ) = 0; virtual HRESULT __stdcall cSetDefaultCurrency ( /*[in]*/ BSTR pCurrency, /*[out,retval]*/ VARIANT_BOOL * Result ) = 0; virtual HRESULT __stdcall cShowCatalogChooser ( /*[out,retval]*/ VARIANT_BOOL * Result ) = 0; . . . Any ideas?

    COM tutorial c++ question csharp visual-studio

  • Using a COM Server in an Visual Studio .vcproj
    J Juergen_80

    Thanks for your help, Stuart. I try now to implement MFC + ATL support and then I can implement all the COM classes out of the .exe file directly with Visual Studio. Regards, Jürgen

    COM tutorial c++ question csharp visual-studio

  • Using a COM Server in an Visual Studio .vcproj
    J Juergen_80

    I have (I think for some of you) a simple question. I have an .vcproj project (no ATL support and no MFC support) and a I have an .exe file. Within this .exe file should be an COM Server that runs on WinVista. Now I need an connection from my .vcproj project to that COM server. Is there anywhere an step by step tutorial with that I can do such something? I’ve heard in several forums that it is the easiest way to create an ATL project and implement this .exe file. This works also if I create a new ATL project. A new .h file will be created with all the Methods and so on out of the .exe file. But what should I do with an non ATL/MFC supported project? Is there also a way to work with such an project and an COM server? The main problem I have is that I need to work later with some events of the COM server, and this should be also very complicated with no ATL support? It would be nice if someone could send me some information (Step by Step tutorial / simple example how events could be called and so on). I’ve found some things but no complete running example with an event handling. Thanks for any hints. System: WinVista, Visual Studio 2005

    COM tutorial c++ question csharp visual-studio

  • COM Connection Points: Problem to call an function out of an sink class
    J Juergen_80

    If you have timelimits in learning and implementing the task.. This is the main problem. The COM server I must use is an .exe file. Is it the easiest way to create an new ATL project? Is there any Wizard with that I can implement the code from the .exe file / COM server in this new project? Until now I use OleView to create the .idl file from the COM server. Can I then use the files from the ATL project in my C++ project?

    COM com help question c++ sysadmin

  • COM Connection Points: Problem to call an function out of an sink class
    J Juergen_80

    Hi All, I’m an absolutely newbie in the COM technology and I have a little tricky question. I hope there’s someone out there who can help me with my problem. I have an .idl / .h / .c file and I integrated them in my VisualStudio 2005 C++ project. After that I’ve searched on the MSDN Library how I can connect an COM Server from my project. I’ve found a little example (http://msdn.microsoft.com/en-us/magazine/cc163361.aspx) and tried to do it on the same way. I’ve created an Csink class and tried to create an instance of this sink object to pass to the server. Now I want to call an function „ OnShowMessageDlg “ out of this Csink class and after that I’ll become the following error message from my compiler: Linker error: LNK2001: unresolved external symbol public: __thiscall ""public: void __thiscall CSink::OnShowMessageDlg(struct IMsgDlg *,short *)" (?OnShowMessageDlg@CSink@@QAEXPAUIMsgDlg@@PAF@Z)". Can someone give me a hint what there could be wrong? Or what I must do to use these function? Is the .idl file and the .h file correct? I didn’t find the functions OnShowMessageDlg and OnConfigurationApply in the .h file? I know, this should be basics I must know. I hope the two books I’ve ordered will arrive as soon as possible. Please let me know if you need any other information. Thanks for ANY help. Juergen ************************************************************************************************* .idl file . . . // TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046} importlib("stdole2.tlb"); // Forward declare all types defined in this typelib interface ITEST2; dispinterface ITESTEvents; . . . [ uuid(6775FB91-B5BE-11D6-A996-0050BA24C7B9), version(1.1), helpstring("Event dispatch interface for TEST") ] dispinterface ITESTEvents { properties: methods: [id(0x00000001)] void OnConfigurationApply([in, out] VARIANT_BOOL* pAccept); [id(0x00000002)] void OnShowMessageDlg( [in] IMsgDlg* pIMsg, [out, retval] VARIANT_BOOL* Result); }; . . . . coclass TESTv2 { [default] interface ITEST2; [default, source] dispinterface ITESTEvents; }; ************************************************************************************************* .h file . . . EXTERN_C const IID DIID_ITESTEvents; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_I

    COM com help question c++ sysadmin

  • COM Connection Points: Problem to create an instance of an sink object.
    J Juergen_80

    Thanks for your reply. I think, now the next step can be done.

    COM com help question c++ sysadmin

  • COM Connection Points: Problem to create an instance of an sink object.
    J Juergen_80

    Hi All, I’m an absolutely newbie in the COM technology and I have a little tricky question. I hope there’s someone out there who can help me with my problem. I have an .idl / .h / .c file and I integrated them in my VisualStudio 2005 C++ project. After that I’ve searched on the MSDN Library how I can connect an COM Server from my project. I’ve found a little example (http://msdn.microsoft.com/en-us/magazine/cc163361.aspx) and tried to do it on the same way. I’ve created an Csink class and tried to create an instance of this sink object to pass to the server. But the problem now I get from my compiler is the following error message: „error C2259: 'CSink': cannot instantiate abstract class due to following members: 'HRESULT IUnknown::QueryInterface(const IID &,void **)' : is abstract“. The thing I need is that I must call the „ OnShowMessageDlg “ and the „ OnConfigurationApply “ functions out of the .idl file in my main c++ function. I’ve put all the code here below this entry that could help you to become an overview about my problem. Is the solution I’ve tried with the sink object correct or should I use another way to do this? Please let me know if you need any other information. Thanks for ANY help. ************************************************************************************************* .idl file . . . // TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046} importlib("stdole2.tlb"); // Forward declare all types defined in this typelib interface ITEST2; dispinterface ITESTEvents; . . . [ uuid(6775FB91-B5BE-11D6-A996-0050BA24C7B9), version(1.1), helpstring("Event dispatch interface for TEST") ] dispinterface ITESTEvents { properties: methods: [id(0x00000001)] void OnConfigurationApply([in, out] VARIANT_BOOL* pAccept); [id(0x00000002)] void OnShowMessageDlg( [in] IMsgDlg* pIMsg, [out, retval] VARIANT_BOOL* Result); }; . . . . coclass TESTv2 { [default] interface ITEST2; [default, source] dispinterface ITESTEvents; }; ************************************************************************************************* .h file . . . EXTERN_C const IID DIID_ITESTEvents; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("6775FB91-B5BE-11D6-A996-0050BA24C7B9") ITESTEvents : public IDispatch { }; #

    COM com help question c++ sysadmin
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups