Пример #1
0
void configure_enchant_provider(EnchantProvider * me, const char *dir_name)
{
#if defined(_WIN32)
    const WCHAR* aspell_module_name = L"aspell-15.dll";
    HMODULE aspell_module = NULL;
    char* szModule;

    /* first try load from registry path */
    szModule = enchant_get_registry_value ("Aspell", "Module");
    if(szModule)
    {
        WCHAR* wszModule;

        wszModule = g_utf8_to_utf16 (szModule, -1, NULL, NULL, NULL);
        aspell_module = LoadLibrary(wszModule);
        g_free(wszModule);
    }

    if (aspell_module == NULL)
    {
        /* next try load from aspell registry path */
        WCHAR* wszDirectory = GetRegistryValue (HKEY_LOCAL_MACHINE, L"Software\\Aspell", L"Path");
        if(wszDirectory)
        {
            aspell_module = LoadLibraryFromPath(wszDirectory, aspell_module_name);
            g_free(wszDirectory);
        }
    }

    if (aspell_module == NULL)
    {
        /* then try from same directory as provider */
        WCHAR* wszDirectory = GetDirectoryOfThisLibrary();
        if(wszDirectory)
        {
            aspell_module = LoadLibraryFromPath(wszDirectory, aspell_module_name);
            g_free(wszDirectory);
        }
    }

    if (aspell_module == NULL)
    {
        /* then try default lookup */
        aspell_module = LoadLibrary(aspell_module_name);
    }

    if (aspell_module == NULL)
    {
        /* we can't seem to load aspell. Avoid late binding problems later */
        g_warning("Unable to load library aspell-15.dll.");
        me->request_dict = NULL;
        me->dispose_dict = NULL;
        me->list_dicts = NULL;
    }
#endif

}
Пример #2
0
gboolean load_library(EnchantProvider * me, const char *dir_name, const WCHAR *aspell_module_name)
{
    HMODULE aspell_module = NULL;
    char* szModule;

    /* first try load from registry path */
   	szModule = enchant_get_registry_value ("Aspell", "Module");
    if(szModule)
    {
        WCHAR* wszModule;

	    wszModule = g_utf8_to_utf16 (szModule, -1, NULL, NULL, NULL);
        aspell_module = LoadLibraryW(wszModule);
        g_free(wszModule);
    }

    if (aspell_module == NULL)
        {
            /* next try load from aspell registry path */
            WCHAR* wszDirectory = GetRegistryValue (HKEY_LOCAL_MACHINE, L"Software\\Aspell", L"Path");
            if(wszDirectory)
                {
                    aspell_module = LoadLibraryFromPath(wszDirectory, aspell_module_name);
                    g_free(wszDirectory);
                }
        }

    if (aspell_module == NULL)
        {
            /* then try from same directory as provider */
            WCHAR* wszDirectory = GetDirectoryOfThisLibrary();
            if(wszDirectory)
                {
                    aspell_module = LoadLibraryFromPath(wszDirectory, aspell_module_name);
                    g_free(wszDirectory);
                }
        }

    if (aspell_module == NULL) 
        {
            /* then try default lookup */
            aspell_module = LoadLibraryW(aspell_module_name);
        }

    if (aspell_module == NULL) 
        {
	        return FALSE;
        }
    return TRUE;
}