Hi, I've written a simple program (using MinGW) which starts Emacs with the same arguments as the program got itself (I'm using Windows 7 and since Windows Vista only programs in certain folders, such as Program Files, can be associated with different file types). It should be as a middle hand that opens Emacs, and it shouldn't be visible to the user.
The program does open Emacs; the only flaw is that a console window pops up and closes immediately, before Emacs is started, so it's not completely invisible. I don't want that console window to appear.
I've tried many of the suggestions for this problem on the internet, but either they don't work or they don't compile. I think many of the suggestions are just for hiding the console window once it has launched.
I'm compiling using MinGW and MSYS. One suggestion when using MinGW is to ad -lmingw32 as an argument to the compiler, but that doesn't work; another suggestion to solve the problem is to include windiws.h and call FreeConsole() in main(), but that doesn't work either.
.
.
.
Edit: By the way, if it should be of any interest to you, here's the code:
Code:#include <stdlib.h> #include <stdio.h> #include <string.h> #define MALLOC_NUM(ptr, number) { \ ptr = (typeof(ptr)) malloc(sizeof(*ptr)*number); \ if (!ptr) { \ printf("Not enough memory\n"); \ exit(1); \ } \ } const char* app = "runemacs"; int main(int argc, char** argv) { int i; //Calculate the total length of the command line int* args_end_at; MALLOC_NUM(args_end_at, argc); args_end_at[0] = strlen(app); for (i = 1; i < argc; i++) { args_end_at[i] = args_end_at[i-1] + 1 + strlen(argv[i]); } //Allocate memory for line char *command_line, *line_ptr; MALLOC_NUM(command_line, args_end_at[argc] + 1); //Copy arguments to line strcpy(command_line, app); for (i = 1; i < argc; i++) { line_ptr = command_line + args_end_at[i-1]; *(line_ptr++) = ' '; strcpy(line_ptr, argv[i]); } command_line[args_end_at[i-1]] = '\0'; //Run command system(command_line); return 0; }



LinkBack URL
About LinkBacks


