Code: Select all
;* FormatMessage(messageID)
FormatMessage(messageID) {
if (!length := DllCall("Kernel32\FormatMessage", "UInt", 0x1100, "Ptr", 0, "UInt", messageID, "UInt", 0, "Ptr*", buffer := 0, "UInt", 0, "Ptr", 0, "UInt")) {
return (FormatMessage(DllCall("Kernel32\GetLastError")))
}
return (StrGet(buffer, length - 2), DllCall("Kernel32\LocalFree", "Ptr", buffer, "Ptr"))
}
Code: Select all
if (!DllCall("GetConsoleScreenBufferInfo", "Ptr", 0, "Ptr", 0, "UInt")) {
throw (Exception(Format("0x{:U}", DllCall("msvcrt\_i64tow", "Int64", A_LastError, "Ptr*", 0, "UInt", 16, "Str")), -1, FormatMessage(A_LastError)))
}