com连接点绑定出错

dl7997 2017-05-31 04:19:07
if (g_cdma.ConnectCom(_T("COM")))
{
HRESULT hr;
IConnectionPointContainer* pConnectionPointContainer = NULL;
IConnectionPoint *pConnectionPoint = NULL;
hr = g_cdma.m_lpDispatch->QueryInterface(IID_IConnectionPointContainer, (void**)&pConnectionPointContainer);
hr = pConnectionPointContainer->FindConnectionPoint(__uuidof(ICDMAXEvents), &pConnectionPoint);
DWORD dwCookie;
hr = pConnectionPoint->Advise((IUnknown*)(this), &dwCookie);
g_cdma.GetVersion();
g_cdmaConnected = true;
}
g_cdma为com组件对象,执行各种功能操作,this继承了事件回调接口,Advice()调用时返回值s_ok,但是执行时报错。
...全文
460 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhujinqiang 2017-06-01
  • 打赏
  • 举报
回复
引用 1 楼 zhao4zhong1 的回复:
GetLastError 在64位Windows下: 64位exe和dll在目录c:\windows\system32目录下; 32位exe和dll在目录c:\windows\syswow64目录下; 所以要注意: 在win64位系统下注册32位ocx或dll需要将32位ocx或dll拷贝到c:\windows\syswow64\目录下。 且注册要用c:\windows\syswow64\regsvr32 xxxxxxx.ocx或dll 在win64位系统下设置32位程序使用的数据库别名要用c:\windows\syswow64\cliconfg.exe 在win64位系统下设置32位程序使用的系统DSN要用c:\windows\syswow64\odbcad32.exe 64 位 Windows 平台注意点之文件系统重定向 http://www.cnblogs.com/jiake/p/4981555.html 64 位 Windows 平台注意点之注册表重定向 http://www.cnblogs.com/jiake/p/4956218.html
赵4老师 2017-05-31
  • 打赏
  • 举报
回复
仅供参考: COINIT A set of values from the COINIT enumeration is passed as the dwCoInit parameter to CoInitializeEx. This value determines the concurrency model used for incoming calls to objects created by this thread. This concurrency model can be either apartment-threaded or multi-threaded. The COINIT enumeration is defined as follows: typedef enum tagCOINIT{ COINIT_APARTMENTTHREADED = 0x2, // Apartment model COINIT_MULTITHREADED = 0x0, // OLE calls objects on any thread. COINIT_DISABLE_OLE1DDE = 0x4, // Don't use DDE for Ole1 support. COINIT_SPEED_OVER_MEMORY = 0x8, // Trade memory for speed. } COINIT; Elements COINIT_MULTITHREADED Initializes the thread for multi-threaded object concurrency (see Remarks). COINIT_APARTMENTTHREADED Initializes the thread for apartment-threaded object concurrency (see Remarks). COINIT_DISABLE_OLE1DDE Disables DDE for Ole1 support. COINIT_SPEED_OVER_MEMORY Trades memory for speed. Remarks When a thread is initialized through a call to CoInitializeEx, you choose whether to initialize it as apartment-threaded or multi-threaded by designating one of the members of COINIT as its second parameter. This designates how incoming calls to any object created by that thread are handled, that is, the object's concurrency. Apartment-threading, the default model for earlier versions of Windows NT, while allowing for multiple threads of execution, serializes all incoming calls by requiring that calls to methods of objects created by this thread always run on the same thread – the apartment/thread that created them. In addition, calls can arrive only at message-queue boundaries (i.e., only during a PeekMessage, SendMessage, DispatchMessage, etc.). Because of this serialization, it is not typically necessary to write concurrency control into the code for the object, other than to avoid calls to PeekMessage and SendMessage during processing that must not be interrupted by other method invocations or calls to other objects in the same apartment/thread. Multi-threading (also called free-threading) allows calls to methods of objects created by this thread to be run on any thread. There is no serialization of calls – many calls may occur to the same method or to the same object or simultaneously. Multi-threaded object concurrency offers the highest performance and takes the best advantage of multi-processor hardware for cross-thread, cross-process, and cross-machine calling, since calls to objects are not serialized in any way. This means, however, that the code for objects must enforce its own concurrency model, typically through the use of Win32 synchronization primitives, such as critical sections, semaphores, or mutexes. In addition, because the object doesn't control the lifetime of the threads that are accessing it, no thread-specific state may be stored in the object (in Thread-Local-Storage). QuickInfo Windows NT: Use version 3.1 and later. Windows: Use Windows 95 and later. Requires DCOM95. Windows CE: Unsupported. Header: Declared in objbase.h. See Also CoInitializeEx, Processes and Threads
dl7997 2017-05-31
  • 打赏
  • 举报
回复
引用 1 楼 zhao4zhong1 的回复:
GetLastError

在64位Windows下:
64位exe和dll在目录c:\windows\system32目录下;
32位exe和dll在目录c:\windows\syswow64目录下;
所以要注意:
在win64位系统下注册32位ocx或dll需要将32位ocx或dll拷贝到c:\windows\syswow64\目录下。
且注册要用c:\windows\syswow64\regsvr32 xxxxxxx.ocx或dll
在win64位系统下设置32位程序使用的数据库别名要用c:\windows\syswow64\cliconfg.exe
在win64位系统下设置32位程序使用的系统DSN要用c:\windows\syswow64\odbcad32.exe
64 位 Windows 平台注意点之文件系统重定向 http://www.cnblogs.com/jiake/p/4981555.html
64 位 Windows 平台注意点之注册表重定向 http://www.cnblogs.com/jiake/p/4956218.html
那个报错的弹窗截图一直上传不上来,g_cdma的功能都没问题,就是回调不太明白怎么回调的,报错提示是Access violation at address 101EF9A2 in module 'mfc120ud.dll',Read of address 00000021
赵4老师 2017-05-31
  • 打赏
  • 举报
回复
崩溃的时候在弹出的对话框按相应按钮进入调试,按Alt+7键查看Call Stack即“调用堆栈”里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码或汇编指令处,看不懂时双击下一行,直到能看懂为止
赵4老师 2017-05-31
  • 打赏
  • 举报
回复
GetLastError 在64位Windows下: 64位exe和dll在目录c:\windows\system32目录下; 32位exe和dll在目录c:\windows\syswow64目录下; 所以要注意: 在win64位系统下注册32位ocx或dll需要将32位ocx或dll拷贝到c:\windows\syswow64\目录下。 且注册要用c:\windows\syswow64\regsvr32 xxxxxxx.ocx或dll 在win64位系统下设置32位程序使用的数据库别名要用c:\windows\syswow64\cliconfg.exe 在win64位系统下设置32位程序使用的系统DSN要用c:\windows\syswow64\odbcad32.exe 64 位 Windows 平台注意点之文件系统重定向 http://www.cnblogs.com/jiake/p/4981555.html 64 位 Windows 平台注意点之注册表重定向 http://www.cnblogs.com/jiake/p/4956218.html

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