about casting
Hello!
I have a COM dll where I have some problem with casting for one method.
Below you see a signature for method InitRules2 which is a method that is
located in the COM dll and is called from C# asp.net web application.
STDMETHODIMP CSyntaxObj::InitRules2(IHandle_DS* handle_ds, BSTR Provider,
BSTR DataSource, BSTR UserId, BSTR Password, BSTR ProductID, BSTR Revision,
BSTR ApplicationID, BSTR ApplicationRev, BSTR SubfileID, VARIANT_BOOL *bRes)
{
....
Handle_DS* m_handle_DS = handle_ds;
....
}
I create this object handle_ds from C# by calling C-tor in the COM dll. This
object is then passed from C# as the first parameter in method InitRules2
as you can see.
Here its called handle_ds and is of type Handle_DS.
In this method InitRules2 I want to let object m_handle_DS points to the
handle_ds parameter that is passed in.
But when I do this I get the following compile error
C:\Projects\DTHTool\VSS\DTHToolObjects\SyntaxObj.cpp(245) : error C2440:
'initializing' : cannot convert from 'struct IHandle_DS *' to 'class
Handle_DS *'
Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
I have also tried this construction but it caused compile error.
Handle_DS* m_handle_DS = (Handle_DS)handle_ds;
When I run the code without the statement that cause compile error I can
step into this method InitRules2.
Does anybody have some good solution to my problem.
//Tony