让D访问其他应用程序

要使用D,就要和其他应用配合。D和C是二进制兼容的。可以转换C的头文件为D的文件,然后访问C的库,或者兼容C的库。

步骤:
1.转换C的头文件。具体办法[url]http://www.digitalmars.com/d/htomodule.html[/url],也可以使用HTOD工具 [url]http://www.digitalmars.com/d/htod.html[/url],下载在[url]http://ftp.digitalmars.com/d/htod.zip[/url]
2.转换动态库,生成D可以链接的lib文件,D链接的格式是Intel32为OMF格式,和微软使用的lib文件格式COFF不兼容,转换格式的程序我没有找到 :oops: ,虽然介绍了。可使用的是implib,用法[url]http://www.digitalmars.com/ctg/implib.html[/url],implib /s kernel32.lib kernel32.dll 下载地址[url]http://ftp.digitalmars.com/bup.zip[/url],包含了几个工具。

创建导入函数定义def文件的工具[url]http://www.dprogramming.com/linkdef.php [/url]

3.例子,转换SQLServer的头文件,SQLDB.H,SQLFRONT.H。
[code]
module sqldb;
extern (C):
alias double DOUBLE;
/*****************************************************************************
* DBPROCESS, LOGINREC and DBCURSOR *
*****************************************************************************/
alias void DBPROCESS;
alias void LOGINREC;
alias void DBCURSOR;
alias void DBHANDLE;

alias void *PDBPROCESS;
alias void *PLOGINREC;
alias void *PDBCURSOR;
alias void *PDBHANDLE;
alias int function()LGFARPROC;

/*****************************************************************************
* Win32 compatibility datatype definitions *
* Note: The following datatypes are provided for Win32 compatibility. *
* Since some of the datatypes are already defined in unrelated include files *
* there may definition duplication. Every attempt has been made to check *
* for such problems. *
*****************************************************************************/

alias short SHORT;
alias int INT;
alias uint UINT;
alias ushort USHORT;
alias uint ULONG;
alias char CHAR;
alias INT *LPINT;
alias char BYTE;
alias CHAR *LPSTR;
alias BYTE *LPBYTE;
alias void *LPVOID;
alias CHAR *LPCSTR;
alias int BOOL;

/*****************************************************************************
* DB-Library datatype definitions *
*****************************************************************************/
const DBMAXCHAR = 256;
alias INT RETCODE;
alias INT STATUS;
// DB-Library datatypes
alias char DBCHAR;
alias ubyte DBBINARY;
alias ubyte DBTINYINT;
alias short DBSMALLINT;
alias ushort DBUSMALLINT;
alias int DBINT;
alias double DBFLT8;
alias ubyte DBBIT;
alias ubyte DBBOOL;
alias float DBFLT4;
alias int DBMONEY4;

alias DBFLT4 DBREAL;
alias UINT DBUBOOL;

struct dbdatetime4
{
USHORT numdays;
USHORT nummins;
}
alias dbdatetime4 DBDATETIM4;


struct dbvarychar
{
DBSMALLINT len;
DBCHAR [256]str;
}
alias dbvarychar DBVARYCHAR;

struct dbvarybin
{
DBSMALLINT len;
BYTE [256]array;
}
alias dbvarybin DBVARYBIN;

struct dbmoney
{
DBINT mnyhigh;
ULONG mnylow;
}
alias dbmoney DBMONEY;

struct dbdatetime
{
DBINT dtdays;
ULONG dttime;
}
alias dbdatetime DBDATETIME;

// DBDATEREC structure used by dbdatecrack
struct dbdaterec
{
int year; // 1753 - 9999
INT quarter; // 1 - 4
INT month; // 1 - 12
INT dayofyear; // 1 - 366
INT day; // 1 - 31
INT week; // 1 - 54 (for leap years)
INT weekday; // 1 - 7 (Mon - Sun)
INT hour; // 0 - 23
INT minute; // 0 - 59
INT second; // 0 - 59
INT millisecond; // 0 - 999
}
alias dbdaterec DBDATEREC;

const MAXNUMERICLEN = 16;

const MAXNUMERICDIG = 38;
const DEFAULTPRECISION = 18;

const DEFAULTSCALE = 0;
struct dbnumeric
{
BYTE precision;
BYTE scale;
BYTE sign;
BYTE [16]val;
}
alias dbnumeric DBNUMERIC;

alias DBNUMERIC DBDECIMAL;


