Re: gtk win32 and env variables
- From: Tor Lillqvist <tml iki fi>
- To: John Cupitt <jcupitt gmail com>
- Cc: Dan McMahill <mcmahill mtl mit edu>, gtk-app-devel-list gnome org
- Subject: Re: gtk win32 and env variables
- Date: Sun, 6 Nov 2005 04:21:11 +0200
Another solution for applications is to look at argv[0]. On
Windows this is always (I think) the full path to the .exe.
Looking at argv[0] is really not recommended on Windows. If memory
serves me right, if the path to the application has spaces in it, it
might even be that depending on the phase of the moon, argv[0]
contains only the part up to the (first) space, the rest is in
argv[1..n], and crap like that. Remember that the real Win32 API to
start a process doesn't pass an argument vector to the process like
Unix does, it passes a command line. It's then the startup code in the
C runtime (which on Windows isn't unique, there are several
alternative ones, even from Microsoft, that an app might be linked
with) that tries its best to construct an argv from the command line,
and sometimes the result is far from perfect.
Much better to call GetModuleFileNameW() on the .exe's HMODULE. (Which
the GLib API mentioned does.)
--tml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]