Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Hunspell unter Delphi 2009 (https://www.delphipraxis.net/140266-hunspell-unter-delphi-2009-a.html)

Flamingo 14. Sep 2009 23:49


Hunspell unter Delphi 2009
 
Hallo,

ich portiere gerade eine Anwendung auf Delphi 2009 und muss leider feststellen, dass die bis jetzt gut funktionierende hunspell-Unit einfach rein garnichts mehr macht. Da hier leider auch vollständig auf Errorreporting verzeichtet wurde, hab ich keinen Anhaltspunkt warum es nicht geht, fakt ist auf jeden Fall, dass kein Wort mehr erkannt und auch keine Vorschläge geliefert werden. Hat jemand von euch da einen Ansatz?

Mein Aufruf:
Delphi-Quellcode:
if loadlibhunspell(extractfilepath(application.exename)+'hunspelldll.dll') then showmessage('loaded');
p := hunspell_initialize(PChar(extractfilepath(application.exename)+'dict/en_US.aff'), PChar(extractfilepath(application.exename)+'dict/en_US.dic'));
if hunspell_spell(p, PChar('good')) then
  showmessage('juhuu');
(loaded wird noch angezeigt)

uHunSpellLib.pas:
Delphi-Quellcode:
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.

mkinzler 15. Sep 2009 05:39

Re: Hunspell unter Delphi 2009
 
Ich vermute mal die Funktionen xbenötigen Ansistrings: PChar -> PAnsiChar


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:03 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz