#include <windows.h>
#include <stdio.h>

static char *sFmt   = "%6d  %8d  %s\n" ;
static char *sTitle = "%6s  %8s  %s\n" ;

static WINAPI
EnumProc(
    HWND    hWindow,
    void    *pvParam
){
    char    sTitle[256] ;
    unsigned long Pid ;

    GetWindowThreadProcessId(hWindow,&Pid) ;
    GetWindowText(hWindow,sTitle,sizeof sTitle-1) ;
    if (sTitle[0] != 0)  {
        printf(sFmt,hWindow,Pid,sTitle) ;
    }
    return(TRUE) ;
}

main(
    int  argc,
    char *argv[]
){
    printf(sTitle," WinID","     PID","Window Name") ;
    EnumWindows(EnumProc,0) ;
    return(0) ;
}