const MAXCOLNAMELEN = 30;

const MAXTABLENAME = 30;

struct _N1
{
DBINT SizeOfStruct;
CHAR [31]Name;
CHAR [31]ActualName;
CHAR [31]TableName;
SHORT Type;
DBINT UserType;
DBINT MaxLength;
BYTE Precision;
BYTE Scale;
BOOL VarLength; // TRUE, FALSE
BYTE Null; // TRUE, FALSE or DBUNKNOWN
BYTE CaseSensitive; // TRUE, FALSE or DBUNKNOWN
BYTE Updatable; // TRUE, FALSE or DBUNKNOWN
BOOL Identity; // TRUE, FALSE
}
alias _N1 DBCOL;
alias _N1 *LPDBCOL;


const MAXSERVERNAME = 30;
const MAXNETLIBNAME = 255;

const MAXNETLIBCONNSTR = 255;
struct _N2
{
DBINT SizeOfStruct;
BYTE ServerType;
USHORT ServerMajor;
USHORT ServerMinor;
USHORT ServerRevision;
CHAR [31]ServerName;
CHAR [256]NetLibName;
CHAR [256]NetLibConnStr;
}
alias _N2 DBPROCINFO;
alias _N2 *LPDBPROCINFO;

struct _N3
{
DBINT SizeOfStruct;
ULONG TotCols;
ULONG TotRows;
ULONG CurRow;
ULONG TotRowsFetched;
ULONG Type;
ULONG Status;
}
alias _N3 DBCURSORINFO;
alias _N3 *LPDBCURSORINFO;


/*****************************************************************************
* Pointer Datatypes *
*****************************************************************************/

alias LPINT LPCINT;
alias LPBYTE LPCBYTE;
alias USHORT *LPUSHORT;
alias LPUSHORT LPCUSHORT;
alias DBINT *LPDBINT;
alias LPDBINT LPCDBINT;
alias DBBINARY *LPDBBINARY;
alias LPDBBINARY LPCDBBINARY;
alias DBDATEREC *LPDBDATEREC;
alias LPDBDATEREC LPCDBDATEREC;
alias DBDATETIME *LPDBDATETIME;
alias LPDBDATETIME LPCDBDATETIME;


/*****************************************************************************
* General #defines *
*****************************************************************************/

const SERVTYPE_UNKNOWN = 0;

const SERVTYPE_MICROSOFT = 1;
// Used by dbcolinfo
enum CI_TYPES
{
CI_REGULAR = 1,
CI_ALTERNATE,
CI_CURSOR,
}

const DB_IN = 1;
const DB_OUT = 2;

const BCPMAXERRS = 1; // bcp_control parameter
const BCPFIRST = 2;
const BCPLAST = 3;
const BCPBATCH = 4;
const BCPKEEPNULLS = 5;
const BCPABORT = 6;

const TRUE = 1;
const FALSE = 0;

const TINYBIND = 1;
const SMALLBIND = 2;
const INTBIND = 3;
const CHARBIND = 4;
const BINARYBIND = 5;
const BITBIND = 6;
const DATETIMEBIND = 7;
const MONEYBIND = 8;
const FLT8BIND = 9;
const STRINGBIND = 10;
const NTBSTRINGBIND = 11;
const VARYCHARBIND = 12;
const VARYBINBIND = 13;
const FLT4BIND = 14;
const SMALLMONEYBIND = 15;
const SMALLDATETIBIND = 16;
const DECIMALBIND = 17;
const NUMERICBIND = 18;
const SRCDECIMALBIND = 19;
const SRCNUMERICBIND = 20;

alias SRCNUMERICBIND MAXBIND;
const DBSAVE = 1;
const DBNOSAVE = 0;
const DBNOERR = -1;
const DBFINDONE = 0x04;
const DBMORE = 0x10;
const DBMORE_ROWS = 0x20;

const MAXNAME = 31;

const DBTXTSLEN = 8;
const DBTXPLEN = 16;
const INT_EXIT = 0;
const INT_CONTINUE = 1;
const INT_CANCEL = 2;

// dboptions
const DBBUFFER = 0;
const DBOFFSET = 1;
const DBROWCOUNT = 2;
const DBSTAT = 3;
const DBTEXTLIMIT = 4;
const DBTEXTSIZE = 5;
const DBARITHABORT = 6;
const DBARITHIGNORE = 7;
const DBNOAUTOFREE = 8;
const DBNOCOUNT = 9;
const DBNOEXEC = 10;
const DBPARSEONLY = 11;
const DBSHOWPLAN = 12;

