BOOL CKontrolaZdarzenApp::InitInstance()
{
//****************************************************************************
// Pocztek dodanego tekstu programu

    DWORD   dwResult;                                 // Wynik tworzenia klucza rejestru.
    CString oData;                                    // Dane przechowywane w rejestrze.
    char    cType[5] = {0x7, 0x0, 0x0, 0x0, 0x0};     // Warto obsugiwanych typw.
    char    cCategory[5] = {0x4, 0x0, 0x0, 0x0, 0x0}; // Obsugiwane kategorie.

// Koniec dodanego tekstu programu
//****************************************************************************
    AfxEnableControlContainer();

    // Standard initialization
    // If you are not using these features and wish to reduce the size
    // of your final executable, you should remove from the following
    // the specific initialization routines you do not need.

    #ifdef _AFXDLL
        Enable3dControls();         // Call this when using MFC in a shared DLL
    #else
        Enable3dControlsStatic();   // Call this when linking to MFC statically
    #endif

//****************************************************************************
// Pocztek dodanego tekstu programu

    // Utwrz lub otwrz klucz rejestru dla zapisywania zdarze.
    RegCreateKeyEx(
        HKEY_LOCAL_MACHINE, 
        "SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\KontrolaZdarzen",
        0,
        NULL,
        REG_OPTION_NON_VOLATILE,
        KEY_ALL_ACCESS,
        NULL,
        &m_hkey,
        &dwResult);

    // Zapisz cig EventMessageFile.
    oData = AfxGetApp()->m_pszHelpFilePath;
    oData.Replace(".HLP", ".EXE");
    RegSetValueEx(
       m_hkey, 
       "EventMessageFile", 
       0, 
       REG_SZ, 
       (BYTE *)oData.GetBuffer(_MAX_PATH), 
       _MAX_PATH + 1);
       oData.ReleaseBuffer(-1);

    // Zapisz TypesSupported DWORD.
    RegSetValueEx(
        m_hkey,
        "TypesSupported",
        0,
        REG_DWORD,
        (BYTE *)cType,
        4);

    // Zapisz cig CategoryMessageFile.
    RegSetValueEx(
        m_hkey, 
        "CategoryMessageFile", 
        0, 
        REG_SZ, 
        (BYTE *)oData.GetBuffer(_MAX_PATH), 
        _MAX_PATH + 1);
    oData.ReleaseBuffer(-1);

    // Zapisz CategoryCount DWORD.
    RegSetValueEx(
        m_hkey,
        "CategoryCount",
        0,
        REG_DWORD,
        (BYTE *)cCategory,
        4);

    // Zamknij klucz po uyciu.
    RegCloseKey(m_hkey);

// Koniec dodanego tekstu programu
//****************************************************************************

    CEventCheckDlg dlg;
    m_pMainWnd = &dlg;
