Εμφάνιση αναρτήσεων με ετικέτα system. Εμφάνιση όλων των αναρτήσεων
Εμφάνιση αναρτήσεων με ετικέτα system. Εμφάνιση όλων των αναρτήσεων

Παρασκευή 11 Μαΐου 2012

How to detect (and prevent) system shutdown

When Windows are being shutdown or restarted, all runnig applications are closed of course. 
This can be dangerous, because you can lost your unsaved documents. But there is an easy way to detect, that Windows wants to shutdown and your application can do everything necessary to close properly.This “trick” is pretty simple.

Global system hotkey

Using the RegisterHotKey function and few other lines of code, you can register a global system hotkey, which is active even if your application is minimized.

Retrieve time since the system was started

This tip is very simple. Just use standard function GetTickCount and the rest is just elementary mathematics.

How to locate important system directories

Using ShlObj unit and SHGetSpecialFolderLocation Windows API function, we can retrieve the location of a special folders, such as My computer, Desktop, Program Files etc… There are over 20 special folder locations.

Own items in application system menu

When you rightclick application title bar (or leftclick icon on title bar), the system menu will appear. Here are common commands to close, minimize or maximize window. But you can add your own commands if you like. Here is how.

Detect system font size

The standard system font size in Windows XP is 96 dpi. You can also use 120 dpi, if your prefer bigger fonts or you can set this font size to your own value. However, the most applications today are tested only with standard font size and if you change it, even professional applications can have problems with it. With this tip, you can detect font size directly from your application and change behaviour of user interface.

Detecting Windows boot-up state using GetSystemMetrics function

Using GetSystemMetrics function, we can detect how the system is started.