const DBSTORPROCID = 13;

const DBCLIENTCURSORS = 16;
const DBSETTIME = 17;

const DBQUOTEDIDENT = 18;

// Data Type Tokens
const SQLVOID = 0x1f;
const SQLTEXT = 0x23;
const SQLVARBINARY = 0x25;
const SQLINTN = 0x26;
const SQLVARCHAR = 0x27;
const SQLBINARY = 0x2d;
const SQLIMAGE = 0x22;
const SQLCHAR = 0x2f;
const SQLINT1 = 0x30;
const SQLBIT = 0x32;
const SQLINT2 = 0x34;
const SQLINT4 = 0x38;
const SQLMONEY = 0x3c;
const SQLDATETIME = 0x3d;
const SQLFLT8 = 0x3e;
const SQLFLTN = 0x6d;
const SQLMONEYN = 0x6e;
const SQLDATETIMN = 0x6f;
const SQLFLT4 = 0x3b;
const SQLMONEY4 = 0x7a;
const SQLDATETIM4 = 0x3a;
const SQLDECIMAL = 0x6a;

const SQLNUMERIC = 0x6c;
// Data stream tokens
const SQLCOLFMT = 0xa1;
const OLD_SQLCOLFMT = 0x2a;
const SQLPROCID = 0x7c;
const SQLCOLNAME = 0xa0;
const SQLTABNAME = 0xa4;
const SQLCOLINFO = 0xa5;
const SQLALTNAME = 0xa7;
const SQLALTFMT = 0xa8;
const SQLERROR = 0xaa;
const SQLINFO = 0xab;
const SQLRETURNVALUE = 0xac;
const SQLRETURNSTATUS = 0x79;
const SQLRETURN = 0xdb;
const SQLCONTROL = 0xae;
const SQLALTCONTROL = 0xaf;
const SQLROW = 0xd1;
const SQLALTROW = 0xd3;
const SQLDONE = 0xfd;
const SQLDONEPROC = 0xfe;
const SQLDONEINPROC = 0xff;
const SQLOFFSET = 0x78;
const SQLORDER = 0xa9;

const SQLLOGINACK = 0xad;
// Ag op tokens
const SQLAOPCNT = 0x4b;
const SQLAOPSUM = 0x4d;
const SQLAOPAVG = 0x4f;
const SQLAOPMIN = 0x51;
const SQLAOPMAX = 0x52;
const SQLAOPANY = 0x53;

