Database 版 (精华区)
发信人: yimei.bbs@bbs.whnet.edu.cn (伊妹), 信区: cndatabase
标 题: Re: Foxpro for DOS紧急问题! 急!
发信站: 武汉白云黄鹤站 (Tue Aug 12 07:28:19 1997)
转信站: Lilac!ustcnews!ustcnews!rjgcnews!whbbs
【 在 Marlboro (Arq) 的大作中提到: 】
: 现面临一大难题:
: 欲用Foxpro for DOS调用C编成的函数,据说Fxopro Library Construction Kits
: 可以将C代码编成Foxpro可以调用的外部库.PLB文件.但如何编呢?
: 或哪位高手用过FoxLCK有心得?
: 急切!
: 谢...
我是Foxpro 2.6(DOS)的忠实用户(因为它是DOS最好的数据库)
现给你一个LCK例子,若成功了别忘了告诉我!
/* * * * * * OHFPT26.H * * * * * * */
#if !defined(__OHTOOLS__H)
#define __OHTOOLS__H 0X0100
typedef unsigned char byte;
typedef unsigned int word;
typedef unsigned long dword;
#include <dos.h>
#include <stdio.h>
#include <malloc.h>
#endif
/* * * * * * OHFPT26.C * * * * * * * */
#include <pro_ext.h>
#include "ohfpt26.h"
#include <stdlib.h>
#include <time.h>
#include <string.h>
static int StrCopyN(byte d[], const byte FAR * s,int n)
{
byte c, FAR *p;
int i;
for(i=0,p=(byte FAR *)s;i<n;i++)
if(p[i]=='\0') break;
else d[i]=p[i];
d[i]='\0';
return i;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void _SetTime(int hour,int min,int sec)
{
struct _dostime_t t;
t.minute = (byte)min;
t.hour = (byte)hour;
t.hsecond = (byte)0;
t.second = (byte)sec;
_dos_settime(&t);
}
void _SetDate(int year,int mon,int day)
{
struct _dosdate_t d;
d.year = (int)year;
d.month = (byte)mon;
d.day = (byte)day;
_dos_setdate(&d);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void FAR SetTime(ParamBlk FAR *parm)
{
int hour, min, sec;
byte is[9]="", os[3]="";
int i;
i=(int)parm->p[0].val.ev_length;
if(i>8) i=8;
StrCopyN(is,_HandToPtr(parm->p[0].val.ev_handle),i);
os[2]='\0';
os[0]=is[0];
os[1]=is[1];
hour=(int)atoi(os);
os[0]=is[3];
os[1]=is[4];
min=(int)atoi(os);
os[0]=is[6];
os[1]=is[7];
sec=(int)atoi(os);
_SetTime(hour, min, sec);
}
void FAR SetDate(ParamBlk FAR *parm)
{
int year, mon, day;
byte is[11]="", os[5]="";
int i;
i=(int)parm->p[0].val.ev_length;
if(i>8) i=10;
StrCopyN(is,_HandToPtr(parm->p[0].val.ev_handle),i);
os[0]=is[0];
os[1]=is[1];
os[2]=is[2];
os[3]=is[3];
os[4]='\0';
year=(int)atoi(os);
os[2]='\0';
os[0]=is[5];
os[1]=is[6];
mon=(int)atoi(os);
os[0]=is[8];
os[1]=is[9];
day=(int)atoi(os);
_SetDate(year, mon, day);
}
void FAR MD(ParamBlk FAR *parm)
{
byte dir[255]="";
int i;
i=(int)parm->p[0].val.ev_length;
if(i>254) i=254;
StrCopyN(dir,_HandToPtr(parm->p[0].val.ev_handle),i);
i=mkdir(dir);
if(i==0) _RetLogical(TRUE);
else _RetLogical(FALSE);
}
void FAR RD(ParamBlk FAR *parm)
{
byte dir[255]="";
int i;
i=(int)parm->p[0].val.ev_length;
if(i>254) i=254;
StrCopyN(dir,_HandToPtr(parm->p[0].val.ev_handle),i);
i=rmdir(dir);
if(i==0) _RetLogical(TRUE);
else _RetLogical(FALSE);
}
void FAR CD(ParamBlk FAR *parm)
{
byte dir[255]="";
int i;
i=(int)parm->p[0].val.ev_length;
if(i>254) i=254;
StrCopyN(dir,_HandToPtr(parm->p[0].val.ev_handle),i);
i=chdir(dir);
if(i==0) _RetLogical(TRUE);
else _RetLogical(FALSE);
}
void FAR DRIVE(ParamBlk FAR *parm)
{
int i;
byte FAR *p;
if(parm->p[0].val.ev_type=='I')
i=(int)parm->p[0].val.ev_long;
else if(parm->p[0].val.ev_type=='C')
{
p=_HandToPtr(parm->p[0].val.ev_handle);
i=(int)p[0]-64;
}else i=-1;
if(i>0 && i<27) i=_chdrive(i);
else i=-1;
if(i==0) _RetLogical(TRUE);
else _RetLogical(FALSE);
}
void FAR IsSZ(ParamBlk FAR *parm)
{
byte FAR * p;
word i;
i=parm->p[0].val.ev_length;
if(i>0)
{
p=(byte FAR *)_HandToPtr(parm->p[0].val.ev_handle);
i=(word)p[0];
}
if(i>47 && i<58) _RetLogical(TRUE);
else _RetLogical(FALSE);
}
void FAR IsZM(ParamBlk FAR *parm)
{
byte FAR * p;
word i;
i=parm->p[0].val.ev_length;
if(i>0)
{
p=(byte FAR *)_HandToPtr(parm->p[0].val.ev_handle);
i=(word)p[0];
}
if(i>32 && i<127 ) _RetLogical(TRUE);
else _RetLogical(FALSE);
}
void FAR IsHZ(ParamBlk FAR *parm)
{
byte FAR * p;
word i;
i=parm->p[0].val.ev_length;
if(i>0)
{
p=(byte FAR *)_HandToPtr(parm->p[0].val.ev_handle);
i=(word)p[0];
}
if(i>127) _RetLogical(TRUE);
else _RetLogical(FALSE);
}
void FAR Just(ParamBlk FAR *parm)
{
byte is[255]="";
int i,j, f;
i=(int)parm->p[0].val.ev_length;
if(i>(int)parm->p[1].val.ev_long) i=(int)parm->p[1].val.ev_long;
if(i>254) i=254;
StrCopyN(is,_HandToPtr(parm->p[0].val.ev_handle),i);
i=f=0;
while(is[i]>'\0')
if(is[i++]>' && f==0) f=1;
else f=0;
if(f==1) is[i-1]=' ';
_RetChar(is);
}
void FAR ToAZ(ParamBlk FAR *parm)
{
byte is[255]="";
int i;
i=(int)parm->p[0].val.ev_length;
if(i>254) i=254;
StrCopyN(is,_HandToPtr(parm->p[0].val.ev_handle),i);
i=0;
while(is[i]>'\0')
if(is[i]>='a' && is[i]<='z') is[i++]-=32;
else i++;
_RetChar(is);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void FAR InitTools(void)
{
word i;
i=(word)time(NULL);
srand(i);
}
void FAR QuitTools(void)
{
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
FoxInfo OhToolInfo[]=
{
{ "INITTOOLS", (FPFI)InitTools,CALLONLOAD,""},
{ "SETTIME", (FPFI)SetTime,1,"C"},
{ "SETDATE", (FPFI)SetDate,1,"C"},
{ "MKDIR", (FPFI)MD,1,"C"},
{ "RMDIR", (FPFI)RD,1,"C"},
{ "CHDIR", (FPFI)CD,1,"C"},
{ "DRIVE", (FPFI)DRIVE,1,"?"},
{ "ISSZ", (FPFI)IsSZ,1,"C"},
{ "ISZM", (FPFI)IsZM,1,"C"},
{ "ISHZ", (FPFI)IsHZ,1,"C"},
{ "JUST", (FPFI)Just,2,"CN"},
{ "TOAZ", (FPFI)ToAZ,1,"C"},
{ "QUITTOOLS", (FPFI)QuitTools,CALLONUNLOAD,""},
};
FoxTable _FoxTable=
{
(FoxTable FAR *)0,sizeof(OhToolInfo)/sizeof(FoxInfo), OhToolInfo
};
--
※ 来源:·武汉白云黄鹤站 s1000e.whnet.edu.cn·[FROM: 202.197.67.3]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:4.710毫秒