コード例 #1
0
                internal Speller(string path)
                {
                    IntPtr ptr;

                    this.libraryHandle = KernalNativeMethods.LoadLibrary(path);
                    if (this.libraryHandle == IntPtr.Zero)
                    {
                        throw new Win32Exception();
                    }

                    ProofInit       proc            = GetProc <ProofInit>(this.libraryHandle, "SpellerInit");
                    ProofSetOptions proofSetOptions = GetProc <ProofSetOptions>(this.libraryHandle, "SpellerSetOptions");

                    this.terminate = GetProc <ProofTerminate>(this.libraryHandle, "SpellerTerminate");
                    this.openLex   = GetProc <ProofOpenLex>(this.libraryHandle, "SpellerOpenLex");
                    this.closeLex  = GetProc <ProofCloseLex>(this.libraryHandle, "SpellerCloseLex");
                    this.check     = GetProc <SpellerCheck>(this.libraryHandle, "SpellerCheck");
                    this.addUdr    = GetProc <SpellerAddUdr>(this.libraryHandle, "SpellerAddUdr");
                    this.deleteUdr = GetProc <SpellerDelUdr>(this.libraryHandle, "SpellerDelUdr");
                    this.clearUdr  = GetProc <SpellerClearUdr>(this.libraryHandle, "SpellerClearUdr");
                    ProofParams pxpar = new ProofParams {
                        VersionApi = 0x3000000
                    };

                    CheckErrorCode(proc(out ptr, ref pxpar));
                    this.id = ptr;
                    CheckErrorCode(proofSetOptions(ptr, 0, 0x20006));
                    this.InitIgnoreDictionary();
                }
コード例 #2
0
                private void Dispose(bool disposing)
                {
                    try
                    {
                        if (this.lexicons != null)
                        {
                            foreach (IntPtr ptr in this.lexicons)
                            {
                                CheckErrorCode(this.closeLex(this.id, ptr, true));
                            }

                            this.lexicons = null;
                        }

                        if (this.id != IntPtr.Zero)
                        {
                            CheckErrorCode(this.terminate(this.id, true));
                            this.id = IntPtr.Zero;
                        }

                        if (this.libraryHandle != IntPtr.Zero)
                        {
                            if (!KernalNativeMethods.FreeLibrary(this.libraryHandle))
                            {
                                throw new Win32Exception();
                            }

                            this.libraryHandle = IntPtr.Zero;
                        }
                    }
                    finally
                    {
                        if (disposing)
                        {
                            this.terminate = null;
                            this.closeLex  = null;
                            this.openLex   = null;
                            this.check     = null;
                            this.addUdr    = null;
                            this.clearUdr  = null;
                            this.deleteUdr = null;
                        }
                    }
                }