コード例 #1
0
        /// <summary>
        /// Load dll dynamic + set pointers to needed methods
        /// </summary>
        /// <param name="baseFolder"></param>
        private void LoadLibVoikkoDynamic(string baseFolder)
        {
            string dllFile = Path.Combine(baseFolder, "Voikkox86.dll");

            if (IntPtr.Size == 8)
            {
                dllFile = Path.Combine(baseFolder, "Voikkox64.dll");
            }
            if (!File.Exists(dllFile))
            {
                throw new FileNotFoundException(dllFile);
            }
            _libDll = NativeMethods.LoadLibrary(dllFile);
            if (_libDll == IntPtr.Zero)
            {
                throw new FileLoadException("Unable to load " + dllFile);
            }

            _voikkoInit          = (VoikkoInit)GetDllType(typeof(VoikkoInit), "voikkoInit");
            _voikkoTerminate     = (VoikkoTerminate)GetDllType(typeof(VoikkoTerminate), "voikkoTerminate");
            _voikkoSpell         = (VoikkoSpell)GetDllType(typeof(VoikkoSpell), "voikkoSpellCstr");
            _voikkoSuggest       = (VoikkoSuggest)GetDllType(typeof(VoikkoSuggest), "voikkoSuggestCstr");
            _voikkoFreeCstrArray = (VoikkoFreeCstrArray)GetDllType(typeof(VoikkoFreeCstrArray), "voikkoFreeCstrArray");

            if (_voikkoInit == null || _voikkoTerminate == null || _voikkoSpell == null || _voikkoSuggest == null || _voikkoFreeCstrArray == null)
            {
                throw new FileLoadException("Not all methods in Voikko dll could be found!");
            }
        }
コード例 #2
0
        /// <summary>
        /// Load dll dynamic + set pointers to needed methods
        /// </summary>
        /// <param name="baseFolder"></param>
        private void LoadLibVoikkoDynamic(string baseFolder)
        {
            string dllFile = Path.Combine(baseFolder, "Voikkox86.dll");
            if (IntPtr.Size == 8)
                dllFile = Path.Combine(baseFolder, "Voikkox64.dll");
            if (!File.Exists(dllFile))
                throw new FileNotFoundException(dllFile);
            _libDll = LoadLibrary(dllFile);
            if (_libDll == IntPtr.Zero)
                throw new FileLoadException("Unable to load " + dllFile);

            _voikkoInit = (VoikkoInit)GetDllType(typeof(VoikkoInit), "voikkoInit");
            _voikkoTerminate = (VoikkoTerminate)GetDllType(typeof(VoikkoTerminate), "voikkoTerminate");
            _voikkoSpell = (VoikkoSpell)GetDllType(typeof(VoikkoSpell), "voikkoSpellCstr");
            _voikkoSuggest = (VoikkoSuggest)GetDllType(typeof(VoikkoSuggest), "voikkoSuggestCstr");
            _voikkoFreeCstrArray = (VoikkoFreeCstrArray)GetDllType(typeof(VoikkoFreeCstrArray), "voikkoFreeCstrArray");

            if (_voikkoInit == null || _voikkoTerminate == null || _voikkoSpell == null || _voikkoSuggest == null || _voikkoFreeCstrArray == null)
                throw new FileLoadException("Not all methods in Voikko dll could be found!");
        }