Active Forums => Programs => Topic started by: SpriggsySpriggs on February 07, 2021, 12:11:21 am
Title: Inspired by ERRORMESSAGE$: Human readable message from GetLastError (Kernel32)
Post by: SpriggsySpriggs on February 07, 2021, 12:11:21 am
This is something I know practically no one will use because, frankly, no one uses WinAPI around here. It probably won't end up in my API collection as its own file for this reason but I think it is neat enough for its own post, at least. I was inspired by the new ERRORMESSAGE$ keyword and how it displays the readable message for an error code in QB64. I decided to do some digging and found WinAPI has its own version of this with FormatMessage from Kernel32. You can also see I'm using a function from C++, written by Galleon, which I obtained from the MySQL Wiki page. Excellent little function. Anyways, this takes the error code from GetLastError and translates it into the actual message you would find on the MSDN. I've also made a special version of the below code (for myself and any other interested party). You can look at the second screenshot to see it.
Working on code with simple APIs to get used to how it works. Maybe some file READ / WRITE APIS to start with.
I'm pretty sure you mentioned doing read and write with API in the past and I advised against it. I wouldn't use the API to read from or write to a file. Just use the built-in functions UNLESS you are using an API that requires a file handle.
Title: Re: Inspired by ERRORMESSAGE$: Human readable message from GetLastError (Kernel32)
Post by: NOVARSEG on February 07, 2021, 01:21:46 am
Just an example to learn API . What do you suggest for a simple API to get started. Maybe something from kernel32
Title: Re: Inspired by ERRORMESSAGE$: Human readable message from GetLastError (Kernel32)
Post by: SpriggsySpriggs on February 07, 2021, 01:24:33 am
Just an example to learn API . What do you suggest for a simple API to get started. Maybe something from kernel32
Well, it depends. What are you trying to accomplish?
Title: Re: Inspired by ERRORMESSAGE$: Human readable message from GetLastError (Kernel32)
Post by: NOVARSEG on February 07, 2021, 01:33:18 am
I'm not sure. That is the same question I came across when I was learning the DOS interrupts. Eventually that is all I coded in and I used QB45 mainly as an IDE with A86 assembler.
Of course assembler is rarely used now. so for me to learn APIs is to upgrade to better features of 32 / 64 bit programming..
Title: Re: Inspired by ERRORMESSAGE$: Human readable message from GetLastError (Kernel32)
Post by: SpriggsySpriggs on February 07, 2021, 01:34:31 am