用金山词霸进行屏幕取词

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, XDICTGRB_TLB; type TForm1 = class(TForm, IXdictGrabSink) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } function QueryWord(const WordString: WideString; lCursorX: Integer; lCursorY: Integer; const SentenceString: WideString; var lLoc: Integer; var lStart: Integer): Integer;safecall; end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var GrabProxy: TGrabProxy; begin GrabProxy:= TGrabProxy.Create(nil); GrabProxy.GrabInterval:= 1; GrabProxy.GrabMode:= XDictGrabMouseWithCtrl; GrabProxy.GrabEnabled:= True; GrabProxy.AdviseGrab(Self); end; function TForm1.QueryWord(const WordString: WideString; lCursorX, lCursorY: Integer; const SentenceString: WideString; var lLoc, lStart: Integer): Integer; begin Caption:= SentenceString; end; end.

 

1.本例子是根据网上查到一个例子改编的,原例子是C#写的;

2.本例要用到金山词霸2005自带的XdictGrb.dll,网上可以搜一下,csdn下载频道也有下载;

3.取得XdictGrb.dll文件后,用RegSvr32命令注册,然后使用Delphi的 install Component—>Import Typle library—>XdictGrb 1.0 Type library生成TLB文件,直接使用其中的TGrabProxy类即可;

你可能感兴趣的:(function,Integer,library,金山,Delphi,Forms)