错误代码3,-1073741819& -1073741510

时间:2015-07-01 08:11:56

标签: qt error-code qt5.4

运行我的应用程序会给我错误代码3,-1073741819和-1073741510 为什么这些代码一般来? 是什么原因导致他们将自己发送到调试器? 我尝试在Qt Framework中使用QFile处理文件。 我的代码如下(注意这是一个非常低功耗的防病毒解决方案):

QFile VirusScanner(Current);
while(!VirusScanner.atEnd()) {
    QByteArray Line = VirusScanner.readLine(LONG_LONG_MAX);
    if(Line.toLower() == "open=regsvr.exe" || Line.toLower() == "open=newfolder.exe") {
        cout << "Autorun.inf virus detected. Deleteing..." << std::endl;
        const QString Virus_Path = VirusScanner.fileName();
        VirusScanner.close();
        QFile::remove();
    }
}

在Vahancho的评论之后,我将代码更改为以下内容,但它给了我-1073741510错误代码:

QFile VirusScanner(Current);
VirusScanner.open(stdin , QFile::ReadOnly);
while(!VirusScanner.atEnd()) {
    QByteArray Line = VirusScanner.readLine(LONG_LONG_MAX);
    if(Line.toLower() == "open=regsvr.exe" || Line.toLower() == "open=newfolder.exe") {
        cout << "Autorun.inf virus detected. Deleteing..." << std::endl;
        VirusScanner.remove();
    }
} 
VirusScanner.close();

1 个答案:

答案 0 :(得分:0)

您应该使用QTextStream来处理转换,换行字符等...所以 if语句也按预期工作。

此外,如果您想阅读stdin文件,则不应打开Current

鉴于此,这将起作用:

QString current = "some_file";
bool bHasVirus = false;

QFile virusScanner(current);
if (!virusScanner.open(QIODevice::ReadOnly | QIODevice::Text)) {
    return -1;
}

QTextStream in(&virusScanner);
while(!in.atEnd()) {
    QString line = in.readLine();
    qDebug() << line.toLower();
    if(line.toLower() == "open=regsvr.exe" || line.toLower() == "open=newfolder.exe") {
        // Virus detected!
        bHasVirus = true;
        break;
    }
}

if(bHasVirus) {
    qDebug() << "Virus detected. Deleteing...";
    virusScanner.remove(); // Will also close the file
} else {
    virusScanner.close();
}

注意:大写字母通常用于 Classes ,而不是变量