📄 ftkernelapi.pas
字号:
//在停止时要退出正在运行的线程所以可能要稍微等待
//Stop context event driver
procedure FTK_Context_Stop(); stdcall; external FTKernelAPI_Library;
//重新根据配置文件绑定端口
//Rebind listen port
procedure FTK_Context_ReBindListenPort(); stdcall; external FTKernelAPI_Library;
//判断是否已经初始化
//Is context initialized?
function FTK_Context_IsInit(): boolean; stdcall; external FTKernelAPI_Library;
//是否监听成功了端口
//Is context running?
function FTK_Context_IsRunning(): boolean; stdcall; external FTKernelAPI_Library;
//判断是否已经运行
//Return context thread ID
function FTK_Context_GetThreadID(): DWord; stdcall; external FTKernelAPI_Library;
//获取线程的ID
//Return listening port
function FTK_Context_GetListenPort(): Word; stdcall; external FTKernelAPI_Library;
//重新指定端口绑定操作
//Return binding ip address
function FTK_Context_GetBindIP(): PChar; stdcall; external FTKernelAPI_Library;
//判断是否绑定端口操作成功
//return bind listen port status
function FTK_Context_IsBindListenPort(): Boolean; stdcall; external FTKernelAPI_Library;
//获取随机生成的用户的ID
//Get random user IDENTIFIER
function FTK_Context_GetMyPeerID(): PByte; stdcall; external FTKernelAPI_Library;
//修改强制内核提交Tracker的IP地址
//Tell kernel the ip address to submit to tracker
procedure FTK_Context_SetForceIP(lpszIP: LPCTSTR); stdcall; external FTKernelAPI_Library;
//设置兼容某些常见的错误torrent格式
//Set to open some mistake mistaken TORRENT file
procedure FTK_Context_TorrentFile(bValidEof: Boolean = True; bValidSort: Boolean = True); stdcall; external FTKernelAPI_Library;
//设置日志的语言文件
//Set language to write log
procedure FTK_Context_OpenLanguageFile(lpszLanguageFile: LPCTSTR); stdcall; external FTKernelAPI_Library;
//释放传递给外部使用的连接对象的指针(配置回调函数使用, 增加回调处理时的灵活性)
//Free socket handle to external module
procedure FTK_Context_CloseExtSocket(nSocket: Integer); stdcall; external FTKernelAPI_Library;
//设置UDPTunnel的IP和地址
//Set UDP tunnel IP and port
procedure FTK_Context_SetUDPTunnelInfo(lpszIP: PChar; nPort: Short); stdcall; external FTKernelAPI_Library;
//获取总共运行的任务的个数
//Get total torrent count
function FTK_Context_GetTorrentCount(): Integer; stdcall; external FTKernelAPI_Library;
//////////////////////////////////////////////////////////////////////////
//Context active sharing files
//增加一个Hash值(大写的不带'%'的HEX字符串)和对应的信息进来
procedure FTK_Context_ShareTorrent(lpszInfoHex: LPCTSTR; lpszAnnounce: LPCTSTR); stdcall; external FTKernelAPI_Library;
//删除一个Hash值及其附带的对应信息
procedure FTK_Context_UnshareTorrent(lpszInfoHex: LPCTSTR); stdcall; external FTKernelAPI_Library;
//////////////////////////////////////////////////////////////////////////
//Downloader interface
//Create a new HDownloader handle
function FTK_Downloader_Open(): HDownloader; stdcall; external FTKernelAPI_Library;
//Destroy a HDownloader hanle
procedure FTK_Downloader_Close(hDownloader: HDownloader); stdcall; external FTKernelAPI_Library;
//提前的初始化IP过滤对象的函数(FTK_Downloader_Init* 函数之前调用), 过滤某些段的IP地址, "ipfilter.dat" 文件和eMule(电骡)兼容
//Previous Initialize IP filter object to filter some peer's IP, "ipfilter.dat" file is compatiable with eMule.
function FTK_Downloader_PreInitIPFilter(hDownloader: HDownloader; lpszIPFilterFile: LPCTSTR; nLevel: UINT = 127): Boolean; stdcall; external FTKernelAPI_Library;
//提前的初始化, 按照块的先后顺序进行下载(适用于边下载边播放的情况)
//Previous Initialize, Tell kernel to sequential download piece
procedure FTK_Downloader_PreInitSEQMode(hDownloader: HDownloader; nSEQFileIndex: Integer); stdcall; external FTKernelAPI_Library;
//预先初始化文件选择下载的优先级别
//数组中,每个元素的值表示: -2:不下载, -1: 低, 0: 一般, 1:高
//Previous Initialize, Tell kernel to Set priority of file
//-2: no download, -1: low, 0: middle, 1: high
procedure FTK_Downloader_PreInitFilePriority(hDownloader: HDownloader; pFilePriority: PChar; nFilesCount: Integer); stdcall; external FTKernelAPI_Library;
//预先初始化Tracker列表,使用外部提供的Tracker列表,替代Torrent文件中的Tracker列表
//Tracker1;Tracker2;Tracker3|Tracker1;Tracker2|Tracker1;Tracker2
procedure FTK_Downloader_PreInitTrackers(hDownloader: HDownloader; lpszAnnouces: LPCTSTR); stdcall; external FTKernelAPI_Library;
//预先初始化远程连接自己的Socket的句柄值
//Previous Initialize, Tell kernel to add a remote [socket] to queue
procedure FTK_Downloader_PreInitSocket(hDownloader: HDownloader; nSocket: Integer); stdcall; external FTKernelAPI_Library;
//预先初始化远程连接自己的UDP呼叫的信息
//Previous Initialize, Tell kernel to add a remote ip and port to queue
procedure FTK_Downloader_PreInitSource(hDownloader: HDownloader; pchIP: PChar; nPort: Short; pPeerID: PByte; nTunnel: BYTE); stdcall; external FTKernelAPI_Library;
//初始化下载对象
//Initialize a HDownloader
//@lpszTorrentFileName: a torrent file name
//@pPreAllocFile: a array of preallocated files, 0->no, 1->yes
//@nPreAllocFileLen: length of preallocated array
//@bOnlyCheckFile: only verify data of files
//@lpszDestFileName: the downloaded filename
//@lpszConfig: kernel configuration file - INI file
//@lpszLogFileName: output log filename
//@lpszStatusFileName: downloading status filename
//@lpszDesKey: DES-EDE2 password
//@nCodePage: code page of the torrent file
function FTK_Downloader_Init(
hDownloader: HDownloader;
lpszTorrentFileName: LPCTSTR;
pPreAllocFile: PByte;
nPreAllocFileLen: Integer;
bOnlyCheckFile: boolean = FALSE;
lpszDestFileName: LPCTSTR = nil;
lpszConfig: LPCTSTR = nil;
lpszLogFileName: LPCTSTR = nil;
lpszStatusFileName: LPCTSTR = nil;
bQuickySeed: Boolean = False;
lpszDesKey: LPCTSTR = nil;
nCodePage: UINT = CP_ACP): boolean; stdcall; external FTKernelAPI_Library;
//初始化下载对象
//Initialize a HDownloader
//@lpszTorrentFileName: a torrent file name
//@pPreAllocFile: a array of preallocated files, 0->no, 1->yes
//@nPreAllocFileLen: length of preallocated array
//@bOnlyCheckFile: only verify data of files
//@lpszDestFileName: the downloaded filename
//@lpszConfig: kernel configuration file - INI file
//@lpszLogFileName: output log filename
//@lpszStatusFileName: downloading status filename
//@lpszDesKey: DES-EDE2 password
//@nCodePage: code page of the torrent file
function FTK_Downloader_Init2(
hDownloader: HDownloader;
lpszTorrentFileName: LPCTSTR;
pPreAllocFile: PByte;
nPreAllocFileLen: Integer;
bOnlyCheckFile: boolean = FALSE;
lpszDestFileName: LPCTSTR = nil;
hConfigIni: HConfigIni = nil;
lpszLogFileName: LPCTSTR = nil;
lpszStatusFileName: LPCTSTR = nil;
bQuickySeed: Boolean = False;
lpszDesKey: LPCTSTR = nil;
nCodePage: UINT = CP_ACP): boolean; stdcall; external FTKernelAPI_Library;
//初始化下载对象3
//Initialize a HDownloader
//@pData: a torrent binary object, a pointer to a binary torrent file content
//@nLength: the length of a torrent binary object
//@pPreAllocFile: a array of preallocated files, 0->no, 1->yes
//@nPreAllocFileLen: length of preallocated array
//@bOnlyCheckFile: only verify data of files
//@lpszDestFileName: the downloaded filename
//@lpszConfig: kernel configuration file - INI file
//@lpszLogFileName: output log filename
//@lpszStatusFileName: downloading status filename
//@lpszDesKey: DES-EDE2 password
//@nCodePage: code page of the torrent file
function FTK_Downloader_Init3(
hDownloader: HDownloader;
pData: PChar;
nLength: Integer;
pPreAllocFile: PByte;
nPreAllocFileLen: Integer;
bOnlyCheckFile: Boolean = False;
lpszDestFileName: LPCTSTR = nil;
lpszConfig: LPCTSTR = nil;
lpszLogFileName: LPCTSTR = nil;
lpszStatusFileName: LPCTSTR = nil;
bQuicklySeed: Boolean = False;
lpszDesKey: LPCTSTR = nil;
nCodePage: UINT = CP_ACP): boolean; stdcall; external FTKernelAPI_Library;
//初始化下载对象4
//Initialize a HDownloader
//@pData: a torrent binary object, a pointer to a binary torrent file content
//@nLength: the length of a torrent binary object
//@pPreAllocFile: a array of preallocated files, 0->no, 1->yes
//@nPreAllocFileLen: length of preallocated array
//@bOnlyCheckFile: only verify data of files
//@lpszDestFileName: the downloaded filename
//@hConfigIni: kernel configuration file handle - INI file
//@lpszLogFileName: output log filename
//@lpszStatusFileName: downloading status filename
//@lpszDesKey: DES-EDE2 password
//@nCodePage: code page of the torrent file
function FTK_Downloader_Init4(
hDownloader: HDownloader;
pData: PChar;
nLength: Integer;
pPreAllocFile: PByte;
nPreAllocFileLen: Integer;
bOnlyCheckFile: Boolean = False;
lpszDestFileName: LPCTSTR = nil;
hConfigIni: HConfigIni = nil;
lpszLogFileName: LPCTSTR = nil;
lpszStatusFileName: LPCTSTR = nil;
bQuicklySeed: Boolean = False;
lpszDesKey: LPCTSTR = nil;
nCodePage: UINT = CP_ACP): boolean; stdcall; external FTKernelAPI_Library;
//初始化下载对象
//Initialize a HDownloader
//@lpszTorrentFileName: a torrent file name
//@pPreAllocFile: a array of preallocated files, 0->no, 1->yes
//@nPreAllocFileLen: length of preallocated array
//@bOnlyCheckFile: only verify data of files
//@lpszDestFileName: the downloaded filename
//@lpszConfig: kernel configuration file - INI file
//@lpszLogFileName: output log filename
//@lpszStatusFileName: downloading status filename
//@lpszDesKey: DES-EDE2 password
//@nCodePage: code page of the torrent file
function FTK_Downloader_Init5(
hDownloader: HDownloader;
lpszFTKLink: LPCTSTR;
lpszTorrentFileName: LPCTSTR;
pPreAllocFile: PByte;
nPreAllocFileLen: Integer;
bOnlyCheckFile: boolean = FALSE;
lpszDestFileName: LPCTSTR = nil;
lpszConfig: LPCTSTR = nil;
lpszLogFileName: LPCTSTR = nil;
lpszStatusFileName: LPCTSTR = nil;
bQuickySeed: Boolean = False;
lpszDesKey: LPCTSTR = nil;
nCodePage: UINT = CP_ACP): boolean; stdcall; external FTKernelAPI_Library;
//初始化下载对象
//Initialize a HDownloader
//@lpszTorrentFileName: a torrent file name
//@pPreAllocFile: a array of preallocated files, 0->no, 1->yes
//@nPreAllocFileLen: length of preallocated array
//@bOnlyCheckFile: only verify data of files
//@lpszDestFileName: the downloaded filename
//@lpszConfig: kernel configuration file - INI file
//@lpszLogFileName: output log filename
//@lpszStatusFileName: downloading status filename
//@lpszDesKey: DES-EDE2 password
//@nCodePage: code page of the torrent file
function FTK_Downloader_Init6(
hDownloader: HDownloader;
lpszFTKLink: LPCTSTR;
lpszTorrentFileName: LPCTSTR;
pPreAllocFile: PByte;
nPreAllocFileLen: Integer;
bOnlyCheckFile: boolean = FALSE;
lpszDestFileName: LPCTSTR = nil;
hConfigIni: HConfigIni = nil;
lpszLogFileName: LPCTSTR = nil;
lpszStatusFileName: LPCTSTR = nil;
bQuickySeed: Boolean = False;
lpszDesKey: LPCTSTR = nil;
nCodePage: UINT = CP_ACP): boolean; stdcall; external FTKernelAPI_Library;
//释放下载对象
//Release downloader handle
function FTK_Downloader_Release(hDownloader: HDownloader): boolean; stdcall; external FTKernelAPI_Library;
//执行下载线程
//Execute downloader
function FTK_Downloader_Execute(hDownloader: HDownloader): boolean; stdcall; external FTKernelAPI_Library;
//暂停下载
//Pause downloader
procedure FTK_Downloader_Pause(hDownloader: HDownloader); stdcall; external FTKernelAPI_Library;
//恢复下载
//Resume downloader
procedure FTK_Downloader_Resume(hDownloader: HDownloader); stdcall; external FTKernelAPI_Library;
//是否已经初始化
//Is downloader intialized?
function FTK_Downloader_IsInit(hDownloader: HDownloader): boolean; stdcall; external FTKernelAPI_Library;
//获取下载任务目前的阶段状态
//Return downloader state
function FTK_Downloader_GetState(hDownloader: HDownloader): Integer stdcall; external FTKernelAPI_Library;
//是否只是进行文件检查
//Only checking file, don't downloading...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -