这个C++Dll文件结口怎么在DELPHI中调用???????

gjzsdesign 2008-03-13 04:19:12
如题:接口如下:
#ifndef _UDT_H_
#define _UDT_H_


#ifndef WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#else
#include <windows.h>
#endif
#include <fstream>
#include <set>
#include <string>


////////////////////////////////////////////////////////////////////////////////

#ifdef WIN32
// Explicitly define 32-bit and 64-bit numbers
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int32 uint32_t;
#if _MSC_VER > = 1300
typedef unsigned __int64 uint64_t;
#else
// VC 6.0 does not support unsigned __int64: may bring potential problems.
typedef __int64 uint64_t;
#endif

#ifdef UDT_EXPORTS
#define UDT_API __declspec(dllexport)
#else
#define UDT_API __declspec(dllimport)
#endif
#else
#define UDT_API
#endif

#define NO_BUSY_WAITING


typedef int UDTSOCKET;

typedef std::set <UDTSOCKET> ud_set;
#define UD_CLR(u, uset) ((uset)-> erase(u))
#define UD_ISSET(u, uset) ((uset)-> find(u) != (uset)-> end())
#define UD_SET(u, uset) ((uset)-> insert(u))
#define UD_ZERO(uset) ((uset)-> clear())

////////////////////////////////////////////////////////////////////////////////

enum UDTOpt
{
UDT_MSS, // the Maximum Transfer Unit
UDT_SNDSYN, // if sending is blocking
UDT_RCVSYN, // if receiving is blocking
UDT_CC, // custom congestion control algorithm
UDT_FC, // Flight flag size (window size)
UDT_SNDBUF, // maximum buffer in sending queue
UDT_RCVBUF, // UDT receiving buffer size
UDT_LINGER, // waiting for unsent data when closing
UDP_SNDBUF, // UDP sending buffer size
UDP_RCVBUF, // UDP receiving buffer size
UDT_MAXMSG, // maximum datagram message size
UDT_MSGTTL, // time-to-live of a datagram message
UDT_RENDEZVOUS, // rendezvous connection mode
UDT_SNDTIMEO, // send() timeout
UDT_RCVTIMEO, // recv() timeout
UDT_REUSEADDR // reuse an existing port or create a new one
};

////////////////////////////////////////////////////////////////////////////////

struct CPerfMon
{
// global measurements
int64_t msTimeStamp; // time since the UDT entity is started, in milliseconds
int64_t pktSentTotal; // total number of sent data packets, including retransmissions
int64_t pktRecvTotal; // total number of received packets
int pktSndLossTotal; // total number of lost packets (sender side)
int pktRcvLossTotal; // total number of lost packets (receiver side)
int pktRetransTotal; // total number of retransmitted packets
int pktSentACKTotal; // total number of sent ACK packets
int pktRecvACKTotal; // total number of received ACK packets
int pktSentNAKTotal; // total number of sent NAK packets
int pktRecvNAKTotal; // total number of received NAK packets

// local measurements
int64_t pktSent; // number of sent data packets, including retransmissions
int64_t pktRecv; // number of received packets
int pktSndLoss; // number of lost packets (sender side)
int pktRcvLoss; // number of lost packets (receiverer side)
int pktRetrans; // number of retransmitted packets
int pktSentACK; // number of sent ACK packets
int pktRecvACK; // number of received ACK packets
int pktSentNAK; // number of sent NAK packets
int pktRecvNAK; // number of received NAK packets
double mbpsSendRate; // sending rate in Mb/s
double mbpsRecvRate; // receiving rate in Mb/s

// instant measurements
double usPktSndPeriod; // packet sending period, in

...全文
173 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
meiZiNick 2008-04-30
  • 打赏
  • 举报
回复
我也想了解,谢谢LZ.
gjzsdesign 2008-03-13
  • 打赏
  • 举报
回复
////////////////////////////////////////////////////////////////////////////////

namespace UDT
{
typedef CUDTException ERRORINFO;
typedef UDTOpt SOCKOPT;
typedef CPerfMon TRACEINFO;
typedef ud_set UDSET;

UDT_API extern const UDTSOCKET INVALID_SOCK;
#undef ERROR
UDT_API extern const int ERROR;

UDT_API UDTSOCKET socket(int af, int type, int protocol);

UDT_API int bind(UDTSOCKET u, const struct sockaddr* name, int namelen);

UDT_API int listen(UDTSOCKET u, int backlog);

UDT_API UDTSOCKET accept(UDTSOCKET u, struct sockaddr* addr, int* addrlen);

UDT_API int connect(UDTSOCKET u, const struct sockaddr* name, int namelen);

UDT_API int close(UDTSOCKET u);

UDT_API int getpeername(UDTSOCKET u, struct sockaddr* name, int* namelen);

UDT_API int getsockname(UDTSOCKET u, struct sockaddr* name, int* namelen);

UDT_API int getsockopt(UDTSOCKET u, int level, SOCKOPT optname, void* optval, int* optlen);

UDT_API int setsockopt(UDTSOCKET u, int level, SOCKOPT optname, const void* optval, int optlen);

UDT_API int send(UDTSOCKET u, const char* buf, int len, int flags);

UDT_API int recv(UDTSOCKET u, char* buf, int len, int flags);

UDT_API int sendmsg(UDTSOCKET u, const char* buf, int len, int ttl = -1, bool inorder = false);

UDT_API int recvmsg(UDTSOCKET u, char* buf, int len);

UDT_API int64_t sendfile(UDTSOCKET u, std::ifstream& ifs, int64_t offset, int64_t size, int block = 364000);

UDT_API int64_t recvfile(UDTSOCKET u, std::ofstream& ofs, int64_t offset, int64_t size, int block = 7280000);

UDT_API int select(int nfds, UDSET* readfds, UDSET* writefds, UDSET* exceptfds, const struct timeval* timeout);

UDT_API ERRORINFO& getlasterror();

UDT_API int perfmon(UDTSOCKET u, TRACEINFO* perf, bool clear = true);
}

#endif
gjzsdesign 2008-03-13
  • 打赏
  • 举报
回复
microseconds
int pktFlowWindow; // flow window size, in number of packets
int pktCongestionWindow; // congestion window size, in number of packets
int pktFlightSize; // number of packets on flight
double msRTT; // RTT, in milliseconds
double mbpsBandwidth; // estimated bandwidth, in Mb/s
int byteAvailSndBuf; // available UDT sender buffer size
int byteAvailRcvBuf; // available UDT receiver buffer size
};

