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,但是執行時報錯。
uj5u.com熱心網友回復:
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
uj5u.com熱心網友回復:
崩潰的時候在彈出的對話框按相應按鈕進入除錯,按Alt+7鍵查看Call Stack即“呼叫堆疊”里面從上到下列出的對應從里層到外層的函式呼叫歷史。雙擊某一行可將游標定位到此次呼叫的源代碼或匯編指令處,看不懂時雙擊下一行,直到能看懂為止。uj5u.com熱心網友回復:
那個報錯的彈窗截圖一直上傳不上來,g_cdma的功能都沒問題,就是回呼不太明白怎么回呼的,報錯提示是Access violation at address 101EF9A2 in module 'mfc120ud.dll',Read of address 00000021uj5u.com熱心網友回復:
僅供參考: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
uj5u.com熱心網友回復:
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/98254.html
