|
Hi
The COM interfaces in my application derive from IUnknown. But some interface functions are declared using the "THIS_" parameter, some with "THIS" and some with none. For example:
1. STDMETHOD(DoBlah1) (THIS_ UINT uNum) PURE;
2. STDMETHOD(DoBlah2) (UINT uNum) PURE;
3. STDMETHOD(DoBlah3) (THIS_) PURE;
4. STDMETHOD(DoBlah4) (THIS) PURE;
5. STDMETHOD(DoBlah5) () PURE;
I would like to know whether the "THIS_" or "THIS" keywords are necessary, and what would be the difference between these functions.
(I couldn't find the definitions of THIS or THIS_ in the VC browser or on the net... )
Cheers
d3m0n
|
|
|
|
|
THIS_ , THIS and PURE are macros defined in basetyps.h and objbase.h. They are used for portability reasons with plain C, thus the code will compile with a C-compiler if written correctly.
Have a look at Jeff Glatt's article serie about COM in plain C. You'll find the first article here[^].
You'll find the other parts, 2 to 8, in various chapters below the COM section here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thank you very much Roger, that is a perfect answer for me.
I'll ensure that all my interfaces contain the THIS_ and THIS macros.
Cheers
d3m0n
|
|
|
|
|
I am using capicom and doing the encryption , the algorithm is 3DES. I am encryting a value and using this value I am doing an encryted login to a site.
I have set the source of the iframe as this url , in which the encrypted value is passed as a query string.
My problem is , I am able to view the page some times and other insatnces I get a "Page Cannot be displayed " message i.e. Error 404 .
Is this due to some problem in encrytion or decrytion. Or is it due to something that is related a .Net while doin an encrypted login.
I am not sure how to trace at who's end the problem is.
Have any body faced a problem like this, please help
Thanks in advance
|
|
|
|
|
在一个COM事件中,有这么个事件接口
dispinterface _IATLDiceObjEvents
{
properties:
methods:
[id(1)] void Test([in]double x, [in] double y);
};
然而在我的事件接收代码中,得到的x,y值是不是原来激发时所传递的.
接收事件的是一个ATL的对话框类,代码如下:
// MyDialog.h : Declaration of the CMyDialog
#ifndef __MYDIALOG_H_
#define __MYDIALOG_H_
#include "resource.h" // main symbols
#include <atlhost.h>
#import "E:\AtlOcx\Debug\AtlOcx.dll" raw_interfaces_only, raw_native_types, no_namespace, named_guids
/////////////////////////////////////////////////////////////////////////////
// CMyDialog
class CMyDialog :
public CAxDialogImpl<cmydialog>,
public IDispEventImpl<idc_atldiceobj1, cmydialog="">//,&DIID__IATLDiceObjEvents,&LIBID_ATLOCXLib, 1, 0>
{
public:
CMyDialog()
{
m_pATLDiceObj = NULL;
}
~CMyDialog()
{
}
enum { IDD = IDD_MYDIALOG };
BEGIN_MSG_MAP(CMyDialog)
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
COMMAND_HANDLER(IDC_OPEN_BUTTON, BN_CLICKED, OnClickedOpen_button)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
END_MSG_MAP()
// Handler prototypes:
// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
LRESULT OnLButtonDblClk(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return 0;
}
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
AtlAdviseSinkMap(this, TRUE);// 增加监听连接
return 1; // Let the system set the focus
}
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
AtlAdviseSinkMap(this, FALSE);
EndDialog(wID);
return 0;
}
public :
BEGIN_SINK_MAP(CMyDialog)
//Make sure the Event Handlers have __stdcall calling convention
SINK_ENTRY(IDC_ATLDICEOBJ1, 0x1, OnTest)
END_SINK_MAP()
HRESULT __stdcall OnTest(DOUBLE x, DOUBLE y)
{
CComVariant varResult;
// TODO : Add Code for event handler.
// here x,y is changed.
return varResult.scode;
}
};
#endif //__MYDIALOG_H_
请问为什么在事件触发中,参数类型为'double'的数据会发生变化?
Thanks in advance!
|
|
|
|
|
Hai,
Plz anyone give the solution for ,How to install .dll files in the windows Registry using Regsvr32 ?
Please Clearly state the steps for installation.
|
|
|
|
|
senthil_rajesh wrote: How to install .dll files in the windows Registry using Regsvr32
Is your dll is self registrable dll(COM dll) ?
If yes, then from command line you need to use regsvr32 "dll path" .
|
|
|
|
|
I also did like that ,but error message occured that " .dll was loaded but unable to find the Entry point.so it was unable to registered.".
|
|
|
|
|
I asked you , whether your dll is self registrable ? If yes, then only you can use Regsvr32 .
Make sure, there is function DllRegistrServer present in your code. Make sure, you are giving valid path using "\\".
|
|
|
|
|
Actually i got the software which contains .dll and an .exe files ,how to find that .dll files is self registerable or not?.i want to execute the software through the HTML Link in ASP.NET.Plz guide me.
|
|
|
|
|
In case of dlls, its not needed to register it. In case of COM dlls only it is needed. At least you can ask this from person, you got this software from.
If its a COM dlls, use dependency walker to see exported function, there should be function DllRegisterServer .
|
|
|
|
|
The Software is SIM card Reader.We are creating the Real time WebApplication for the Mobile users.In particular Asp.net Page Having a link Which Calls that sIM CARD Reader Software.But the error was created that (one of the dll).dll was required.But that dll already with in that folder.we are get confused.plz suggest me a suitable solution to run that software in asp.net page link.
|
|
|
|
|
Have you used dependency walker as said in previous reply ?
Dependency walker will be presented in VS--> visual studio tools .
|
|
|
|
|
ya,using dependency walker i able to open an .dll file.how to register?,what is the use of dependency walker?.i didn't work before related to .dll files.
|
|
|
|
|
|
Hi
Tell me some books which is suitable for begineers in COM,
and it contians only COM concepts.
Beacuse many books introduce COM in last three Chapter.
When I read them ,its really teadious to understand what they are coming to say.
Please dont say any e books or search in googlee.
Please help me.
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
Inside COM by Dale Rogerson[^]
Essential COM by Don Box[^]
There also the Beginners section on COM here at CodeProject here[^] if you want to learn how to do COM.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Outstanding, thanks! I just came across some stuff I have to do in COM and this will help greatly. The timing is incredible!
Mike Poz
|
|
|
|
|
Hello,
"COM+ Programming: A Practical Guide Using Visual C++ and ATL" by Pradeep Tapadiya is the best.
Regards
|
|
|
|
|
Ok, I plead guilty for using global variables in a COM project of mine.
I know global variables are bad but sometimes it's hard to avoid.
My question is: Can I have some "global in the instance scope only" kind of variables? That is, inside the instance the variables are global, every class can see them. But each instance of the object has its own set of individual "global" variables.
Is it possible to work around this?
__________________________
S.C.
|
|
|
|
|
To me this sounds like a contradiction in terms: if “each instance of the object has its own set of individual "global" variables” then they're not global!?!?
Steve
|
|
|
|
|
S.C.Wong wrote: My question is: Can I have some "global in the instance scope only" kind of variables? That is, inside the instance the variables are global, every class can see them. But each instance of the object has its own set of individual "global" variables.
Do you write global to mean public ?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
No. I mean a global variable which doesn't belong to any class. (Quite similar to a static variable. ) Like the "theApp" variable in those wizard-generated MFC project.
Lets say I have an ActiveX control called MyCtrl.
Now I insert two of MyCtrl in an dialog:
CMyCtrl1 m_ctrl1;
CMyCtrl2 m_ctrl2;
And somewhere in MyCtrl there is a global variable int g_nVariable.
The global(or static) variable g_nVariable is shared by m_ctrl1 and m_ctrl2. There is only one copy of g_nVariable.
All I want is a global variable, but of which each instance og the control has its own copy.
If I can get a pointer to the "active instance of COleControl", I can solve the problem too.
Sorry for my lousy English as it's not my first language and I am too frustrated...
__________________________
S.C.
|
|
|
|
|
Why don't you use just a class member static variable?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
S.C.Wong wrote: All I want is a global variable, but of which each instance og the control has its own copy.
Again I ask the question: if each instance has its own copy how is it global since, by definiton, all instances share the same globals?
Steve
|
|
|
|