Re: Relocatable locale

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Peter Eisentraut" <peter_e(at)gmx(dot)net>
Cc: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Relocatable locale
Date: 2004-05-27 13:29:12
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCE34BB3D@algol.sollentuna.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

> > > > > As for how to do it - on Windows you *can* get the
> path of the
> > > > > DLL that is executing your code, using GetModuleFileName().
> > > > > Hardly cross-platform, but can be done.
> > > >
> > > > That sounds pretty reasonable to me.
> > >
> > > True, and we already have our own find_my_exec() which
> works for Unix too.
> >
> > What does that have to do with this case? We're trying to find the
> > library here.
>
> Oh, I see that GetModuleFileName() finds the location of your
> library, not of the binary. Nice. So, for Win32, we use
> that function call to find the locale directory?
>
> We do have a comment in port/exec.c:
>
> if (GetModuleFileName(NULL, retpath, MAXPGPATH) == 0)
>
> and I thought that did only binaries, not the library that
> uses them. I assume if the library is a DLL, it returns the
> DLL location, and if it is in the binary, it returns the
> binary location.

Nope, not quite.
With the parameter NULL, it will return for the current *process*.
You will need to use GetModuleHandle() (I think that should work) to get
the handle of the DLL. See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc
/base/getmodulehandle.asp

For static libaries, you need a different solution. Base that off the
EXE?

//Magnus

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2004-05-27 13:36:53 Re: Relocatable locale
Previous Message Peter Eisentraut 2004-05-27 13:25:55 Re: Relocatable locale