Windows - peregrineshahin/ChessProgrammingWiki GitHub Wiki


title: Windows

Home * Software * Windows

[ Windows Server 2012 Logo [1] Windows,

a series of 32-bit and 64-bit operating systems by Microsoft for x86 and x86-64 PC's, as well as Windows CE for embedded systems and the mobile operating system Windows Mobile. Its development started in the early 80s as a graphical user interface for 16-bit MS-DOS operating system, with the ability to perform cooperative multitasking while processing an event loop.

Chess Engines

Most current chess engines are suited to run under Windows, a few with its own proprietary user interface, but most common as console application and child process of an external chess GUI communicating via redirected standard streams [6] using protocols like the Chess Engine Communication Protocol (WinBoard) and/or the Universal Chess Interface (UCI).

Windows Chess GUIs

Arena320.jpg CPsshot2.png
Arena [7] Deep Sjeng under ChessPartner [8]
DeepFritz14d 1.jpg DeepRybkaInAqurium7.png
Deep Fritz 14 GUI [9] Deep Rybka 4 Aquarium [10]

Applications

Major

Microsoft Word Microsoft Excel Microsoft PowerPoint

Accessories

Entertainment

Taipei by David Norris Ziggurat by David Norris

Remote Desktop

Remote Desktop Services, MSDN

Development

Covers integrated development environments (IDE), Software development kit (SDK), Application programming interface (API), programming languages, compiler and tools.

IDE

Visual Studio 2010, MSDN

Eclipse.org home

Frameworks

Common Language Runtime Overview, MSDN Windows Communication Foundation from Wikipedia

Subsystems

SDK

API

Input and Output

Memory

Interprocess Communications

Dynamic Linking

Dynamic-Link Libraries, MSDN

The End of DLL Hell, MSDN C

C programmers were faced with some new paradigms from early 16-bit Windows API, not to mention the fact that a lot of C standard library functions were hard and error-prone to use, or even taboo [11] . Charles Petzold: "The original hello world program in the Windows 1.0 SDK was a bit of a scandal. HELLO.C was about 150 lines long, and the HELLO.RC resource script had another 20 or so more lines". (...) Veteran C programmers often curled up in horror or laughter when encountering the Windows hello-world program." [12] .

WinMain and the Message loop

Windows programs are event-driven, have no usual main, but WinMain to enter a event loop [13] , where DispatchMessage transfers messages to a callback procedure associated with the window the message refers to, i.e. for keyboard events one window which owns the keyboard focus. To make Windows applications work flawlessly, keeping its windows up to date, that is processing paint messages, the I/O bound GUI thread needs to be run in the message loop, to react on messages best within 20 ms. In early 16-bit Windows, DispatchMessage implemented cooperative multitasking - but one application being uncooperative could made the whole system hang.


int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
   WNDCLASS wc;
   MSG msg;
   ...
   wc.lpfnWndProc = (WNDPROC) MyWndProc; // associate a Window procedure for this "class" of windows
   if (!RegisterClass(&wc)) // register window class
       return FALSE;
   hwnd = CreateWindow(...);
   ShowWindow(hwnd, SW_SHOW);
   while(GetMessage(&msg, NULL, 0, 0) > 0)
   {
     TranslateMessage(&msg);
     DispatchMessage(&msg);
   }
   return msg.wParam;
}

Window Procedure

The callback or Window procedure is called from the above message loop.


LRESULT CALLBACK MyWndProc(
    HWND hwnd,        // handle to window
    UINT uMsg,        // message identifier
    WPARAM wParam,    // first message parameter
    LPARAM lParam)    // second message parameter
{
    PAINTSTRUCT ps;
    HDC hdc;
    switch (uMsg)
    {
        case WM_CREATE:    // Initialize the window
            return 0;
        case WM_PAINT:
            hdc = BeginPaint(hwnd, &ps);
            TextOut(hdc, 0, 0, "Hello, Windows!", 15);
            EndPaint(hwnd, &ps);
            return 0;
        case WM_DESTROY:   // Clean up window-specific data objects
            return 0;
        case WM_CHAR:      // Process Keyboard character events
            return 0;
        case WM_MOUSEMOVE: // Process mouse move events
            return 0;
        // Process other messages
        default:
            return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    return 0;
}

Standard C Library

C++

Microsoft's proprietary C++ Foundation Classes wrapped the handle based Windows API and hides much of its complexity. Still one of the early class libs, it has a lot of ugly macros, i.e. for message maps. Borland's counter part was the Object Windows Library.

Command-Line Applications

Applies for most UCI and/or Chess Engine Communication Protocol (WinBoard) compatible chess engines, relying on an external GUI.

Class Libs

MFC Reference, MSDN

Compiler

Visual C++ Tutorials, Library, and More on MSDN

MinGW - Minimalist GNU for Windows

Cygwin Information and Installation

Intel® Compilers Intel(R) C++ Compiler User and Reference Guides covers Intrinsics » x86, x86-64, MMX, SSE2, SSSE3, SSE4, AVX

Calling Conventions

Agner Fog describes x86 and x86-64 calling conventions for different C++ compilers and operating systems, covering 32-bit and 64-bit Windows [14] :

The document contains details about data representation, function calling conventions, register usage conventions, name mangling schemes, etc. for many different C++ compilers and operating systems. Discusses compatibilities and incompatibilities between different C++ compilers. Includes information that is not covered by the official Application Binary Interface standards (ABI's). The information provided here is based on my own research and therefore descriptive rather than normative. Intended as a source of reference for programmers who want to make function libraries compatible with multiple compilers or operating systems and for makers of compilers and other development tools who want their tools to be compatible with existing tools.

Other Languages

See also

Publications

Forum Posts

1995 ...

2000 ...

2010 ...

2015 ...

Further Links

References

  1. Microsoft Windows from Wikipedia
  2. Microsoft Windows 1.03 and other tools, 1985 from DigiBarn
  3. Microsoft Windows/286 2.11 and other tools from DigiBarn
  4. Windows NT 4.0 Workstation Betriebssystem
  5. ↑ [https://en.wikipedia.org/wiki/Task_View Task View from Wikipedia
  6. Creating a Child Process with Redirected Input and Output, MSDN
  7. Free chess graphical user interface (GUI) Arena for chess engines
  8. Sjeng - chess, audio and misc. software
  9. Deep Fritz 14 from ChessBase
  10. ChessOK, Chess Shop from the Developers of Rybka 3 Aquarium
  11. Standard C Library Functions from MSDN: Microsoft Development
  12. Windows API from Wikipedia - History
  13. Message loop in Microsoft Windows
  14. Calling conventions for different C++ compilers and operating systems (pdf) by Agner Fog
  15. MinGW from Wikipedia

Up one Level