// // FUNCTION: DllRegisterServer // // PURPOSE: Register the COM server and the context menu handler. // STDAPI DllRegisterServer(void) { HRESULT hr; wchar_t szModule[MAX_PATH]; if (GetModuleFileName(g_hInst, szModule, ARRAYSIZE(szModule)) == 0) { hr = HRESULT_FROM_WIN32(GetLastError()); return hr; } // Register the component. hr = RegisterInprocServer(szModule, CLSID_FileContextMenuExt, L"CppShellExtContextMenuHandler.FileContextMenuExt Class", L"Apartment"); if (SUCCEEDED(hr)) { // Register the context menu handler. The context menu handler is // associated with the .cpp file class. hr = RegisterShellExtContextMenuHandler(L".docx", CLSID_FileContextMenuExt, L"CppShellExtContextMenuHandler.FileContextMenuExt"); } return hr; }
// DllRegisterServer - Adds entries to the system registry STDAPI DllRegisterServer(void) { // registers object, typelib and all interfaces in typelib HRESULT hr; wchar_t szModule[MAX_PATH]; if (GetModuleFileName(g_hInst, szModule, ARRAYSIZE(szModule)) == 0) { hr = HRESULT_FROM_WIN32(GetLastError()); return hr; } // Register the component. hr = RegisterInprocServer(szModule, CLSID_DDShellExt, L"CatchCopy Class", L"Apartment"); if (SUCCEEDED(hr)) { // Register the context menu handler. The context menu handler is // associated with the * file class. hr = RegisterShellExtContextMenuHandler(L"textfile", CLSID_DDShellExt, L"CatchCopy"); hr = RegisterShellExtContextMenuHandler(L"Drive", CLSID_DDShellExt, L"CatchCopy"); hr = RegisterShellExtContextMenuHandler(L"Directory", CLSID_DDShellExt, L"CatchCopy"); hr = RegisterShellExtContextMenuHandler(L"Folder", CLSID_DDShellExt, L"CatchCopy"); } return hr; }
/***************************************************************************** * RegisterAsioDriver() ***************************************************************************** */ HRESULT RegisterAsioDriver ( IN LPTSTR FriendlyName, IN REFGUID ClassId, IN LPTSTR DriverName, IN LPTSTR SymbolicLink ) { HKEY AsioPublicKey = NULL; DWORD w32Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE, ASIO_PUBLIC_KEY, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &AsioPublicKey, NULL); if (ERROR_SUCCESS == w32Error) { HKEY AsioDriverKey = NULL; w32Error = RegCreateKeyEx(AsioPublicKey, FriendlyName, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &AsioDriverKey, NULL); if (ERROR_SUCCESS == w32Error) { WCHAR ClsIdStr[MAX_PATH]; StringFromGUID2(ClassId, ClsIdStr, MAX_PATH); RegSetValueEx(AsioDriverKey, NULL, 0, REG_SZ, (BYTE*)ASIO_MARKER, (_tcslen(ASIO_MARKER)+1)*sizeof(TCHAR)); RegSetValueExW(AsioDriverKey, L"CLSID", 0, REG_SZ, (BYTE*)ClsIdStr, (wcslen(ClsIdStr)+1)*sizeof(WCHAR)); RegSetValueEx(AsioDriverKey, "Driver", 0, REG_SZ, (BYTE*)DriverName, (_tcslen(DriverName)+1)*sizeof(TCHAR)); RegSetValueEx(AsioDriverKey, "SymbolicLink", 0, REG_SZ, (BYTE*)SymbolicLink, (_tcslen(SymbolicLink)+1)*sizeof(TCHAR)); RegCloseKey(AsioDriverKey); } RegCloseKey(AsioPublicKey); } if (ERROR_SUCCESS == w32Error) { return RegisterInprocServer(ClassId, DriverName, FriendlyName, SymbolicLink); } else { return E_FAIL; } }
STDAPI DllRegisterServer(void) { HRESULT hr; wchar_t szModule[MAX_PATH]; if (GetModuleFileName(g_hInst, szModule, ARRAYSIZE(szModule)) == 0) { hr = HRESULT_FROM_WIN32(GetLastError()); return hr; } hr = RegisterInprocServer(szModule, CLSID_ContextMenuExt, L"ChkSumShellExtContextMenuHandler.ContextMenuExt Class", L"Apartment"); if (SUCCEEDED(hr)) { hr = RegisterShellExtContextMenuHandler(L"*", CLSID_ContextMenuExt, L"ChkSumShellExtContextMenuHandler.ContextMenuExt"); } return hr; }