[project @ 2001-05-10 09:51:28 by rrt]
authorrrt <unknown>
Thu, 10 May 2001 09:51:28 +0000 (09:51 +0000)
committerrrt <unknown>
Thu, 10 May 2001 09:51:28 +0000 (09:51 +0000)
Enhanced. Probably not to be used now, though.

ghc/InstallShield/runexe.c

index c01f0b1..acdd5db 100644 (file)
@@ -1,11 +1,37 @@
+#include <stdarg.h>
+#include <stdio.h>
 #include <windows.h>
 
 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;
 }