mirror of
https://github.com/tnodir/fort
synced 2024-11-15 07:38:16 +00:00
Add Device.getLastErrorMessage()
This commit is contained in:
parent
350f7837f0
commit
0e4c740859
@ -56,3 +56,22 @@ bool Device::ioctl(int code, char *in, int inSize,
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Device::getLastErrorMessage()
|
||||||
|
{
|
||||||
|
const DWORD err = GetLastError();
|
||||||
|
LPWSTR buf = nullptr;
|
||||||
|
|
||||||
|
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||||
|
| FORMAT_MESSAGE_FROM_SYSTEM
|
||||||
|
| FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
|
NULL, err, 0, (LPWSTR) &buf, 0, NULL);
|
||||||
|
|
||||||
|
if (!buf) {
|
||||||
|
return QString("System Error %1").arg(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString text = QString::fromUtf16((const ushort *) buf).trimmed();
|
||||||
|
LocalFree(buf);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
@ -11,6 +11,8 @@ public:
|
|||||||
explicit Device(QObject *parent = nullptr);
|
explicit Device(QObject *parent = nullptr);
|
||||||
virtual ~Device();
|
virtual ~Device();
|
||||||
|
|
||||||
|
static QString getLastErrorMessage();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
Loading…
Reference in New Issue
Block a user