零贰'Blog

零贰'Blog - 记录日常点点滴滴..........

在回收站建立隐藏目录

VC6编程VC6
[阅读原文]()
#define D_NODEL_PATH "\\Recycler\\D-%s-19801011-19821106-13875458802-5402...\\"


    CString csDriver, csDPath, csNoDelPath;
    csDriver = m_DiskList.GetItemText(nCurSel, 0);
    csDriver.TrimLeft();csDriver.TrimRight();
    csDPath = csDriver + User.csDiskPath;
    csNoDelPath = csDriver + User.csDiskNoDelPath;
    if(PathFileExists(csDPath))
        MoveFile(csDPath, csNoDelPath);
    CreateDirectory(csNoDelPath, NULL);
    WIN32_FIND_DATA FindFileData;
    FindClose(FindFirstFile(csNoDelPath, &FindFileData));
    DWORD dwFileAttributes = FindFileData.dwFileAttributes;
    CStdioFile stdFile;
    if(!PathFileExists(csNoDelPath))
        return;
    CString csDesktopFilePath = csNoDelPath + "\\Desktop.ini";
    dwFileAttributes = dwFileAttributes & ~CFile::readOnly & ~CFile::hidden & ~CFile::system;
    SetFileAttributes(csDesktopFilePath, dwFileAttributes );
    DeleteFile(csDesktopFilePath);
    stdFile.Open(csDesktopFilePath, CFile::modeCreate|CFile::modeWrite);
    stdFile.WriteString("[.ShellClassInfo]\n");
    stdFile.WriteString("CLSID={645FF040-5081-101B-9F08-00AA002F954E}");
    stdFile.Close();
    dwFileAttributes = dwFileAttributes | CFile::readOnly | CFile::hidden | CFile::system;
    SetFileAttributes(csDesktopFilePath, dwFileAttributes );
    SetFileAttributes(csNoDelPath, dwFileAttributes );