Interfacing computers to physics experiments
This page is for the new ExpEYES (ExpEYES Junior)
For the old ExpEYES click here
Win32 Tutorial

This tutorial guides you through the process of writing programs in C for the Win32-API. For more detail you can read the references given at the end of this page.

Setting up the tools

1. Download and install Notepad++ from Use this for editing the source files. This is much better than Notepad or Wordpad.
2. Download and install either MinGW or Visual Studio Express 2013 for Windows Desktop (older editions are also ok) (You can also use any recent Professional Edition of Visual Studio C++). Which compiler you use (MinGW or Visual Studio) will depend on your temperament. If you are comfortable with a Linux-like command shell you may prefer MinGW. It produces exe files that are more compact than Visual Studio. On the other hand, if you already have Visual Studio installed on your computer and/or plan to use it for other projects, then the you can complie the Win32 programs provided here with the Visual Studio Command Prompt.


Download and install MinGW from At the time of writing, the latest version is mingw-get-inst-20120426.exe, any later version will be similar. Select only the C Compiler and MSYS Basic System (We dont need C++ and other languages). After install you may like to create a desktop shortcut for the MSys command shell.

Go to Start→All Programs→MinGW and click MinGW Shell (or your desktop shortcut). MinGW Shell is just another name for MSYS. It is a command prompt window with Linux like features. Basic UNIX commands like ls, pwd will work here. If you type pwd you will see that you are at /home/[User] where [User] is the Windows user name. This directory is actually C:\MinGW\msys\1.0\home\[User]

You need to have your source codes in a folder under the working directory C:\MinGW\msys\1.0\home\[User]\. For example, to work with Microhope source codes you may like to work in C:\MinGW\msys\1.0\home\[User]\MHope. Change to this directory ($cd MHope). You can add, delete and edit files in either using UNIX commands from the MinGW Shell or using Windows tools. Use Notepad++ in a separate window to edit the source files. and build the program by typing "make" in the MinGW Shell.

If you have hopper.c, hopper.h and Makefile in this directory, typing make in the MinGW Shell will create hopper.exe. You can also compile by the gcc command mentioning all the c source files and libraries to be linked together. For The program can be run either by double-clicking in explorer or by typing hopper.exe at the MSYS prompt. If the code is in a single c file, you can also compile by typing e.g. gcc -o hopper.exe hopper.c -mwindows -lcomctl32

Visual Studio 2008/2010/2013 or later

You can use the free express editions of Visual Studio 2008, 2010 or 2013. The latest edition at the time of writing is Visual Studio Express 2013 for Windows Desktop. If you already have Visual Studio Professional (2008 or later) then you dont need any additional tools.

For compiling you do not need to use the Visual Studio IDE. Edit the source code files with Notepad++ and use the Command Prompt to compile. Instructions for Visual Studio 2008 are given below. Later editions are similar. 1. Click All Programs, Microsoft Visual Studio 2008, Visual Studio Tools, Visual Studio 2008 Command Prompt. This gives a command prompt with all the libraries in PATH.
2. cd to working directory
3. If you have the file mcompile.bat, type mcompile. If you dont have the file mcompile.bat You can use a command line mentioning all the c files and the required libraries to be linked together. For HOPPER there is only one source file, so the command is: cl hopper.c user32.lib comctl32.lib gdi32.lib

Visual Studio
References for win32API programming
Complete win32 reference as a help file
A smaller help file
Programming Windows by Charles Petzold 5th Edition. This a complete and authoritative book. The PDF is available for free, but as the links keep changing, you will have to search for it on the web. There is also a 6th Edition, but that is for Metro style applications, while here we are concerned with Desktop style applications.