So I climbed down and started digging through my old C archives and... (imagine Indiana Jones emerging from some deep underground tunnel, covered in cobwebs with spiders hanging off his hat, but holding up an ancient golden statue)... found this gem:
Code: Select all
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#include "io.h"
#include "fcntl.h"
#include "stdio.h"
#include "stdlib.h"
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR lpCmdLine,INT nCmdShow) {
char buf[512]="";
int i;
// minimal version, just stdin
FILE *fin;
fin=_fdopen(_open_osfhandle((long)GetStdHandle(STD_INPUT_HANDLE),_O_RDONLY),"r");
fread(buf,1,sizeof(buf),fin);
if (fclose(fin)==0) MessageBox(NULL,buf,"OK",0);
}
This short snippet works if used with a redirected stdin:
But how to translate that stuff into FP/Lazarus... I haven't got a clue. It's probably not even worth your while to try as the C runtime library does things differently to FP's, I'd assume. Nevertheless, in theory at least a Win32 GUI app can indeed read stdin if started from a console
