1
#include "../NKernel.h"
2
#include "NPluginInterface.h"
3
#include "NPluginManager.h"
8
void NPluginManager::GetPluginList(TCHAR * dirPath, bool addToList)
10
if(!addToList) ClearPluginList();
13
TCHAR fname[MAX_PATH];
14
STRCPY_S(fname, MAX_PATH, dirPath);
15
size_t len = _tcslen(fname);
16
if(fname[len-1] == TEXT('/') || fname[len-1] == TEXT('\\'))
17
STRCAT_S(fname, MAX_PATH, TEXT("*.dll"));
19
STRCAT_S(fname, MAX_PATH, TEXT("\\*.dll"));
20
HANDLE hFind = FindFirstFile(fname, &fd);
22
NFileName Path = dirPath;
23
Path.RemoveBackSlashAtEnd();
24
Path.RemoveSlashAtEnd();
26
if (hFind == INVALID_HANDLE_VALUE)
34
HINSTANCE dllHandle = NULL;
37
if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
39
NFileName FilePath = Path + INL_PATH_SEPARATOR_STRING + fd.cFileName;
40
dllHandle = LoadLibrary(FilePath.GetTCharPtr());
41
if (dllHandle != NULL)
43
PLUGIN_FACTORYFUNC funcHandle;
44
funcHandle = reinterpret_cast<PLUGIN_FACTORYFUNC>(GetProcAddress(dllHandle, "makePlugin"));
47
NPlugin * curPlugin = new NPlugin();
48
curPlugin->SetFileName(FilePath.GetTCharPtr());
50
PLUGIN_TEXTFUNC textFunc;
51
textFunc = reinterpret_cast<PLUGIN_TEXTFUNC>(GetProcAddress(dllHandle, "getPluginType"));
52
curPlugin->SetType(textFunc());
53
textFunc = reinterpret_cast<PLUGIN_TEXTFUNC>(GetProcAddress(dllHandle, "getPluginName"));
54
curPlugin->SetName(textFunc());
56
pluginRegister.push_back(curPlugin);
58
FreeLibrary(dllHandle);
64
if (dllHandle != NULL) FreeLibrary(dllHandle);
66
} while (FindNextFile(hFind, &fd));