BOOL ShellExt::Load(WCHAR *parent_dir, WCHAR *dll_name) { if (hShDll) { UnLoad(); } WCHAR path[MAX_PATH]; MakePathW(path, parent_dir, dll_name); if ((hShDll = TLoadLibraryW(path)) == NULL) return FALSE; RegisterDllProc = (HRESULT (WINAPI *)(void))GetProcAddress(hShDll, REGISTER_PROC); UnRegisterDllProc= (HRESULT (WINAPI *)(void))GetProcAddress(hShDll, UNREGISTER_PROC); RegisterDllUserProc = (HRESULT (WINAPI *)(void))GetProcAddress(hShDll, REGISTERUSER_PROC); UnRegisterDllUserProc= (HRESULT (WINAPI *)(void))GetProcAddress(hShDll, UNREGISTERUSER_PROC); IsRegisterDllProc= (BOOL (WINAPI *)(BOOL))GetProcAddress(hShDll, ISREGISTER_PROC); SetMenuFlagsProc = (BOOL (WINAPI *)(BOOL, int))GetProcAddress(hShDll, SETMENUFLAGS_PROC); GetMenuFlagsProc = (int (WINAPI *)(BOOL))GetProcAddress(hShDll, GETMENUFLAGS_PROC); SetAdminModeProc = (BOOL (WINAPI *)(BOOL))GetProcAddress(hShDll, SETADMINMODE_PROC); // ver違いで proc error になるが、 // install時に overwrite failを検出して、リネームする if (!RegisterDllProc || !UnRegisterDllProc || !IsRegisterDllProc || !RegisterDllUserProc || !UnRegisterDllUserProc || !SetMenuFlagsProc || !GetMenuFlagsProc || !SetAdminModeProc) { ::FreeLibrary(hShDll); hShDll = NULL; return FALSE; } SetAdminModeProc(isAdmin); return TRUE; }
BOOL ShellExt::Load(WCHAR *parent_dir, WCHAR *dll_name) { if (hShellExtDll) UnLoad(); WCHAR path[MAX_PATH]; MakePathW(path, parent_dir, dll_name); if ((hShellExtDll = TLoadLibraryW(path)) == NULL) return FALSE; RegisterDllProc = (HRESULT (WINAPI *)(void))GetProcAddress(hShellExtDll, REGISTER_PROC); UnRegisterDllProc = (HRESULT (WINAPI *)(void))GetProcAddress(hShellExtDll, UNREGISTER_PROC); IsRegisterDllProc = (BOOL (WINAPI *)(void))GetProcAddress(hShellExtDll, ISREGISTER_PROC); SetMenuFlagsProc = (BOOL (WINAPI *)(int))GetProcAddress(hShellExtDll, SETMENUFLAGS_PROC); GetMenuFlagsProc = (int (WINAPI *)(void))GetProcAddress(hShellExtDll, GETMENUFLAGS_PROC); UpdateDllProc = (BOOL (WINAPI *)(void))GetProcAddress(hShellExtDll, UPDATEDLL_PROC); if (!RegisterDllProc || !UnRegisterDllProc || !IsRegisterDllProc || !SetMenuFlagsProc || !GetMenuFlagsProc || !UpdateDllProc) { ::FreeLibrary(hShellExtDll); hShellExtDll = NULL; return FALSE; } return TRUE; }