const SQLAOPNOOP = 0x56;
// Error numbers (dberrs) DB-Library error codes
const SQLEMEM = 10000;
const SQLENULL = 10001;
const SQLENLOG = 10002;
const SQLEPWD = 10003;
const SQLECONN = 10004;
const SQLEDDNE = 10005;
const SQLENULLO = 10006;
const SQLESMSG = 10007;
const SQLEBTOK = 10008;
const SQLENSPE = 10009;
const SQLEREAD = 10010;
const SQLECNOR = 10011;
const SQLETSIT = 10012;
const SQLEPARM = 10013;
const SQLEAUTN = 10014;
const SQLECOFL = 10015;
const SQLERDCN = 10016;
const SQLEICN = 10017;
const SQLECLOS = 10018;
const SQLENTXT = 10019;
const SQLEDNTI = 10020;
const SQLETMTD = 10021;
const SQLEASEC = 10022;
const SQLENTLL = 10023;
const SQLETIME = 10024;
const SQLEWRIT = 10025;
const SQLEMODE = 10026;
const SQLEOOB = 10027;
const SQLEITIM = 10028;
const SQLEDBPS = 10029;
const SQLEIOPT = 10030;
const SQLEASNL = 10031;
const SQLEASUL = 10032;
const SQLENPRM = 10033;
const SQLEDBOP = 10034;
const SQLENSIP = 10035;
const SQLECNULL = 10036;
const SQLESEOF = 10037;
const SQLERPND = 10038;
const SQLECSYN = 10039;
const SQLENONET = 10040;
const SQLEBTYP = 10041;
const SQLEABNC = 10042;
const SQLEABMT = 10043;
const SQLEABNP = 10044;
const SQLEBNCR = 10045;
const SQLEAAMT = 10046;
const SQLENXID = 10047;
const SQLEIFNB = 10048;
const SQLEKBCO = 10049;
const SQLEBBCI = 10050;
const SQLEKBCI = 10051;
const SQLEBCWE = 10052;
const SQLEBCNN = 10053;
const SQLEBCOR = 10054;
const SQLEBCPI = 10055;
const SQLEBCPN = 10056;
const SQLEBCPB = 10057;
const SQLEVDPT = 10058;
const SQLEBIVI = 10059;
const SQLEBCBC = 10060;
const SQLEBCFO = 10061;
const SQLEBCVH = 10062;
const SQLEBCUO = 10063;
const SQLEBUOE = 10064;
const SQLEBWEF = 10065;
const SQLEBTMT = 10066;
const SQLEBEOF = 10067;
const SQLEBCSI = 10068;
const SQLEPNUL = 10069;
const SQLEBSKERR = 10070;
const SQLEBDIO = 10071;
const SQLEBCNT = 10072;
const SQLEMDBP = 10073;
const SQLINIT = 10074;
const SQLCRSINV = 10075;
const SQLCRSCMD = 10076;
const SQLCRSNOIND = 10077;
const SQLCRSDIS = 10078;
const SQLCRSAGR = 10079;
const SQLCRSORD = 10080;
const SQLCRSMEM = 10081;
const SQLCRSBSKEY = 10082;
const SQLCRSNORES = 10083;
const SQLCRSVIEW = 10084;
const SQLCRSBUFR = 10085;
const SQLCRSFROWN = 10086;
const SQLCRSBROL = 10087;
const SQLCRSFRAND = 10088;
const SQLCRSFLAST = 10089;
const SQLCRSRO = 10090;
const SQLCRSTAB = 10091;
const SQLCRSUPDTAB = 10092;
const SQLCRSUPDNB = 10093;
const SQLCRSVIIND = 10094;
const SQLCRSNOUPD = 10095;
const SQLCRSOS2 = 10096;
const SQLEBCSA = 10097;
const SQLEBCRO = 10098;
const SQLEBCNE = 10099;
const SQLEBCSK = 10100;
const SQLEUVBF = 10101;
const SQLEBIHC = 10102;
const SQLEBWFF = 10103;
const SQLNUMVAL = 10104;
const SQLEOLDVR = 10105;
const SQLEBCPS = 10106;
const SQLEDTC = 10107;
const SQLENOTIMPL = 10108;
const SQLENONFLOAT = 10109;
const SQLECONNFB = 10110;

// The severity levels are defined here
const EXINFO = 1; // Informational, non-error
const EXUSER = 2; // User error
const EXNONFATAL = 3; // Non-fatal error
const EXCONVERSION = 4; // Error in DB-LIBRARY data conversion
const EXSERVER = 5; // The Server has returned an error flag
const EXTIME = 6; // waiting for a response from the Server - the DBPROCESS is still alive
const EXPROGRAM = 7; // Coding error in user program
const EXRESOURCE = 8; // Running out of resources - the DBPROCESS may be dead
const EXCOMM = 9; // Failure in communication with Server - the DBPROCESS is dead
const EXFATAL = 10; // Fatal error - the DBPROCESS is dead
const EXCONSISTENCY = 11; // Internal software error - notify MS Technical Supprt
// Offset identifiers
const OFF_SELECT = 0x16d;
const OFF_FROM = 0x14f;
const OFF_ORDER = 0x165;
const OFF_COMPUTE = 0x139;
const OFF_TABLE = 0x173;
const OFF_PROCEDURE = 0x16a;
const OFF_STATEMENT = 0x1cb;
const OFF_PARAM = 0x1c4;
const OFF_EXEC = 0x12c;
// Print lengths for certain fixed length data types
const PRINT4 = 11;
const PRINT2 = 6;
const PRINT1 = 3;
const PRFLT8 = 20;
const PRMONEY = 26;
const PRBIT = 3;
const PRDATETIME = 27;

const SUCCEED = 1;
const FAIL = 0;
const SUCCEED_ABORT = 2;

const DBUNKNOWN = 2;
const MORE_ROWS = -1;
const NO_MORE_ROWS = -2;
alias MORE_ROWS REG_ROW;
const BUF_FULL = -3;
// Status code for dbresults(). Possible return values are
// SUCCEED, FAIL, and NO_MORE_RESULTS.
const NO_MORE_RESULTS = 2;
const NO_MORE_RPC_RESULTS = 3;
const DBSETHOST = 1;
const DBSETUSER = 2;
const DBSETPWD = 3;
const DBSETAPP = 4;
const DBSETID = 5;
const DBSETLANG = 6;
const DBSETSECURE = 7;
const DBVER42 = 8;
const DBVER60 = 9;
const DBSETLOGINTIME = 10;

