Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ERROR_SXS_KEY_NOT_FOUND-CreateDispatch fails in createthread

32 views
Skip to first unread message

sudhakar

unread,
Sep 9, 2008, 2:00:01 AM9/9/08
to
Hello ,

I created a MFC Dialog based application and then using class wizard created
Automation classes for excel.

I'm able to call the Automation object using the function CreateDispatch
function and it starts the excel.exe. This is fine. Code is below

void OnRun()
{

COleException *excp = new COleException;
CString s , err;
s.Empty();
//GetDlgItem(IDC_APPEDIT)->GetWindowText(s);
// Start Excel and get Application object...Excel.Application
if( app.CreateDispatch("Excel.Application" , excp) == FALSE )
{
err.Empty();
err.Format(" Error: %d",GetLastError());
AfxMessageBox(err);
}
else
{
//Make Excel Visible and display a message
app.SetVisible(TRUE);
err.Empty();
err.Format("%s is Running!!",s);
AfxMessageBox (err);

}


But the same part of the above code , if it is being called from
CreateThread like the below code, , it returns error code 14007

DWORD dwThreadId;
HANDLE hThread =
CreateThread(0,0,DIAdemInstanceThread,(LPVOID)this,0,&dwThreadId);

DWORD WINAPI DIAdemInstanceThread(LPVOID lpParam)
{
_Application app;
COleException *excp = new COleException;
CString s , err;
s.Empty();
// Start Excel and get Application object...Excel.Application
if( app.CreateDispatch("Excel.Application" , excp) == FALSE )
{
err.Empty();
err.Format(" Error: %d",GetLastError());
AfxMessageBox(err);
}
else
{
//Make Excel Visible and display a message
app.SetVisible(TRUE);
err.Empty();
err.Format("%s is Running!!",s);
AfxMessageBox (err);
}

return 0;
}
Details of the Win32 Error code;
**********************************
14007 - ERROR_SXS_KEY_NOT_FOUND

Description:
************
The requested lookup key was not found in any active activation context

why is this happening ? Please help me out.

thanks ,
Sudhakar

0 new messages