Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi,
I developed a MFC application to use an activeX control. The ocx file is used for barcode reader in a device.
when I add the ocx in my application, two different classes are added to my project.
Here is some codes in my .cpp file for class 1:

...
1) Barcode barcode;
2) barcode.Create(_T("STATIC"), _T("Hi"), WS_CHILD | WS_VISIBLE, CRect(0, 0, 20, 20), this, 1234);
...

When I run the application, an error comes up at line 2.

here is the detail of error:

First-chance exception at 0x7c812aeb in TestBCR.exe: Microsoft C++ exception: COleException at memory location 0x0012f0f0.

This error related to a function named AtlTraceVA.

C#
inline void __cdecl CTrace::TraceV(const char *pszFileName, int nLine,
        DWORD_PTR dwCategory, UINT nLevel, LPCSTR pszFmt, va_list args) const
    {
        AtlTraceVA(m_dwModule, pszFileName, nLine, dwCategory, nLevel, pszFmt, args);
    }


Can someone help me?

Thanks in advance
Ahrost
Posted
Comments
[no name] 5-Jul-14 8:02am    
Did you initialize the COM library before trying to use your component?
Ahrost 5-Jul-14 8:15am    
Dear Wes,
How can I do that?

Thanks
[no name] 5-Jul-14 8:25am    
http://msdn.microsoft.com/en-us/library/windows/desktop/ms695279(v=vs.85).aspx
Ahrost 12-Jul-14 6:27am    
Dear Wes,
Sorry to bother you.
Thanks for your help.
I could initialize the COM library with coInitializeEX() and solve the previous error but I got another error when I call my method in the class. here is the error :
OleInitialize returned scode = RPC_E_CHANGED_MODE ($80010106)

The codes that I use to call the method - ScanBarcode() - is something like this:

FASTBarcode fastbarcode;

bool res = fastbarcode.Create(_T("STATIC"), _T("Hi"), WS_CHILD | WS_VISIBLE, CRect(0, 0, 20, 20), this, 1234);
fastbarcode.ScanBarcode ();

void ScanBarcode()
{
InvokeHelper(0x1, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}

Many Thanks
Ahrost

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900