I got this error while trying to boot Slax off a USB for my previous post. I had created the bootable drive using Rufus 3.13, a well known bootable USB creator. When Rufus encounters older distribution images, it downloads Syslinux 6.03 files ldlinux.bss and ldlinux.sys to include in the drive’s boot folder. But because of whatever reason all the older ISOs Syslinux 6.03 I’ve burnt with Rufus always fail to boot. I’ve encountered this problem multiple times.
My solution to this was to use UNetBootin for creating the bootable USB and basically avoid this problem altogether. Other people on various forums have also had the same conclusion, i.e. using a different ISO to USB tool like Win32 Disk Imager, etc.
I’m pretty curious about why this is happening. I tried doing a lot of stuff like manually putting in Syslinux 6.03 files from kernel.org but nothing worked other than changing the USB tool. Might make a post about this later if I find something interesting.
One of my readers, Niteen, asked me if I could help install a battery indicator next to the system tray in Slax. So I did some digging and found a way.
cbatticon is a nice battery indicator applet that works well with Fluxbox. Cbatticon is available on the Debian package repositories. The problem is, it is not available for Debian Stretch off of which Slax 9.11 is based. That’s why using “apt search cbatticon” doesn’t yield any results.
We can still install it, though. First, we’ll install all the dependencies of cbatticon with the command:
After downloading the package, we navigate to the directory where the package was downloaded and install it with dpkg. Use the command:
cd Downloads
dpkg -i cbatticon_1.6.8-1_amd64.deb
After installing the package, we can launch it by using the terminal.
cbatticon &
To get cbatticon to start automatically with every login, we need to edit Fluxbox’s configuration files. Go to “$HOME/.fluxbox/” and open the file “apps” in a text editor.
cd $HOME/.fluxbox/
nano apps
Add the following line to the top of the file. (Thanks to the good folks at LinuxQuestions.org for this information)
[startup]{cbatticon &}
Then, log out and log back in and you’ll see cbatticon start automatically when you log in.
Making some simple programs is a good way of getting used to the Win32 API. Here’s the code for a basic application that shows a simple message box.
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
LPCWSTR myText = L"Text for the message box";
LPCWSTR myCaption = L"Caption for the message box";
MessageBoxW(NULL, myText, myCaption, MB_OKCANCEL);
return 0;
}
Basic Win32 program for creating a message box
I’ll compile it with mingw-w64’s g++ that we setup in my previous post.
Compiling and running the message box programws.exe in Explorer
All of this might be confusing for people new to the Windows API, so let’s break it down line by line.
#include <windows.h>
This line tells the g++ compiler to include the “windows.h” header file. Windows.h contains Windows API functions, macros and data types that must be used inside a Win32 application.
int WINAPI WinMain
This is the entry point for a graphical Windows application. In simple terms, it’s the equivalent of the standard C++ int main() but specific to Windows GUI applications.
(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
lpCmdLine contains the command line arguments as a long pointer. nCmdShow decides if the application window will be maximized, minimized or act normally on launch. hPrevInstance is not used these days, its value is NULL or 0. hInstance is a HANDLE to an instance, used to identify the executable when it is loaded into memory. (More info here)
LPCWSTR myText = L"Text for the message box";
LPCWSTR myCaption = L"Caption for the message box";
LPCWSTR is a typedef/alias for const wchar_t * data type. The L prefix before the double quote is used to define a wide character string literal as opposed to a normal string. For more information on Windows data types, look here.
I’ve always been fascinated by classic Win32 applications. They start up really quick, are always really fast and they rarely hog resources. The speed and fast startup is a huge plus for me, especially compared to “modern” desktop applications built with .NET.
I’m going to try and make a simple Win32 app, a program which helps me store the Spotlight lock-screen images that are changed periodically.
Spotlight Lockscreen (Source: Superuser.com)
The Compiler
The first step is getting the tools we need. I don’t feel like installing the massive Visual Studio IDE for this project so I’ll go with mingw-w64 which is a free port of the GNU C/C++ Compiler and other libraries/tools for 64 bit Windows. To install this, I’ll use a package distribution program called WinBuilds.
WinBuilds
All packages from WinBuilds total are around 500MB in size (unextracted), compared to the multiple gigabytes for Visual Studio.
winbuilds directory
The WinBuilds directory will contain a “bin” subdirectory, containing EXE files for all the tools. Ideally one should add this directory to the PATH environment variable, but I’m going to be using a batch script to manually set for a terminal session.
add-mingw-to-path.bat
set PATH=%PATH%;c:\winbuilds\bin\
where C:\winbuilds\bin is your WinBuilds install directory.
add MinGW to path
I’ll be using VSCode as my text editor for this series. First I’ll make a simple C++ program that prints “Hello” and compile it with g++. Then I run the output EXE file. Seems to work so far.
Compiling and running my Hello.cpp file
Mingw-w64’s g++ produces Windows PE (portable executable) .EXE files, which is neat. I’ve not used any Windows APIs here, so hello.exe is not really a proper Win32 application yet.
To use the Windows API, we need to include windows.h and use Windows API functions. To test my setup I’ll use the first program from theForger’s Win32 API Programming Tutorial, the most famous Win32 API programming tutorial.
Hello.exe GUI window appears
It works. I’ll add more stuff to it in the next part.