`
ideage
  • 浏览: 326169 次
社区版块
存档分类
最新评论

让D访问其他应用程序

阅读更多

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

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

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

3.例子,转换SQLServer的头文件,SQLDB.H,SQLFRONT.H。
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 );



调用例子:
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;
}


4.参考http://qiezi.iteye.com/blog/26632
分享到:
评论
2 楼 ideage 2006-10-10  
to qiezi 不好意思,我是看你搬了家,才来的!

以后还请多多帮助!
1 楼 qiezi 2006-10-10  
你的家居然在这里。。。幸会~

不过怎么在http://www.iteye.com/user/36102可以看到这篇文章,左边显示的是ideage,但点进来用户名显示的却是 czhcc,论坛的BUG?

相关推荐

    怎样在wincc中用按钮打开某个文件夹及其他应用程序

    在 WinCC 中,我们可以使用按钮来打开文件夹、应用程序等,以便更方便地访问和操作这些资源。下面我们将详细介绍如何在 WinCC 中使用按钮打开文件夹及其他应用程序。 按钮的定义和命名 首先,在图形编辑器中定义一...

    让Asp.net应用程序使用UNC路径访问网络文件夹

    ### Asp.net应用程序使用UNC路径访问网络文件夹 #### 背景介绍 在开发Asp.net应用程序的过程中,经常会遇到需要访问网络文件夹的情况。在本地开发环境下使用Visual Studio 2010(以下简称Vs2010)进行测试时,能够...

    Web应用程序设计案例教程

    第1章 初识Web应用程序 第2章 数据库应用基础 ...第4章 用户登录模块设计 第5章 网站访问计数器设计 第6章 图书信息查询模块设计 第7章 图书信息浏览模块设计 ...附录D Web应用程序设计综合实训

    android管理应用程序相关代码及资源路径

    在Android中,用户可以通过`Settings`应用访问"管理应用程序"。相关设置的标题和描述可能包含以下字符串资源: - `manageapplications_settings_title`:这可能是管理应用程序设置的标题,比如"应用管理"。 - `...

    windows 服务启动应用程序

    4. **设置服务权限**:如果应用程序需要特定的权限,比如访问网络或者特定的系统资源,你可能需要调整服务账户的权限。默认情况下,服务通常以Local System账户运行,但也可以更改为其他账户。 5. **启动和管理服务...

    asp.net中web应用程序部署

    ASP.NET 2.0 中 WEB 应用程序的部署是指在我们建立完一个 WEB 应用程序后,将其部署到生产环境中,使其可以被用户访问的过程。部署 WEB 应用程序是非常重要的步骤,因为它直接影响着用户体验和应用程序的可靠性。 ...

    maximo 应用程序设计器 文档

    - 介绍如何使用应用程序设计器来实现与其他系统的集成,比如ERP或CRM系统。 - **主题2:高级用户界面定制** - 探讨如何利用CSS、JavaScript等前端技术进一步定制Maximo的用户界面,以提供更加友好的用户体验。 - *...

    获取上网账号和密码的应用程序

    “获取上网帐号密码并自动保存到D盘.EXE”是压缩包内的文件名,表明这是可执行文件(EXE),是Windows操作系统下的应用程序。这个文件很可能就是描述中所说的工具,用户下载并运行后,就能使用其功能。自动保存功能...

    C语言基础 简单C语言应用程序

    在“C语言基础 简单C语言应用程序”这个主题中,我们将深入探讨C语言的基础知识,了解如何编写简单的C语言应用程序。 首先,C语言的基础包括数据类型。C语言支持基本的数据类型如整型(int)、浮点型(float、...

    应用程序的M F C类、支持窗口

    在第3章中,我们将讨论一个M F C应用程序是怎样通过消息与外界及应用程序进行通信的。 还将讨论四种消息类型,并跟踪一个消息通过接收消息的类。最后将探讨该路径上的重定向 消息。 绘图 在第4章中,我们将讨论在...

    单片机原理与应用及C51程序设计习题答案

    单片机原理与应用是电子工程领域中一个重要的学习板块,C51程序设计则是针对8051系列单片机进行编程的一种语言。在这个专题中,我们将深入探讨这两个核心概念,以及如何通过课后习题来提升理解和实践能力。 首先,...

    《C51单片机应用与C语言程序设计》配套程序

    《C51单片机应用与C语言程序设计》是一本深入浅出的教程,旨在帮助读者掌握C51单片机的使用以及基于C语言的编程技术。配套程序是学习过程中不可或缺的一部分,它们提供了实践操作的机会,使理论知识得以实际验证。...

    visual c++ vc限制磁盘驱动器访问,如禁止访问D盘.zip

    在使用Visual C++ (VC++) 开发Windows应用程序时,有时我们可能需要对程序的磁盘访问权限进行控制,比如禁止程序访问特定的磁盘驱动器,例如D盘。这种需求通常出于安全考虑,防止程序误操作或者恶意行为,或者是为了...

    单片机高级c51应用程序设计

    单片机高级C51应用程序设计是一门涵盖了嵌入式系统开发中的重要技术领域,主要针对Atmel公司的8位AVR单片机进行讲解。C51是专门为8051系列单片机定制的一种高级编程语言,它扩展了标准C语言,使其更适合于微控制器的...

    单片机原理与应用及C51程序设计课件电子教案.rar

    6. **实际应用案例**:教案可能包含一些实际项目案例,如温控系统、防盗报警器、智能家居等,让学生了解单片机在现实生活中的广泛应用。 7. **优秀毕业设计与论文**:标签中的“优秀毕业设计”和“优秀毕业论文”...

    单片机高级语言C51应用程序设计

    ### 单片机高级语言C51应用程序设计 #### 一、引言 随着电子技术的发展,单片机因其体积小、成本低、可靠性高、易于控制等优势,在工业自动化、家用电器、智能仪器仪表等领域得到了广泛应用。在单片机编程领域,...

    西门子 Sinumerik 802S_C_D PLC子程序库应用指南.zip

    西门子Sinumerik 802S/C/D PLC子程序库是专为这款系列的数控系统设计的应用工具,用于实现复杂控制逻辑和自动化任务。这个应用指南详细介绍了如何有效地利用PLC子程序来提高系统的功能性和效率。下面将深入探讨相关...

    Lazarus开发Android应用程序指南

    ### Lazarus开发Android应用程序指南 #### 一、引言 随着移动互联网的快速发展,Android操作系统因其开放性和灵活性而成为智能手机和平板电脑市场的主导者之一。为了满足开发者的需求,多种编程工具和技术应运而生...

    单片机高级C51应用程序设计(PDG).rar

    《单片机高级C51应用程序设计》是一本专注于单片机编程的书籍,主要针对C51语言在单片机应用中的高级技巧和实践。C51是为8051系列单片机设计的一种高级语言,它以其简洁、易读的语法特性,成为单片机开发中广泛使用...

Global site tag (gtag.js) - Google Analytics