User can switch active application by Alt+Tab or by clicking on their icons in TaskBar. Is it possible to get the name (or other unique characteristic) of current active application?
I want to write a program which collects statistic of the applications usage.
The Windows API has a function called GetForegroundWindow(). You will need to use P/Invoke to call into the Win32 API. The P/Invoke wiki has more info for C# users.
See this page for an example which gets the caption (name) of the current application.