/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include "EnumProc.h"

int fnd = 0;

char searchstr[256];

BOOL __stdcall Proc( DWORD dw, WORD alwaysZero, LPSTR lpstr, LPARAM lParam )
{
  if( strcmp( lpstr, searchstr) == 0 ) fnd = 1;
  return 1;
}

int APIENTRY WinMain(HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR    lpCmdLine,
                    int      nCmdShow)
{
  strcpy( searchstr, getenv("MAN_PROG") );
  while (1) {
    fnd = 0;
    EnumProcs( Proc, 0 );
    if ( !fnd ) {
      ExitWindowsEx( EWX_SHUTDOWN + EWX_FORCE, 0 );
    }
    Sleep(2000);
  }
  return 0;
}