const DBSETFALLBACK = 12;
// Standard exit and error values
const STDEXIT = 0;
const ERREXIT = -1;

// dbrpcinit flags
const DBRPCRECOMPILE = 0x0001;
const DBRPCRESET = 0x0004;
const DBRPCCURSOR = 0x0008;

// dbrpcparam flags
const DBRPCRETURN = 0x1;
const DBRPCDEFAULT = 0x2;

// Cursor related constants

// Following flags are used in the concuropt parameter in the dbcursoropen function
const CUR_READONLY = 1;
const CUR_LOCKCC = 2;
const CUR_OPTCC = 3;
const CUR_OPTCCVAL = 4;
// Following flags are used in the scrollopt parameter in dbcursoropen
const CUR_FORWARD = 0;
const CUR_KEYSET = -1;
const CUR_DYNAMIC = 1;

const CUR_INSENSITIVE = -2;
// Following flags define the fetchtype in the dbcursorfetch function
const FETCH_FIRST = 1;
const FETCH_NEXT = 2;
const FETCH_PREV = 3;
const FETCH_RANDOM = 4;
const FETCH_RELATIVE = 5;

const FETCH_LAST = 6;
// Following flags define the per row status as filled by dbcursorfetch and/or dbcursorfetchex
const FTC_EMPTY = 0x00;
const FTC_SUCCEED = 0x01;
const FTC_MISSING = 0x02;
const FTC_ENDOFKEYSET = 0x04;

const FTC_ENDOFRESULTS = 0x08;
// Following flags define the operator types for the dbcursor function
const CRS_UPDATE = 1;
const CRS_DELETE = 2;
const CRS_INSERT = 3;
const CRS_REFRESH = 4;

const CRS_LOCKCC = 5;
// Following value can be passed to the dbcursorbind function for NOBIND type

const NOBIND = -2;
// Following are values used by DBCURSORINFO's Type parameter
const CU_CLIENT = 0x00000001;
const CU_SERVER = 0x00000002;
const CU_KEYSET = 0x00000004;
const CU_MIXED = 0x00000008;
const CU_DYNAMIC = 0x00000010;
const CU_FORWARD = 0x00000020;
const CU_INSENSITIVE = 0x00000040;
const CU_READONLY = 0x00000080;
const CU_LOCKCC = 0x00000100;
const CU_OPTCC = 0x00000200;
const CU_OPTCCVAL = 0x00000400;
// Following are values used by DBCURSORINFO's Status parameter
const CU_FILLING = 0x00000001;
const CU_FILLED = 0x00000002;

// Following are values used by dbupdatetext's type parameter
const UT_TEXTPTR = 0x0001;
const UT_TEXT = 0x0002;
const UT_MORETEXT = 0x0004;
const UT_DELETEONLY = 0x0008;

const UT_LOG = 0x0010;

// The following values are passed to dbserverenum for searching criteria.
const NET_SEARCH = 0x0001;
const LOC_SEARCH = 0x0002;
// These constants are the possible return values from dbserverenum.
const ENUM_SUCCESS = 0x0000;
const MORE_DATA = 0x0001;
const NET_NOT_AVAIL = 0x0002;
const OUT_OF_MEMORY = 0x0004;
const NOT_SUPPORTED = 0x0008;

const ENUM_INVALID_PARAM = 0x0010;

// Netlib Error problem codes. ConnectionError() should return one of
// these as the dblib-mapped problem code, so the corresponding string
// is sent to the dblib app's error handler as dberrstr. Return NE_E_NOMAP
// for a generic DB-Library error string (as in prior versions of dblib).

const NE_E_NOMAP = 0;
const NE_E_NOMEMORY = 1;
const NE_E_NOACCESS = 2;
const NE_E_CONNBUSY = 3;
const NE_E_CONNBROKEN = 4;
const NE_E_TOOMANYCONN = 5;
const NE_E_SERVERNOTFOUND = 6;
const NE_E_NETNOTSTARTED = 7;
const NE_E_NORESOURCE = 8;
const NE_E_NETBUSY = 9;
const NE_E_NONETACCESS = 10;
const NE_E_GENERAL = 11;
const NE_E_CONNMODE = 12;
const NE_E_NAMENOTFOUND = 13;
const NE_E_INVALIDCONN = 14;
const NE_E_NETDATAERR = 15;
const NE_E_TOOMANYFILES = 16;
const NE_E_CANTCONNECT = 17;

