From c2e133502697ce22b75a18521ea55f458c82a3ae Mon Sep 17 00:00:00 2001 From: Jose Fonseca Date: Sat, 9 Dec 2023 20:21:03 +0000 Subject: [PATCH] Better ExcHndl.DLL sample code. Slightly more compact version of @asmwarrior's sample code. Fixes https://github.com/jrfonseca/drmingw/issues/87 --- README.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 551b588..570f3fb 100644 --- a/README.md +++ b/README.md @@ -92,9 +92,25 @@ You can use ExcHndl by: * or use `LoadLibrary`/`GetProcAddress` like - LoadLibrary("exchndl.dll"); - pfnExcHndlInit = GetProcAddress("ExcHndlInit"); - pfnExcHndlInit() + // Load the DLL + HMODULE hModule = LoadLibraryW(L"exchndl.dll"); + + if (hModule != NULL) { + // Get the function pointer + typedef void (*PFNEXCHNDLINIT)(); + PFNEXCHNDLINIT pfnExcHndlInit = (PFNEXCHNDLINIT)GetProcAddress(hModule, "ExcHndlInit"); + + if (pfnExcHndlInit != NULL) { + pfnExcHndlInit(); + } else { + // Handle the error if GetProcAddress fails + // Add your error handling code here + } + + // Do not free the DLL module + } else { + // Handle the error if LoadLibrary fails + } * you can also override the report location by invoking the exported `ExcHndlSetLogFileNameA`/`ExcHndlSetLogFileNameW` entry-point.