- Posts: 4
- Thank you received: 0
Online Forums
Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.
Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.
Do not use the Contact page for technical issues.
- Forum
- Discussions
- QuickOPC-Classic in COM
- Reading, Writing, Subscriptions, Property Access
- How to pass a pointer to the CallBack method assigned to an item by "SubscribeMultipleItems" method in VS C++?
How to pass a pointer to the CallBack method assigned to an item by "SubscribeMultipleItems" method in VS C++?
"2)" is exactly what i am trying right now. And thanks for hint with pointer sized variables.
That will definitely help me a lot.
I think i will check the example you mentioned as soon as possible.
Thanks and best regards,
...
p.s.: I could not find how to mark that as "solved", is there some way ?
Please Log in or Create an account to join the conversation.
1) "as is", with help of Win32 API functions that work with VARIANT-s (e.g. msdn.microsoft.com/en-us/library/windows/desktop/ms221673(v=vs.85).aspx ).
2) Using Microsoft C++ "Native COM support" - which is what you are using if you #import the type library. In this case, VARIANT is wrapped as _variant_t (msdn.microsoft.com/en-us/library/x295h94e.aspx ).
3) Using Microsoft ATL; in this case, one uses the CComVariant class (msdn.microsoft.com/en-us/library/ac97df2h.aspx ). Actually, in some our example, we combine ATL with the native COM support, because ATL allows to write the event hooking code better.
4) and obviously the list is open and other methods can be used as well. For example, I am aware that one of our customers have used a portable library called VOLE which has its own encapsulation for VARIANT-s.
Yes, I suggest to use integers to store the pointers. Besides traditional options such as VT_INT or VT_LONG, there are even pointer-sized VARTYPE-s (see msdn.microsoft.com/en-us/library/windows/desktop/ms221170(v=vs.85).aspx ) such VT_INTPTR, VT_UINTPTR that are properly sized to the bitness of the project. It might be even be possible to use VT_PTR, but we have not tested it.
BTW, are you aware of the SubscribeMultipleItems example project for C++ which comes with the product? It does not have the State passing part, but besides that, it is a good starting point.
Best regards
Please Log in or Create an account to join the conversation.
I am not sure if i got everything right so far.
To clarify: That "Object" in C# is transformed into a variant because i #import the ".tlb" files ? I am quite a newbie in that field, and i do not know what really happens behind the scenes ...
What is meant by " ... only one of the options" ??
And you suggest to use the integer values to store the pointers, is that right ?
I' ll have a look at that link.
Thanks and best regards so far,
...
Please Log in or Create an account to join the conversation.
Passing a pointer is therefore a matter of storing it into _variant_t, and then extracting it back. Various _variant_c constructors and other members are described here: msdn.microsoft.com/en-us/library/x295h94e.aspx .
Let me know if you need further help with that.
Best regards
Please Log in or Create an account to join the conversation.
i am not sure, maybe that was posted before ... [EDIT] it was! i just thought it was somehow not transmitted, sorry [/EDIT]
Please Log in or Create an account to join the conversation.
i am using the QuickOPC libraries for few hours now and i wonder how to get a pointer into the CallBack function ...
I tried that while editing the "ExampleCom\CPP\VS2012" ... SubscribeMultipleItems"
The callbacks interface is
STDMETHOD(ItemChanged)(VARIANT varSender, _EasyDAItemChangedEventArgs* pEventArgs)
The thing is that i have read here that one can use the "_EasyDAItemChangedEventArgs* pEventArgs" -> "State" in C# to supply a reference to some object, but it turned out to be a "_variant_t" in C++ and i do not know how to put a pointer into that.
So is there a way to put a pointer somewhere else into the "pEventArgs" ? Or can anyone tell me how to achieve that via a variant ?
I know that i can put my address value into a suitable integer value, but I'd like to avoid that, if possible. Also i did not use globals yet.
Any hint will be greatly appreciated and thanks in advance,
....
Please Log in or Create an account to join the conversation.
- Forum
- Discussions
- QuickOPC-Classic in COM
- Reading, Writing, Subscriptions, Property Access
- How to pass a pointer to the CallBack method assigned to an item by "SubscribeMultipleItems" method in VS C++?