[Top][All Lists]

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

Re: Dark mode on Windows

From: Eli Zaretskii
Subject: Re: Dark mode on Windows
Date: Mon, 25 Oct 2021 15:37:22 +0300

> 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.

reply via email to

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