////////////////////////////////////////////////////////////////////////////////

class UDT_API CUDTException
{
public:
CUDTException(int major = 0, int minor = 0, int err = -1);
CUDTException(const CUDTException& e);
virtual ~CUDTException();

// Functionality:
// Get the description of the exception.
// Parameters:
// None.
// Returned value:
// Text message for the exception description.

virtual const char* getErrorMessage();

// Functionality:
// Get the system errno for the exception.
// Parameters:
// None.
// Returned value:
// errno.

virtual const int getErrorCode() const;

// Functionality:
// Clear the error code.
// Parameters:
// None.
// Returned value:
// None.

virtual void clear();

private:
int m_iMajor; // major exception categories

// 0: correct condition
// 1: network setup exception
// 2: network connection broken
// 3: memory exception
// 4: file exception
// 5: method not supported
// 6+: undefined error

int m_iMinor; // for specific error reasons
int m_iErrno; // errno returned by the system if there is any
std::string m_strMsg; // text error message
public: // Error Code
static const int SUCCESS;
static const int ECONNSETUP;
static const int ENOSERVER;
static const int ECONNREJ;
static const int ESOCKFAIL;
static const int ESECFAIL;
static const int ECONNFAIL;
static const int ECONNLOST;
static const int ENOCONN;
static const int ERESOURCE;
static const int ETHREAD;
static const int ENOBUF;
static const int EFILE;
static const int EINVRDOFF;
static const int ERDPERM;
static const int EINVWROFF;
static const int EWRPERM;
static const int EINVOP;
static const int EBOUNDSOCK;
static const int ECONNSOCK;
static const int EINVPARAM;
static const int EINVSOCK;
static const int EUNBOUNDSOCK;
static const int ENOLISTEN;
static const int ERDVNOSERV;
static const int ERDVUNBOUND;
static const int ESTREAMILL;
static const int EDGRAMILL;
static const int EDUPLISTEN;
static const int ELARGEMSG;
static const int EASYNCFAIL;
static const int EASYNCSND;
static const int EASYNCRCV;
static const int EUNKNOWN;
};
加密狗系列—软件狗 面向单机环境的低成本加密方案   软件狗是使用在计算机并行口和USB口上的用于软件保护的硬件产品。软件狗采用端口噪声技术,提供100字节的掉电保护存储器,具备反跟踪能力,是经济实用软件保护解决方案的首选。软件狗开发套件有两种选型:并口型和USB型。软件开发商可以采用多种方法保护软件,防止软件被非法拷贝使用。软件狗开发套件由:软件狗、加密接口、开发商工具等组成。 1.软件狗 软件狗指安装在并口上或 USB 口上的硬件狗。软件狗是一个可编程、可读写的存储设备,具有 100 个字节的数据存储区。如果软件狗插在计算机上,您可以通过相应的加密接口函数或开发商工具对软件狗进行访问。 2.加密接口 软件狗开发套件提供的加密接口是一套包含各种开发语言的程序接口模块,可以嵌在程序的源代码。您可以在您程序使用软件狗开发套件提供的加密接口对软件狗进行操作。 3.开发商工具(DogEdt32.EXE) 软件狗开发商工具可以使开发商方便地对软件狗存储区进行编辑、读取系列号以及连续初始化等操作。 工作原理: 开发商程序通过调用软件狗开发套件提供的接口模块对软件狗操作,软件狗响应该操作并通过接口模块将相应数据返回给开发商程序。开发商程序可以对返回值进行判定并采取相应的动作。如果返回无效的响应,表明没有正确的软件狗,开发商可以将应用程序终止运行。 简要示意如下: 软件狗开发套件提供了两种加密方案:使用 Obj 、 DLL 、 ActiveX 控件或者直接使用外壳工具,请根据您的需求选择方案。 加密方案一:使用 Obj 、 DLL 、 ActiveX 控件 Obj 、 DLL 、 ActiveX 控件提供了操作软件狗的接口函数,您可以直接在应用程序的源代码里加入这些接口函数的调用,来保护您的一个或者多个软件,然后重新编译您的应用程序。 由您来设置应用程序调用加密接口的次数以及没有发现软件狗采取的措施。原则上您调用、设置的加密接口越多将更有利于阻止潜在破坏您的软件保护。 加密方案二:使用外壳工具 使用外壳工具对软件保护是一种快速、简单的保护方案。它不象使用接口函数需要对源代码进行改动,而是自动给您的可执行应用程序加了一个保护层。在程序开始运行和运行当会自动地访问软件狗是否存在。假如软件狗不存在,用户将看到一个错误提示,该应用程序将不能运行。 产品特点: 软件狗开发套件适用于 DOS 、 Windows 3X/9X/ME/NT/2000/XP 、 Linux 操作系统,支持几乎所有主流编程语言、开发工具。软件狗的主要特点如下: 数据交换随机噪声技术 有效地对抗逻辑分析仪及各种调试工具的攻击,完全禁止软件仿真程序模拟并口的数据。 迷宫技术 在 RC-DL 函数入口和出口之间包含大量复杂的判断跳转干扰代码,动态改变执行次序,提升 RC-DL 的抗跟踪能力。 时间闸 硬件狗内部设有时间闸,各种操作必须在规定的时间内完成。硬件狗正常操作用时很短,但跟踪时用时较长,超过规定时间,硬件狗将返回错误结果。 AS 技术 API 函数调用与 SHELL 外壳加密相结合的方式,同时使用能够达到极高的加密强度。 RC-DL 开发套件在外壳加密工具调用的 API 函数建立了对应关系。这样处理后,程序调用的 API 函数只有在有外壳的情况下才能正确运行,而外壳本身隐蔽了对 API 函数的调用。 抗共享 可以通过编程的方式实现对抗并口共享器。 存储器 提供 100 字节掉电保持数据存储区供开发商存放关键数据、配置参数等信息,可通过 RC-DL 开发商工具或接口函数对存储区进行读写。 改良的硬件驱动程序 驱动程序的安装及发布更加方便、快捷,开发商只需使用 InstDrv.exe 安装驱动程序,硬件即可正常工作。 崭新的硬件狗编辑工具 DogEdt32.exe 集成了原有 DogEdt32.exe 、 Reveal.exe 、 Convert.exe 三个工具,并新增错误码查询功能,令硬件狗编辑调试过程更趋简捷、顺畅。 高强度动态库加密方式 在原有加密方式基础上,新增 C 语言高强度动态库加密方式,并有效运用动态库认证安全机制,确保动态库调用具有无与伦比的安全可靠性。 支持 ActiveX 控件 开发商可以在网页或 VB 、 VC 使用 ActiveX 控件对硬件狗进行操作。 Linux 模块 提供了针对 Linux 内核 2.2 和 2.4 版本驱动程序,开发商可以使用 Linux 模块保护运行于 Linux 操作系统上的应用程序。 新增功能: 软件狗开发套件 3.0 版新增功能在软件狗开发套件 V3.0 ,新增了与原并口硬件完全兼容的 UDA 型 USB 软件狗。 USB 软件狗也提供了 100 字节的用户存储区。新的开发商工具( DogEdt32.EXE )或接口函数既可以老的并口硬件,也可以对新的 USB 硬件进行操作。 已安装了软件狗开发套件 V2.1 的老用户如要使用 UDA 型 USB 软件狗,必须重新安装软件狗开发套件 V3.0 ,以安装 UDA 型 USB 软件狗的驱动程序并更新开发套件的 OBJ 。 开发商如果使用 WIN32 模块,在 Windows98 或更高版本( WindowsME/2K/XP )下既可以使用 USB 软件狗也可以使用并口软件狗。目前暂不提供 USB 软件狗在 Windows NT4 上的驱动程序,即在 Windows NT4 操作系统上,目前只能使用并口软件狗。 在安装 Linux2.4 以上内核的 Linux 系统,既可以使用并口软件狗也可以使用 USB 软件狗。 WIN16 、 DOS16 、 DOS32 模块本次没有改动,仍只支持并口软件狗。 软件狗开发套件 目前最新版本为 v3.0 支持并口硬件 RC-DL (现已更名为 PDL ) , 支持 USB 口硬件 UDA 适用语言环境: 并口型软件狗: DOS16: C , C++, FORTRAN, ASM, Pascal, BASIC ( BASCOM, Quick,True, Turbo ) , FOXPRO, Clipper, Foxbase, Dbase, EXE/COM 文件;DOS32: C, C++ ( High, NDP, Watcom ), FORTRAN ( NDP, PowerStation,Watcom) , EXP 文件; Win16: C, C++ ( Borland, Visual ), Visual BASIC, FOXPRO, PowerBuilder,Delphi Win32: C, C++ ( Visual, Borland, C++Builder, MFC ), FORTRAN ( LAHEY,PowerStation, Visual ), Java, VisualBasic, VisualFoxpro, PowerBuilder,Delphi,JavaScript, VBScript, VBA, InstallShield, AutoCAD, .NET 等。 Linux: C, C++, Java USB 型软件狗: Win32: C, C++ ( Visual, Borland, C++Builder, MFC), FORTRAN ( LAHEY, PowerStation, Visual ), Java, VisualBasic, VisualFoxpro, PowerBuilder, Delphi , JavaScript, VBScript, VBA, InstallShield, AutoCAD, .NET 等等。 Linux: C, C++, Java 适用操作系统: 并口型软件狗: DOS , Windows 3.x / 9x / ME / NT / 2000 / XP / Sever 2003 LINUX (Red hat 内核 2.2 / 2.4) USB 型软件狗: Windows 98 / ME / 2000 / XP / Sever 2003 LINUX (Red hat 内核 2.2 / 2.4) 开发商升级注意事项: 并口 RC-DL (现已更名为 PDL )型软件狗的软件软件狗开发套件 V3.0 与原 DJ/DK 完全兼容,即使用软件狗开发套件 V3.0 的驱动程序、模块及工具,可以正常操作 DJ/DK 型软件狗。所以建议使用原 DJ/DK 软件的开发商将您的驱动程序、模块及工具全部用软件狗开发套件 V3.0 (光盘版)套件升级。 如果您仍旧使用原有的 DI/DJ/DK 驱动程序、模块及工具,在 DOS 、 Windows 9X/NT/2000 下对 RC-DL 只能做读操作,写操作将失败。如果您不想改动已发行的软件,而还要使用 RC-DL 型软件狗,只升级驱动程序也可以,但您的程序必须是 WIN32 程序。如果您加密的程序是 DOS16 、 DOS32 或 WIN16 程序,您必须升级新的模块及工具,否则将无法对 RC-DL 型软件狗进行写操作。 使用方法: 1.对 EXE 文件 ( 或 COM 文件 ), 利用配套软件的 EXE 文件加密工具加密。 2 对数据库文件 (PRC 、 FOX 、 APP 、 DBF), 利用配套软件的加密工具加密。 3 对于 C 语言及其它编译型语言,配套软件提供可链接的模块文件 (OBJ 文件 ) , 模块文件提供两个函数 :(1) 写数据 ; ⑵读数据。开发商可在要加密软件的源码加入适当的调用语句,对软件狗进行读写操作,以确定对应的软件狗是否存在,从而决定程序是否继续运行。对加入软件狗函数调用的源程序编译后,链接时加上软件狗的模块文件 (OBJ) 即可。

1,594

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