bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnubg] Bug when opening from file icon a match saved in .sgf


From: Jon Kinsey
Subject: Re: [Bug-gnubg] Bug when opening from file icon a match saved in .sgf
Date: Mon, 13 Oct 2003 11:46:24 +0100

At 20:05 12/10/2003, Joern Thyssen wrote:
On Sun, Oct 12, 2003 at 08:22:37PM +0200, Nardy Pillards wrote
> On 12 Oct 2003 at 16:58, Joern Thyssen wrote:
>
>
> > Isn't there some environment variable we can query or some function we
> > can call that'll return the path to "program files"? Or will this only
> > work if installed in the default suggested directory? Is it somehow
> > possible to find out where gnubg was installed?
> >
> > If possible, it should be trivial to initialise the data directory
> > with this value.
>
> You can read the Registry.
> (Installation Archive keeps the Installation Directory there)
>
> But you can also set (and read) an environment variable.
> DOS command:
> SET xyz=[value]
>
> I would opt for the second choice, although the WinPro(g)s will say:
> No way. Use that Registry!!

I'd opt for the registry, unless it's possible by the installer to add
the environment variable to the list of system env. variables.

It shouldn't be that difficult to query the registry (or am I just being
naïve)?

Here's some sample code to read the value from the registry (I think this works with 95):

Jon

#include <windows.h>
#include <stdlib.h>

int main()
{
        char buf[_MAX_PATH];
        DWORD buflen = _MAX_PATH;
        HKEY key;
        LONG res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\gnubg",
                0, KEY_READ, &key);
        if (res == ERROR_SUCCESS)
        {
res = RegQueryValueEx(key, "Install_dir", 0, 0, (LPBYTE)buf, &buflen);
                if (res == ERROR_SUCCESS)
                {
                        printf("test: %s\n", buf);
                }

                RegCloseKey(key);
        }
        return 0;
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]