const NE_MAX_NETERROR = 17;

//define a function pointer
alias INT DBERRHANDLE_PROC(PDBPROCESS , INT , INT , INT , LPCSTR , LPCSTR );
alias INT DBMSGHANDLE_PROC(PDBPROCESS , DBINT , INT , INT , LPCSTR , LPCSTR , LPCSTR , DBUSMALLINT );

DBERRHANDLE_PROC dberrhandle(DBERRHANDLE_PROC );
DBMSGHANDLE_PROC dbmsghandle(DBMSGHANDLE_PROC );

DBERRHANDLE_PROC dbprocerrhandle(PDBHANDLE , DBERRHANDLE_PROC );
DBMSGHANDLE_PROC dbprocmsghandle(PDBHANDLE , DBMSGHANDLE_PROC );

/*****************************************************************************
* Function Prototypes *
*****************************************************************************/

// Two-phase commit functions
int abort_xact(PDBPROCESS , DBINT );
void build_xact_string(LPCSTR , LPCSTR , DBINT , LPSTR );
void close_commit(PDBPROCESS );
int commit_xact(PDBPROCESS , DBINT );
PDBPROCESS open_commit(PLOGINREC , LPCSTR );
int remove_xact(PDBPROCESS , DBINT , INT );
int scan_xact(PDBPROCESS , DBINT );
DBINT start_xact(PDBPROCESS , LPCSTR , LPCSTR , INT );
int stat_xact(PDBPROCESS , DBINT );

// BCP functions
DBINT bcp_batch(PDBPROCESS );
int bcp_bind(PDBPROCESS , LPCBYTE , INT , DBINT , LPCBYTE , INT , INT , INT );
int bcp_colfmt(PDBPROCESS , INT , BYTE , INT , DBINT , LPCBYTE , INT , INT );
int bcp_collen(PDBPROCESS , DBINT , INT );
int bcp_colptr(PDBPROCESS , LPCBYTE , INT );
int bcp_columns(PDBPROCESS , INT );
int bcp_control(PDBPROCESS , INT , DBINT );
DBINT bcp_done(PDBPROCESS );
int bcp_exec(PDBPROCESS , LPDBINT );
int bcp_init(PDBPROCESS , LPCSTR , LPCSTR , LPCSTR , INT );
int bcp_moretext(PDBPROCESS , DBINT , LPCBYTE );
int bcp_readfmt(PDBPROCESS , LPCSTR );
int bcp_sendrow(PDBPROCESS );
int bcp_setl(PLOGINREC , BOOL );
int bcp_writefmt(PDBPROCESS , LPCSTR );

// Standard DB-Library functions
LPCBYTE dbadata(PDBPROCESS , INT , INT );
DBINT dbadlen(PDBPROCESS , INT , INT );
int dbaltbind(PDBPROCESS , INT , INT , INT , DBINT , LPCBYTE );
int dbaltcolid(PDBPROCESS , INT , INT );
DBINT dbaltlen(PDBPROCESS , INT , INT );
int dbaltop(PDBPROCESS , INT , INT );
int dbalttype(PDBPROCESS , INT , INT );
DBINT dbaltutype(PDBPROCESS , INT , INT );

