| 11 | std::vector<PRECLASS_PLUGIN> g_LoadedPlugins; |
| 12 | |
| 13 | VOID |
| 14 | LoadPlugins( |
| 15 | VOID |
| 16 | ) |
| 17 | { |
| 18 | PRECLASS_PLUGIN Plugin; |
| 19 | HMODULE PluginBase; |
| 20 | |
| 21 | HANDLE FileTreeHandle; |
| 22 | WIN32_FIND_DATA FileData; |
| 23 | |
| 24 | PPLUGIN_INIT PluginInitFunction; |
| 25 | PPLUGIN_STATE_CHANGE PluginStateChangeFunction; |
| 26 | DLGPROC PluginSettingDlgFunction; |
| 27 | |
| 28 | //TCHAR ModulePath[MAX_PATH]; |
| 29 | //GetModuleFileName( GetModuleHandle( NULL ), ModulePath, MAX_PATH ); |
| 30 | |
| 31 | #if defined(_M_AMD64) |
| 32 | #ifndef _DEBUG |
| 33 | FileTreeHandle = FindFirstFile( _T( "plugins\\*.rc-plugin64" ), &FileData ); |
| 34 | #else |
| 35 | FileTreeHandle = FindFirstFile( _T( "plugins\\*.rc-plugin64d" ), &FileData ); |
| 36 | #endif |
| 37 | #else |
| 38 | #ifndef _DEBUG |
| 39 | FileTreeHandle = FindFirstFile( _T( "plugins\\*.rc-plugin" ), &FileData ); |
| 40 | #else |
| 41 | FileTreeHandle = FindFirstFile( _T( "plugins\\*.rc-plugind" ), &FileData ); |
| 42 | #endif |
| 43 | #endif |
| 44 | if (FileTreeHandle != INVALID_HANDLE_VALUE) |
| 45 | { |
| 46 | do |
| 47 | { |
| 48 | PluginBase = LoadLibrary( CString( _T( "plugins\\" ) ) + FileData.cFileName ); |
| 49 | if (PluginBase == NULL) |
| 50 | { |
| 51 | PrintOut( _T( "plugin %s was not able to be loaded!" ), FileData.cFileName ); |
| 52 | continue; |
| 53 | } |
| 54 | |
| 55 | PluginInitFunction = (PPLUGIN_INIT)GetProcAddress( PluginBase, "PluginInit" ); |
| 56 | if (!PluginInitFunction) |
| 57 | { |
| 58 | PrintOut( _T( "%s is not a reclass plugin!" ), FileData.cFileName ); |
| 59 | FreeLibrary( PluginBase ); |
| 60 | continue; |
| 61 | } |
| 62 | |
| 63 | PluginStateChangeFunction = (PPLUGIN_STATE_CHANGE)GetProcAddress( PluginBase, "PluginStateChange" ); |
| 64 | if (!PluginStateChangeFunction) |
| 65 | { |
| 66 | PrintOut( _T( "%s doesnt have exported state change function! " |
| 67 | "Unable to disable plugin on request, stop reclass and delete the plugin to disable it" ), FileData .cFileName ); |
| 68 | } |
| 69 | |
| 70 | PluginSettingDlgFunction = (DLGPROC)GetProcAddress( PluginBase, "PluginSettingsDlg" ); |