Ctypes unable to load dll in Anaconda only

Windows 10,

I have developed a dll that I load in python using ctypes. Using a regular python3 installation this works just fine, but if I try to run the same python code from an Anaconda prompt or notebook launched from Anaconda (default installation, no special environment), I get the following error:

OSError: [WinError 1114] A dynamic link library (DLL) initialization routine failed

The dll only depends only on VC runtime and standard libraries that are obviously available on my system since I can load the dll in other contexts. Here is the output of dumpbin:

  Image has the following dependencies:

    SHELL32.dll
    ADVAPI32.dll
    ntdll.dll
    MSVCP140.dll
    MSVCP140_CODECVT_IDS.dll
    ole32.dll
    KERNEL32.dll
    VCRUNTIME140.dll
    VCRUNTIME140_1.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-heap-l1-1-0.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-math-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-filesystem-l1-1-0.dll
    api-ms-win-crt-convert-l1-1-0.dll
    api-ms-win-crt-time-l1-1-0.dll
    api-ms-win-crt-utility-l1-1-0.dll
    api-ms-win-crt-environment-l1-1-0.dll

The dll was compiled using Visual Studio 2022 (17.10.5), using flags

/LD /MD /EHsc /GR- /std:c++17

In the Anaconda prompt I have

python --version
Python 3.12.4

conda --version
conda 24.5.0