请问有谁有拷贝钩子的例程,我想要一份学习学习。
拜托各位了!

解决方案 »

  1.   

    COPy hook????什么意思?
      

  2.   

    拷贝钩子处理(CopyHook Handler)就是在当你删除,移动,重命名一个文件时由windows Shell调用,它是一种Shell扩展.
      

  3.   

    你查查MSDN不就可以了吗?里面说的很详细的呀,都有例子代码的。好象有个API是SHFileOperation的,可以实现删除,移动,重命名什么的,只要参数合适。很简单的
      

  4.   

    MSDN里没有例子,我需要的是一个完整的实例。
      

  5.   

    SHFileOperation
    Copies, moves, renames, or deletes a file system object. int SHFileOperation(
        LPSHFILEOPSTRUCT lpFileOp
    );
    Parameters
    lpFileOp 
    [in] Address of an SHFILEOPSTRUCT structure that contains information this function needs to carry out the specified operation. 
    Return Values
    Returns zero if successful, or nonzero otherwise. Res
    You should use fully-qualified pathnames with this function. Using it with relative path-names is not thread-safe.With two exceptions, you cannot use SHFileOperation to move special folders from a local drive to a remote computer by specifying a network path. The exceptions are the MyDocs and MyPics folders (CSIDL_PERSONAL and CSIDL_MYPICTURES, respectively).When used to delete a file, SHFileOperation will attempt to place the deleted file in the Recycle Bin. If you wish to delete a file and guarantee that it will not be placed in the Recycle Bin, use DeleteFile.If a copy callback handler is exposed and registered, SHFileOperation will call it unless you set a flag such as FOF_NOCONFIRMATION in the fFlags member of the structure pointed to by lpFileOp. See ICopyHook::CopyCallback for details on implementing copy callback handlers. File deletion is recursive unless you set the FOF_NORECURSION flag in lpFileOp.With Microsoft® Windows 2000® and later, it is possible to connect an HTML file with a folder containing related files such as GIF images or style sheets. If file connection is enabled, when you move or copy the HTML file, all of the files in the folder will be moved or copied as well. Conversely, if you move the folder with the related files, the HTML file is also moved.The HTML file must have a .htm or .html extension. You create the connection to the related files by placing them in a subfolder of the folder containing the HTML file. The folder must have the name of the HTML file followed by " files". For example, if the HTML file is MyFile.htm, the folder should be named "MyFile files". Any files you place in the "MyFile files" subfolder will be connected to MyFile.htm. File connection is enabled by default. It can be disabled by adding a REG_DWORD value, NoFileFolderConnection, to the HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer registry key. Setting NoFileFolderConnection to 1 disables file connection. If the value is set to zero or is missing, file connection is enabled.To move only specified files from a group of connected files, set the FOF_ NO_CONNECTED_ELEMENTS flag in the fFlags member of the structure pointed to by lpFileOp.Note that the use of a folder with a name like "MyFile files" to define a connection may not be valid for localized versions of Windows NT. The term "files" may need be replaced by the equivalent word in the local language.Requirements 
      Version 4.00 and later of Shell32.dll  Windows NT/2000: Requires Windows NT 4.0 or later. 
      Windows 95/98: Requires Windows 95 or later. 
      Header: Declared in shellapi.h. 
      Import Library: shell32.lib.
      

  6.   

    #include <shlobj.h>
    #include <shlwapi.h>main()
    {
        IShellFolder *psfDeskTop = NULL;
        IShellFolder *psfDocFiles = NULL;
        IMalloc *pMalloc = NULL;
        LPITEMIDLIST pidlDocFiles = NULL;
        LPITEMIDLIST pidlItems = NULL;
        IEnumIDList *ppenum = NULL;
        SHFILEOPSTRUCT sfo;
        STRRET strDispName;
        TCHAR szParseName[MAX_PATH];
        TCHAR szSourceFiles[256];
        int i;
        int iBufPos = 0;
        ULONG chEaten;
        ULONG celtFetched;
        HRESULT hr;    pzSourceFiles[0] = '\0';
        hr = SHGetMalloc(&pMalloc);
        hr = SHGetDesktopFolder(&psfDeskTop);    hr = psfDeskTop->ParseDisplayName(NULL, NULL, L"c:\\My_Docs", 
             &chEaten, &pidlDocFiles, NULL);
        hr = psfDeskTop->BindToObject(pidlDocFiles, NULL, IID_IShellFolder, 
             (LPVOID *) &psfDocFiles);
        hr = psfDeskTop->Release();    hr = psfDocFiles->EnumObjects(NULL,SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, 
             &ppenum);    while( (hr = ppenum->Next(1,&pidlItems, &celtFetched)) == S_OK 
           && (celtFetched) == 1)
        {
            psfDocFiles->GetDisplayNameOf(pidlItems, SHGDN_FORPARSING, 
                &strDispName);
            StrRetToBuf(&strDispName, pidlItems, szParseName, MAX_PATH);
            for(i=0;i<=lstrlen(szParseName); i++)
            {
                szSourceFiles[iBufPos++] = szParseName[i];
            }
            pMalloc->Free(pidlItems);
        }
    ppenum->Release();

        szSourceFiles[iBufPos] = '\0';    sfo.hwnd = NULL;
        sfo.wFunc = FO_COPY;
        sfo.pFrom = szSourceFiles;
        sfo.pTo = "c:\\My_Docs2\0";
        sfo.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR;    hr = SHFileOperation(&sfo);

        SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH, (LPCVOID) "c:\My_Docs2", 0);    pMalloc->Free(pidlDocFiles);
        psfDocFiles->Release();    return 0;
    }