diff --git a/simplex~.c b/simplex~.c index a682868..752edb9 100644 --- a/simplex~.c +++ b/simplex~.c @@ -727,7 +727,15 @@ static void *simplex_tilde_new(t_symbol *s, int ac, t_atom *av) { void simplex_tilde_setup(void) { #ifdef _WIN32 - g_signal_setmultiout = (t_signal_setmultiout)GetProcAddress(GetModuleHandle(NULL), "signal_setmultiout"); + // get a handle to the module containing the Pd API functions. + // NB: GetModuleHandle("pd.dll") does not cover all cases. + HMODULE module; + if (GetModuleHandleEx( + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (LPCSTR)&pd_typedmess, &module)) { + g_signal_setmultiout = (t_signal_setmultiout)(void *)GetProcAddress( + module, "signal_setmultiout"); + } #else g_signal_setmultiout = (t_signal_setmultiout)dlsym(dlopen(NULL, RTLD_NOW), "signal_setmultiout"); #endif