[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Dark mode on Windows
From: |
Vince Salvino |
Subject: |
RE: Dark mode on Windows |
Date: |
Mon, 25 Oct 2021 15:44:05 +0000 |
Thanks for the suggestions Eli and Po. I tried GetModuleHandle, and did in fact
run into the error that you cannot GetModuleHandle if the DLL is not already
loaded (it returns 0x0). For some reason this worked with uxtheme.dll (I'm
guessing something must have inadvertently loaded it as a side effect?), but
not with dwmapi.dll. I will try LoadLibrary and see if that works.
I understand that linking -ldwmapi will shut out XP and earlier, so am trying
to find a solution around that. Will report back with any findings after
playing with it a bit.
Vince Salvino
-----Original Message-----
From: Eli Zaretskii <eliz@gnu.org>
Sent: Monday, October 25, 2021 8:38 AM
To: Po Lu <luangruo@yahoo.com>
Cc: Vince Salvino <salvino@coderedcorp.com>; emacs-devel@gnu.org
Subject: Re: Dark mode on Windows
> From: Po Lu <luangruo@yahoo.com>
> Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
> Date: Mon, 25 Oct 2021 14:25:38 +0800
>
> Vince Salvino <salvino@coderedcorp.com> writes:
>
> > I originally tried dynamically loading dwmapi.dll, and it cannot be
> > done dynamically. It will simply not load. I spent a lot of time
> > head-scratching in gdb to figure this out. From what I read, it
> > behaves a bit differently than other DLLs and has to be linked. This
> > is also my first foray into Win32 programming, so I have exactly
> > zero experience with any of this stuff, and could be wrong.
>
> Some searching reveals that dwmapi.dll is apparently already loaded
> into every program on systems that have it.
If it is already loaded, LoadLibrary should just increase its reference count,
but will return a valid handle. We do that all the time in Emacs, for example
when using LoadLibrary to load kernel32.dll, which on modern Windows systems is
always loaded.
> So you probably just need a way to get the address of the symbol for
> the function you want to use.
You cannot get an address without a handle to the DLL, and that's what
LoadLibrary gives you. An alternative is to use GetModuleHandle, if we know
the library is already loaded.
The main point is that if we link with -ldmwapi, i.e. link statically against
the DLL, the resulting Emacs binary will refuse to start on systems where this
DLL is not available. So this means in practice we will be unable to provide
precompiled binaries that run on any supported Windows system.
- Re: Dark mode on Windows, (continued)
- RE: Dark mode on Windows, Vince Salvino, 2021/10/25
- Re: Dark mode on Windows, Po Lu, 2021/10/25
- RE: Dark mode on Windows, Vince Salvino, 2021/10/25
- Re: Dark mode on Windows, Po Lu, 2021/10/25
- Re: Dark mode on Windows, Eli Zaretskii, 2021/10/25
- RE: Dark mode on Windows,
Vince Salvino <=
- Re: Dark mode on Windows, Eli Zaretskii, 2021/10/25
- Re: Dark mode on Windows, Eli Zaretskii, 2021/10/25
- Re: Dark mode on Windows, Eric S Fraga, 2021/10/25
Re: Dark mode on Windows, Alan Third, 2021/10/25
Re: Dark mode on Windows, Eli Zaretskii, 2021/10/25
- Re: Dark mode on Windows, Stefan Monnier, 2021/10/25
- Re: Dark mode on Windows, Eli Zaretskii, 2021/10/25
- Re: Dark mode on Windows, Michael Albinus, 2021/10/25
- Re: Dark mode on Windows, Po Lu, 2021/10/25
- Re: Dark mode on Windows, Eli Zaretskii, 2021/10/26