AdfView.cpp
上传用户:hy_wanghao
上传日期:2007-01-08
资源大小:279k
文件大小:5k
- // AdfView.cpp : ADF View Shell namespace extension
- //
- // Written by Bjarke Viksoe (bjarke@viksoe.dk)
- // Copyright (c) 2001 Bjarke Viksoe.
- //
- // Beware of bugs.
- //
- // ADF View - ADF Shell Namespace Extension
- // Copyright(C) 2001 Bjarke Viksoe
- //
- // This program is free software; you can redistribute
- // it and/or modify it under the terms of the GNU General
- // Public License as published by the Free Software Foundation;
- // either version 2 of the License, or (at your option) any
- // later version.
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied
- // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- // See the GNU General Public License for more details.
- //
- #include "stdafx.h"
- #include "resource.h"
- #include <initguid.h>
- CAdfShellModule _Module;
- const CLSID CLSID_Folder = {0x2B3256E4,0x49DF,0x11D3,{0x82,0x29,0x00,0x80,0xAE,0x50,0x90,0x54}};
- const CLSID CLSID_View = {0x2B3256E4,0x49DF,0x11D3,{0x82,0x29,0x00,0x80,0xAE,0x50,0x90,0x55}};
- const CLSID CLSID_VolumeDlg = {0x2B3256E4,0x49DF,0x11D3,{0x82,0x29,0x00,0x80,0xAE,0x50,0x90,0x56}};
- const CLSID CLSID_Drive = {0x2B3256E4,0x49DF,0x11D3,{0x82,0x29,0x00,0x80,0xAE,0x50,0x90,0x57}};
- const CLSID CLSID_DropHandler = {0x2B3256E4,0x49DF,0x11D3,{0x82,0x29,0x00,0x80,0xAE,0x50,0x90,0x58}};
- #include "Folder.h"
- #include "View.h"
- #include "VolumeDlg.h"
- #include "DropHandler.h"
- #include "ShellNewDlg.h"
- BEGIN_OBJECT_MAP(ObjectMap)
- OBJECT_ENTRY(CLSID_Folder, CFolder)
- OBJECT_ENTRY(CLSID_Drive, CFolder)
- OBJECT_ENTRY(CLSID_View, CView)
- OBJECT_ENTRY(CLSID_VolumeDlg, CVolumeDlg)
- OBJECT_ENTRY(CLSID_DropHandler, CDropHandler)
- END_OBJECT_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // DLL Entry Point
- extern "C"
- BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
- {
- if (dwReason == DLL_PROCESS_ATTACH) {
- _Module.Init(ObjectMap, hInstance);
- _Module.m_CFSTR_ADFID = (CLIPFORMAT)::RegisterClipboardFormat(_T("AdfID"));
- CreateImageLists();
- ::DisableThreadLibraryCalls(hInstance);
- }
- else if (dwReason == DLL_PROCESS_DETACH) {
- _Module.Term();
- }
- return TRUE; // ok
- }
- /////////////////////////////////////////////////////////////////////////////
- // Used to determine whether the DLL can be unloaded by OLE
- STDAPI DllCanUnloadNow(void)
- {
- return _Module.GetLockCount()==0 ? S_OK : S_FALSE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Returns a class factory to create an object of the requested type
- STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
- {
- return _Module.GetClassObject(rclsid, riid, ppv);
- }
- /////////////////////////////////////////////////////////////////////////////
- // DllRegisterServer - Adds entries to the system registry
- STDAPI DllRegisterServer(void)
- {
- // Registers object, typelib and all interfaces in typelib
- HRESULT hr;
- _Module.m_adf.SetSilent(TRUE);
- hr = _Module.RegisterServer();
- if( SUCCEEDED(hr) ) {
- // Tell Shell that we've updated assoc. icons
- ::SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
- }
- #ifdef _DEBUG
- // During DEBUG I have found it neat to kill the Explorer
- // during DLL registration under W2K.
- // It is much easier to debug this way because once you
- // start tracing (running) you effectively debug the
- // first instance of Explorer.exe!
- HWND hwndShell = ::FindWindow(_T("Progman"), NULL);
- ::PostMessage(hwndShell, WM_QUIT, 0, 0L);
- //::WinExec("Explorer.exe",SW_SHOW);
- #endif
- return hr;
- }
- /////////////////////////////////////////////////////////////////////////////
- // DllUnregisterServer - Removes entries from the system registry
- STDAPI DllUnregisterServer(void)
- {
- return _Module.UnregisterServer(FALSE);
- }
- /////////////////////////////////////////////////////////////////////////////
- // RUNDLL32 support
- void CALLBACK Install(HWND /*hwndStub*/, HINSTANCE /*hInstance*/, LPSTR /*lpszCmdLine*/, int /*nCmdShow*/)
- {
- if( FAILED( DllRegisterServer() ) ) {
- CResString<64> sText(IDS_INSTALLERROR);
- CResString<64> sCaption(IDS_PROJNAME);
- ::MessageBox(NULL, sText, sCaption, MB_ICONSTOP);
- }
- }
- void CALLBACK Uninstall(HWND hwndStub, HINSTANCE /*hInstance*/, LPSTR lpszCmdLine, int /*nCmdShow*/)
- {
- DllUnregisterServer();
- TCHAR szFmt[] = _T("setupapi.dll,InstallHinfSection DefaultUninstall 132 %s");
- TCHAR szCmd[lengthof(szFmt)+MAX_PATH];
- ::wsprintf(szCmd, szFmt, lpszCmdLine);
- ::ShellExecute(hwndStub, NULL, _T("rundll32.exe"), szCmd, NULL, SW_SHOWMINIMIZED);
- // BUG: This DLL could still be locked when SETUPAPI.DLL attempts to delete it
- }
- void CALLBACK ShellNew(HWND /*hwndStub*/, HINSTANCE /*hInstance*/, LPSTR lpszCmdLine, int /*nCmdShow*/)
- {
- // Show the "Shell New" wizard dialog
- USES_CONVERSION;
- ::InitCommonControls();
- CShellNewDlg dlg;
- dlg._Init(A2CT(lpszCmdLine));
- dlg.DoModal();
- };