Yogesh M writes: > I am using Gtk in windows(as well as linux). I want to set the > environment path to executable path so i can load icons present in > the executable path. I will be happy if it works both on linux and > windows.
On Linux, do a readlink on /proc/self/exe (if it exists), and g_get_dirname() on the result. On other Unixes, don't know. Some might have something like /proc/self/exe. Otherwise look at argv[0], and if it doesn't contain a directory already (possibly relative) look for the executable in $PATH, etc. Note that this method is trivial to spoof, so it shouldn't be used for anything that might have security consequences. On Windows, do GetModuleFileName() on the result of GetModuleHandle(NULL). If you want to be really correct, use the wide character version (and then convert pathname from UTF-16 to UTF-8 before passing to g_open() etc.) --tml _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list