make uninstDirKey and G_H_Module automatic

This commit is contained in:
onyx-and-iris 2024-06-25 17:22:33 +01:00
parent e7ea31eb21
commit 45496452c5

View File

@ -6,10 +6,12 @@
/** GET VOICEMEETER DIRECTORY **/ /** GET VOICEMEETER DIRECTORY **/
/*******************************************************************************/ /*******************************************************************************/
static char uninstDirKey[] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
#define INSTALLER_UNINST_KEY "VB:Voicemeeter {17359A74-1236-5467}" #define INSTALLER_UNINST_KEY "VB:Voicemeeter {17359A74-1236-5467}"
#ifndef KEY_WOW64_32KEY
#define KEY_WOW64_32KEY 0x0200
#endif
void remove_name_in_path(char *szPath) void remove_name_in_path(char *szPath)
{ {
char *p = szPath; char *p = szPath;
@ -22,10 +24,6 @@ void remove_name_in_path(char *szPath)
*p = '\0'; *p = '\0';
} }
#ifndef KEY_WOW64_32KEY
#define KEY_WOW64_32KEY 0x0200
#endif
bool __cdecl registry_get_voicemeeter_folder(char *szDir) bool __cdecl registry_get_voicemeeter_folder(char *szDir)
{ {
char szKey[256]; char szKey[256];
@ -35,6 +33,7 @@ bool __cdecl registry_get_voicemeeter_folder(char *szDir)
LONG rep; LONG rep;
DWORD pptype = REG_SZ; DWORD pptype = REG_SZ;
sss[0] = 0; sss[0] = 0;
const char uninstDirKey[] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
// build Voicemeeter uninstallation key // build Voicemeeter uninstallation key
strcpy(szKey, uninstDirKey); strcpy(szKey, uninstDirKey);
@ -70,20 +69,19 @@ bool __cdecl registry_get_voicemeeter_folder(char *szDir)
/*******************************************************************************/ /*******************************************************************************/
/** GET DLL INTERFACE **/ /** GET DLL INTERFACE **/
/*******************************************************************************/ /*******************************************************************************/
static HMODULE G_H_Module = NULL;
long initialize_dll_interfaces(T_VBVMR_INTERFACE *iVMR) long initialize_dll_interfaces(T_VBVMR_INTERFACE *iVMR)
{ {
HMODULE G_H_Module = NULL;
char szDllName[1024]; char szDllName[1024];
memset(iVMR, 0, sizeof(T_VBVMR_INTERFACE)); memset(iVMR, 0, sizeof(T_VBVMR_INTERFACE));
// get folder where is installed Voicemeeter // get Voicemeeter installation directory
if (!registry_get_voicemeeter_folder(szDllName)) if (!registry_get_voicemeeter_folder(szDllName))
{ {
// voicemeeter not installed // Voicemeeter not installed
return -100; return -100;
} }
// use right dll according O/S type // use right dll according to O/S type
if (sizeof(void *) == 8) if (sizeof(void *) == 8)
strcat(szDllName, "\\VoicemeeterRemote64.dll"); strcat(szDllName, "\\VoicemeeterRemote64.dll");
else else