int dbanullbind(PDBPROCESS , INT , INT , LPCDBINT );
//int dbbind(PDBPROCESS dbproc, INT , INT , DBINT , LPBYTE );
int dbbind (PDBPROCESS dbproc, int column, int vartype, DBINT varlen, LPBYTE varaddr );
LPCBYTE dbbylist(PDBPROCESS , INT , LPINT );
int dbcancel(PDBPROCESS );
int dbcanquery(PDBPROCESS );
LPCSTR dbchange(PDBPROCESS );
int dbclose(PDBPROCESS );
void dbclrbuf(PDBPROCESS , DBINT );
int dbclropt(PDBPROCESS , INT , LPCSTR );
int dbcmd(PDBPROCESS , LPCSTR );
int dbcmdrow(PDBPROCESS );
bool dbcolbrowse(PDBPROCESS , INT );
int dbcolinfo(PDBHANDLE , INT , INT , INT , LPDBCOL );
DBINT dbcollen(PDBPROCESS , INT );
LPCSTR dbcolname(PDBPROCESS , INT );
LPCSTR dbcolsource(PDBPROCESS , INT );
int dbcoltype(PDBPROCESS , INT );
DBINT dbcolutype(PDBPROCESS , INT );
int dbconvert(PDBPROCESS , INT , LPCBYTE , DBINT , INT , LPBYTE , DBINT );
DBINT dbcount(PDBPROCESS );
int dbcurcmd(PDBPROCESS );
DBINT dbcurrow(PDBPROCESS );
int dbcursor(PDBCURSOR , INT , INT , LPCSTR , LPCSTR );
int dbcursorbind(PDBCURSOR , INT , INT , DBINT , LPDBINT , LPBYTE );
int dbcursorclose(PDBHANDLE );
int dbcursorcolinfo(PDBCURSOR , INT , LPSTR , LPINT , LPDBINT , LPINT );
int dbcursorfetch(PDBCURSOR , INT , INT );
int dbcursorfetchex(PDBCURSOR , INT , DBINT , DBINT , DBINT );
int dbcursorinfo(PDBCURSOR , LPINT , LPDBINT );
int dbcursorinfoex(PDBCURSOR , LPDBCURSORINFO );
PDBCURSOR dbcursoropen(PDBPROCESS , LPCSTR , INT , INT , UINT , LPDBINT );
LPCBYTE dbdata(PDBPROCESS , INT );
bool dbdataready(PDBPROCESS );
int dbdatecrack(PDBPROCESS , LPDBDATEREC , LPCDBDATETIME );
DBINT dbdatlen(PDBPROCESS , INT );
bool dbdead(PDBPROCESS );
void dbexit();
int dbenlisttrans(PDBPROCESS , LPVOID );
int dbenlistxatrans(PDBPROCESS , BOOL );
//C extern RETCODE dbfcmd (PDBPROCESS, LPCSTR, ...);
INT dbfcmd(PDBPROCESS , LPCSTR ,...);
DBINT dbfirstrow(PDBPROCESS );
void dbfreebuf(PDBPROCESS );
void dbfreelogin(PLOGINREC );
void dbfreequal(LPCSTR );
LPSTR dbgetchar(PDBPROCESS , INT );
short dbgetmaxprocs();
int dbgetoff(PDBPROCESS , DBUSMALLINT , INT );
uint dbgetpacket(PDBPROCESS );
int dbgetrow(PDBPROCESS , DBINT );
int dbgettime();
LPVOID dbgetuserdata(PDBPROCESS );
bool dbhasretstat(PDBPROCESS );
LPCSTR dbinit();
bool dbisavail(PDBPROCESS );
bool dbiscount(PDBPROCESS );
bool dbisopt(PDBPROCESS , INT , LPCSTR );
DBINT dblastrow(PDBPROCESS );
PLOGINREC dblogin();
int dbmorecmds(PDBPROCESS );
int dbmoretext(PDBPROCESS , DBINT , LPCBYTE );
LPCSTR dbname(PDBPROCESS );
int dbnextrow(PDBPROCESS );
int dbnullbind(PDBPROCESS , INT , LPCDBINT );
int dbnumalts(PDBPROCESS , INT );
int dbnumcols(PDBPROCESS );
int dbnumcompute(PDBPROCESS );
int dbnumorders(PDBPROCESS );
int dbnumrets(PDBPROCESS );
PDBPROCESS dbopen(PLOGINREC , LPCSTR );
int dbordercol(PDBPROCESS , INT );
int dbprocinfo(PDBPROCESS , LPDBPROCINFO );
void dbprhead(PDBPROCESS );
int dbprrow(PDBPROCESS );
LPCSTR dbprtype(INT );
LPCSTR dbqual(PDBPROCESS , INT , LPCSTR );
DBINT dbreadpage(PDBPROCESS , LPCSTR , DBINT , LPBYTE );
DBINT dbreadtext(PDBPROCESS , LPVOID , DBINT );
int dbresults(PDBPROCESS );
LPCBYTE dbretdata(PDBPROCESS , INT );
DBINT dbretlen(PDBPROCESS , INT );
LPCSTR dbretname(PDBPROCESS , INT );
DBINT dbretstatus(PDBPROCESS );
int dbrettype(PDBPROCESS , INT );
int dbrows(PDBPROCESS );
int dbrowtype(PDBPROCESS );
int dbrpcinit(PDBPROCESS , LPCSTR , DBSMALLINT );
int dbrpcparam(PDBPROCESS , LPCSTR , BYTE , INT , DBINT , DBINT , LPCBYTE );
int dbrpcsend(PDBPROCESS );
int dbrpcexec(PDBPROCESS );
void dbrpwclr(PLOGINREC );
int dbrpwset(PLOGINREC , LPCSTR , LPCSTR , INT );
int dbserverenum(USHORT , LPSTR , USHORT , LPUSHORT );
void dbsetavail(PDBPROCESS );
int dbsetmaxprocs(SHORT );
int dbsetlname(PLOGINREC , LPCSTR , INT );
int dbsetlogintime(INT );
int dbsetlpacket(PLOGINREC , USHORT );
int dbsetnull(PDBPROCESS , INT , INT , LPCBYTE );
int dbsetopt(PDBPROCESS , INT , LPCSTR );
int dbsettime(INT );
void dbsetuserdata(PDBPROCESS , LPVOID );
int dbsqlexec(PDBPROCESS );
int dbsqlok(PDBPROCESS );
int dbsqlsend(PDBPROCESS );
int dbstrcpy(PDBPROCESS , INT , INT , LPSTR );
int dbstrlen(PDBPROCESS );
bool dbtabbrowse(PDBPROCESS , INT );
int dbtabcount(PDBPROCESS );
LPCSTR dbtabname(PDBPROCESS , INT );
LPCSTR dbtabsource(PDBPROCESS , INT , LPINT );
int dbtsnewlen(PDBPROCESS );
LPCDBBINARY dbtsnewval(PDBPROCESS );
int dbtsput(PDBPROCESS , LPCDBBINARY , INT , INT , LPCSTR );
LPCDBBINARY dbtxptr(PDBPROCESS , INT );
LPCDBBINARY dbtxtimestamp(PDBPROCESS , INT );
LPCDBBINARY dbtxtsnewval(PDBPROCESS );
int dbtxtsput(PDBPROCESS , LPCDBBINARY , INT );
int dbuse(PDBPROCESS , LPCSTR );
bool dbvarylen(PDBPROCESS , INT );
bool dbwillconvert(INT , INT );
int dbwritepage(PDBPROCESS , LPCSTR , DBINT , DBINT , LPBYTE );
int dbwritetext(PDBPROCESS , LPCSTR , LPCDBBINARY , DBTINYINT , LPCDBBINARY , BOOL , DBINT , LPCBYTE );
int dbupdatetext(PDBPROCESS , LPCSTR , LPCDBBINARY , LPCDBBINARY , INT , DBINT , DBINT , LPCSTR , DBINT , LPCDBBINARY );

