Re: gtk win32 and env variables
- From: Goran RakiÄ <gox devbase net>
- To: Dan McMahill <mcmahill mtl mit edu>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: gtk win32 and env variables
- Date: Sat, 5 Nov 2005 15:40:40 +0100
Put this first:
#ifdef WIN32
# include <windows.h>
# include <winreg.h>
#endif
And latter in your code...
#ifdef WIN32
// Fallback value: data in working dir
char dbpath[MAX_PATH]="data";
HKEY hkResult;
DWORD DataType;
DWORD DataCount = MAX_PATH;
// Open registry key
if (RegOpenKeyEx( HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\
\YouApp.exe",
0 ,
KEY_QUERY_VALUE,
&hkResult ) == ERROR_SUCCESS )
{
// Write registry key value to dbpath
RegQueryValueEx(hkResult, "dbpath", NULL, NULL, (unsigned
char*) dbpath, &DataCount );
}
RegCloseKey(hkResult);
#else
char *dbpath = PACKAGE_DATA_DIR "/" PACKAGE "/data";
#endif
In any case, you now have dbpath pointer you can use.
Also, you can add some kind of arguments checking (so user can bypass
this check with argument like -data-dir some/dir).
Goran Rakic
On 05.11.2005., at 15.22, Dan McMahill wrote:
Hi,
Not sure if this is the right list or not for this question.
I have a gtk+ app developed for NetBSD/Linux/Solaris. I just
ported it to windows with almost no pain thanks to gtk for win32.
I even made an installer with NSIS. The problem I have though is
that my program has 2 directories where it looks for some system
data files at runtime. One of the ways it can find these
directories is through the use of 2 environment variables. On a
unix like system, those variables are usually not needed because a
default path is put into the binary at compile time based on the
configure options. On windows, it is easy for the user to pick a
different place to install so I need to set those variables.
So my question is how do gtk apps ported to windows typically deal
with something like that? Do I try and make the installer set some
windows environmnet variables? Do I use some registry thing? Is
that even supported in glib/gtk for win32? I'm really not a
windows user at all, but know of a number of people interested in
using my program on windows.
Thanks for any suggestions.
-Dan
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]