liang leon
unread,Oct 30, 2011, 2:51:53 AM10/30/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Crashrpt
I found some hints.
For doc/view application , or for simple GUI win32 application
(without mfc),
you must put the install rt code after main windows created. or ,you
will not get ReportRpt work in worker thread.
these code not work
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
CR_INSTALL_INFO ii;
memset(&ii, 0, sizeof(CR_INSTALL_INFO));
ii.cb = sizeof(CR_INSTALL_INFO);
ii.dwFlags = CR_INST_ALL_POSSIBLE_HANDLERS;
ii.pszAppName = _T("MfcTest");
ii.pszAppVersion = _T("1.0.0");
int nResult = crInstall(&ii);
TCHAR szError[256];
crGetLastErrorMsg(szError, 256);
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_CRASHWIN, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance,
MAKEINTRESOURCE(IDC_CRASHWIN));
// Create the worker thread
HANDLE hWorkingThread = ::CreateThread(NULL, 0,
ThreadProc, (LPVOID)NULL, 0, NULL);
// Main message loop:
//int* p = NULL;
//*p = 13; // This results in Access Violation
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
crUninstall();
return (int) msg.wParam;
}
that code will work
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_CRASHWIN, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
CR_INSTALL_INFO ii;
memset(&ii, 0, sizeof(CR_INSTALL_INFO));
ii.cb = sizeof(CR_INSTALL_INFO);
ii.dwFlags = CR_INST_ALL_POSSIBLE_HANDLERS;
ii.pszAppName = _T("MfcTest");
ii.pszAppVersion = _T("1.0.0");
int nResult = crInstall(&ii);
TCHAR szError[256];
crGetLastErrorMsg(szError, 256);
hAccelTable = LoadAccelerators(hInstance,
MAKEINTRESOURCE(IDC_CRASHWIN));
// Create the worker thread
HANDLE hWorkingThread = ::CreateThread(NULL, 0,
ThreadProc, (LPVOID)NULL, 0, NULL);
// Main message loop:
//int* p = NULL;
//*p = 13; // This results in Access Violation
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
crUninstall();
return (int) msg.wParam;
}