[/code]

调用例子:
[code]module test;

import sqldb;
import std.c.stdio;
import std.string;

int main(){

PDBPROCESS dbproc; // The connection with SQL Server.
PLOGINREC login; // The login information.
DBCHAR name[100];
DBCHAR city[100];

// Initialize DB-Library.
dbinit();

// Get a LOGINREC.
login = dblogin ();
dbsetlname (login, "sa",DBSETUSER);
dbsetlname (login, "",DBSETPWD);
dbsetlname (login, "example",DBSETAPP);

// Get a DBPROCESS structure for communication with SQL Server.
dbproc = dbopen (login, "BM");

// Retrieve some columns from the authors table in the pubs database.

// First, put the command into the command buffer.
dbcmd (dbproc, "SELECT cpm,ccd FROM pt..tzl_sp");
dbcmd (dbproc, " WHERE CID < 130 ");

// Send the command to SQL Server and start execution.
dbsqlexec (dbproc);

// Process the results.
if (dbresults (dbproc) == SUCCEED)
{
// Bind column to program variables.
dbbind (dbproc, 1, NTBSTRINGBIND, 0, name);
dbbind (dbproc, 2, NTBSTRINGBIND, 0, city);

// Retrieve and print the result rows.
while (dbnextrow(dbproc) != NO_MORE_ROWS)
{
printf ("%s from %s\n", toStringz(name), toStringz(city));
}
}
// Close the connection to SQL Server.
dbexit ();
return 0;
}
[/code]

4.参考[url]http://qiezi.iteye.com/blog/26632[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值