From ebc3a6899acc6f6336750042612df23a41e1327c Mon Sep 17 00:00:00 2001 From: rrt Date: Thu, 10 May 2001 09:51:28 +0000 Subject: [PATCH] [project @ 2001-05-10 09:51:28 by rrt] Enhanced. Probably not to be used now, though. --- ghc/InstallShield/runexe.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/ghc/InstallShield/runexe.c b/ghc/InstallShield/runexe.c index c01f0b1..acdd5db 100644 --- a/ghc/InstallShield/runexe.c +++ b/ghc/InstallShield/runexe.c @@ -1,11 +1,37 @@ +#include +#include #include const char *prog = "runexe"; +#define BUFLEN 1025 + +void die(char *fmt, ...) +{ + va_list ap = va_start(ap, fmt); + + fprintf(stderr, "%s: ", prog); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); + exit(1); +} + +void warn(char *fmt, ...) +{ + va_list ap = va_start(ap, fmt); + + fprintf(stderr, "%s: ", prog); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); +} + int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow) { STARTUPINFO sInfo; PROCESS_INFORMATION pInfo; + TCHAR buf[BUFLEN]; sInfo.cb = sizeof(STARTUPINFO); sInfo.lpReserved = NULL; @@ -14,11 +40,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmd sInfo.lpDesktop = NULL; sInfo.lpTitle = NULL; sInfo.dwFlags = 0; - - if (strlen(lpszCmdParam) == 0) { - printf("%s: no parameters given\n", prog); - exit(1); - } + + if (GetCurrentDirectory(BUFLEN, buf) == 0) die("no parameters given"); + if (strlen(lpszCmdParam) == 0) warn("couldn't get current directory"); + warn("cwd: %s\n", buf); + warn("runexing >>>%s<<<\n", lpszCmdParam); CreateProcess(NULL, lpszCmdParam, NULL, NULL, FALSE, 0, NULL, NULL, &sInfo, &pInfo); return 0; } -- 1.7.10.4