unit uHunSpellLib;
interface
uses Windows, SysUtils;
var hunspell_initialize:
function(aff_file: PChar; dict_file: PChar): Pointer;
cdecl;
var hunspell_uninitialize:
procedure(sspel: Pointer);
cdecl;
var hunspell_spell:
function(spell: Pointer; word: PChar): Boolean;
cdecl;
var hunspell_suggest:
function(spell: Pointer; word: PChar;
var suggestions: PPChar): Integer;
cdecl;
var hunspell_suggest_auto:
function(spell: Pointer; word: PChar;
var suggestions: PPChar): Integer;
cdecl;
var hunspell_suggest_free:
procedure(spell: Pointer; suggestions: PPChar; suggestLen: Integer);
cdecl;
var hunspell_get_dic_encoding:
function(spell: Pointer): PChar;
cdecl;
var hunspell_put_word:
function(spell: Pointer; word: PChar): Integer;
cdecl;
var LibsLoaded: Boolean = False;
var DLLHandle: THandle;
function LoadLibHunspell(libraryName:
String): Boolean;
implementation
function LoadLibHunspell(libraryName:
String): Boolean;
begin
if libraryName = '
'
then
libraryName := '
hunspelldll.dll';
Result := LibsLoaded;
if Result
then //already loaded.
exit;
DLLHandle := LoadLibrary(PChar(libraryName));
if DLLHandle <> 0
then begin
Result := True;
//assume everything ok unless..
@hunspell_initialize := GetProcAddress(DLLHandle, '
hunspell_initialize');
if not Assigned(@hunspell_initialize)
then Result := False;
@hunspell_uninitialize := GetProcAddress(DLLHandle, '
hunspell_uninitialize');
if not Assigned(@hunspell_uninitialize)
then Result := False;
@hunspell_spell := GetProcAddress(DLLHandle, '
hunspell_spell');
if not Assigned(@hunspell_spell)
then Result := False;
@hunspell_suggest := GetProcAddress(DLLHandle, '
hunspell_suggest');
if not Assigned(@hunspell_suggest)
then Result := False;
@hunspell_suggest_auto := GetProcAddress(DLLHandle, '
hunspell_suggest_auto');
if not Assigned(@hunspell_suggest_auto)
then Result := False;
@hunspell_suggest_free := GetProcAddress(DLLHandle, '
hunspell_suggest_free');
if not Assigned(@hunspell_suggest_free)
then Result := False;
@hunspell_get_dic_encoding := GetProcAddress(DLLHandle, '
hunspell_get_dic_encoding');
if not Assigned(@hunspell_get_dic_encoding)
then Result := False;
@hunspell_put_word := GetProcAddress(DLLHandle, '
hunspell_put_word');
if not Assigned(@hunspell_put_word)
then Result := False;
end;
end;
initialization
finalization
if DLLHandle <> 0
then
FreeLibrary(DLLHandle);
end.