Index: src/ch/ch.cpp
===================================================================
diff -u -N -rf6c4389122d92e5f84a509e9be0facebac429151 -rd0fdcc905035e648382256101a3d99f429af6d56
--- src/ch/ch.cpp	(.../ch.cpp)	(revision f6c4389122d92e5f84a509e9be0facebac429151)
+++ src/ch/ch.cpp	(.../ch.cpp)	(revision d0fdcc905035e648382256101a3d99f429af6d56)
@@ -21,7 +21,7 @@
 
 #include "CfgProperties.h"
 #include "MainWnd.h"
-#include "..\common\ipcstructs.h"
+#include "../common/ipcstructs.h"
 #include <Dbghelp.h>
 #include "CrashDlg.h"
 #include "../common/version.h"
@@ -84,7 +84,8 @@
 
 CCopyHandlerApp::CCopyHandlerApp() :
 	m_lfLog(),
-	m_cfgSettings(icpf::config::eIni)
+	m_cfgSettings(icpf::config::eIni),
+	m_piShellExtControl(NULL)
 {
 	m_pMainWindow=NULL;
 
@@ -106,6 +107,12 @@
 		delete m_pMainWindow;
 		m_pMainWnd=NULL;
 	}
+
+	if(m_piShellExtControl)
+	{
+		m_piShellExtControl->Release();
+		m_piShellExtControl = NULL;
+	}
 }
 
 CCopyHandlerApp* GetApp()
@@ -206,6 +213,10 @@
 	// set the exception handler to catch the crash dumps
 	SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter);
 
+	HRESULT hResult = CoInitializeEx(NULL, COINIT_MULTITHREADED);
+	if(FAILED(hResult))
+		AfxMessageBox(_T("Cannot initialize COM, the application will now exit."), MB_ICONERROR | MB_OK);
+
 	// InitCommonControlsEx() is required on Windows XP if an application
 	// manifest specifies use of ComCtl32.dll version 6 or later to enable
 	// visual styles.  Otherwise, any window creation will fail.
@@ -226,7 +237,7 @@
 		return FALSE; 
 	
 	// Get a pointer to the file-mapped shared memory.
-	g_pscsShared=(CSharedConfigStruct*)MapViewOfFile(m_hMapObject, FILE_MAP_WRITE, 0, 0, 0);
+	g_pscsShared=(CSharedConfigStruct*)MapViewOfFile(m_hMapObject, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
 	if (g_pscsShared == NULL) 
 		return FALSE; 
 	
@@ -298,6 +309,32 @@
 		return FALSE;
 	}
 
+	// calculate ch version
+	LONG lCHVersion = PRODUCT_VERSION1 << 24 | PRODUCT_VERSION2 << 16 | PRODUCT_VERSION3 << 8 | PRODUCT_VERSION4;
+
+	// check the version of shell extension
+	LONG lVersion = 0;
+	BSTR bstrVersion = NULL;
+
+	hResult = CoCreateInstance(CLSID_CShellExtControl, NULL, CLSCTX_ALL, IID_IShellExtControl, (void**)&m_piShellExtControl);
+	if(SUCCEEDED(hResult) && !m_piShellExtControl)
+		hResult = E_FAIL;
+	if(SUCCEEDED(hResult))
+		hResult = m_piShellExtControl->GetVersion(&lVersion, &bstrVersion);
+	if(SUCCEEDED(hResult) && lVersion == lCHVersion)
+		hResult = m_piShellExtControl->SetFlags(eShellExt_Enabled, eShellExt_Enabled);
+	if(FAILED(hResult) || lCHVersion != lVersion)
+	{
+		MsgBox(IDS_SHELL_EXTENSION_MISMATCH_STRING);
+
+		if(m_piShellExtControl)
+			m_piShellExtControl->SetFlags(0, eShellExt_Enabled);
+	}
+
+	if(bstrVersion)
+		::SysFreeString(bstrVersion);
+
+	// create main window
 	m_pMainWindow=new CMainWnd;
 	if (!((CMainWnd*)m_pMainWindow)->Create())
 		return FALSE;				// will be deleted at destructor
@@ -307,6 +344,18 @@
 	return TRUE;
 }
 
+bool CCopyHandlerApp::IsShellExtEnabled() const
+{
+	if(m_piShellExtControl)
+	{
+		LONG lFlags = 0;
+		HRESULT hResult = m_piShellExtControl->GetFlags(&lFlags);
+		if(SUCCEEDED(hResult) && (lFlags & eShellExt_Enabled))
+			return true;
+	}
+	return false;
+}
+
 void CCopyHandlerApp::OnConfigNotify(uint_t uiPropID)
 {
 	// is this language
@@ -397,3 +446,15 @@
 		}
 	}
 }
+
+int CCopyHandlerApp::ExitInstance()
+{
+	if(m_piShellExtControl)
+	{
+		m_piShellExtControl->Release();
+		m_piShellExtControl = NULL;
+	}
+	CoUninitialize();
+
+	return __super::ExitInstance();
+}