Hello, from a gtk+ application I execute an external program in Windows 7 (64 bit) with administrator privileges, and I use a callback function when it exits to elaborate the result. So far, it works. The problem is that I would like to hide or, at least, to minimize (iconify) the external program to not bore the user. I guess that I have to manage the GPid value returned by g_spawn_async_with_pipes, but how? I didn't find any suitable function in gtk.
Knowing that GPid is an handle in windows, I used the winapi functions CloseWindow, ShowWindow, MoveWindow, SetWindowPos. They are simply and silently ignored during the execution. Just to check the returned pid, I used TerminateProcess( (HWND)pid , 0) and the external application correctly terminated: i.e. pid is correct. On the other side DestroyWindow is ignored. Do you have any suggestion? Below you can find a simplified version of my code. #include <windows.h> #include <gtk/gtk.h> // ... snip ... // gchar *argv[3]; GPid pid; argv[0]= "external_program.exe"; argv[1]= "external_parameter_file.ini"; argv[2]= NULL;// g_spawn_async_with_pipes ( NULL, //gchar *working_directory, argv, //gchar **argv, NULL, //gchar **envp, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, //GSpawnFlags flags, NULL, //GSpawnChildSetupFunc child_setup, NULL, //gpointer user_data, &pid, //GPid *child_pid, NULL, //gint *standard_input, NULL, //gint *standard_output, NULL, //gint *standard_error, error); //GError **error); /* Add watch function to elaborate the result of external_program.exe. It will clean any remnants of process. */ g_child_watch_add( pid, (GChildWatchFunc)child_watch_cb, data ); CloseWindow((HWND)pid); // ignored during execution!!! // I tried also the following variants that are "ignored": // ShowWindow((HWND)pid, SW_FORCEMINIMIZE); // Tested also other options: SW_HIDE, SW_MINIMIZE, SW_SHOWMINIMIZED, SW_SHOWMINNOACTIVE // MoveWindow((HWND)pid, 10, 10, 10, 10, TRUE); // SetWindowPos( (HWND)pid, 0, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE ); // This works and terminates the external application, but this is not obviously my goal // TerminateProcess( (HWND)pid , 0); // ... snip ... // /Giovanni _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list