1. 程式人生 > >Qt複製dll到系統盤system32下失敗的解決方法

Qt複製dll到系統盤system32下失敗的解決方法

repairDll(const QString findPath)
{

    QString path = "C:/Windows/System32" ;
   
    if(path.isEmpty())
        return;
    //獲取所選檔案型別過濾器
       QStringList filters;
   //    檔案過濾
      filters<<QString("*.dll");

       //定義迭代器並設定過濾器
   QDirIterator dir_iterator(findPath, filters, QDir::Files | QDir::NoSymLinks,QDirIterator::Subdirectories);
   PVOID OldValue = NULL;
   if( Wow64DisableWow64FsRedirection(&OldValue))
   {

        while(dir_iterator.hasNext())
        {
           dir_iterator.next();
           QFileInfo file_info = dir_iterator.fileInfo();
           QString newFile = path + file_info.fileName();
           if(!QFile::exists(newFile)){
                QFile::copy(file_info.absoluteFilePath(),newFile);
           }
        }
        if(false == Wow64RevertWow64FsRedirection(OldValue))
        {
            return;
        }
    }

}