?? tts.c
?? 網絡打印機及文件共享 C程序源代碼 用于網絡通信
?? C
字號:
??
# include <stdio.h>
# include <dos.h>
# include <bios.h>
union REGS ipregs;
union REGS opregs;
struct SREGS spregs;
struct DoubleWord
{
unsigned int HiWord;
unsigned int LoWord;
};
union LongToWord
{
long dw;
struct DoubleWord w;
};
int GetExtendedFileAttribute();
int SetExtendedFileAttribute();
int TTSIsAvailable();
int TTSBeginTransaction();
int TTSEndTransaction();
int TTSTransactionStatus();
int TTSAbortTransaction();
int TTSSetApplicationThresholds();
int TTSGetApplicationThresholds();
int TTSSetWorkstationThresholds();
int TTSGetWorkstationThresholds();
main()
{
int return_code;
long transactionNumber;
char app_logicalRecordLockThreshold;
char app_physicalRecordLockThreshold;
char wor_logicalRecordLockThreshold;
char wor_physicalRecordLockThreshold;
char Attribute;
FILE *fp;
clrscr();
printf("\n\n\n The example for TTS DOS call\n\n\n");
if (TTSIsAvailable()==1)
{SetExtendedFileAttribute("test",Attribute|0x10);
TTSBeginTransaction();
fp=fopen("test","w");
fputs("This string will not be written!",fp);
fclose(fp);
TTSAbortTransaction();
TTSBeginTransaction();
fp=fopen("test","w");
fputs("This string will be written !",fp);
fclose(fp);
TTSEndTransaction(&transactionNumber);
printf("\n The transaction is being written to disk,please wait!\n\n");
while (TTSTransactionStatus(transactionNumber)!=0);
}
else
printf("TTS isn't available!");
TTSGetApplicationThresholds(&app_logicalRecordLockThreshold,
&app_physicalRecordLockThreshold);
printf("\nThe logicalRecordLockThreshold of application:%d",app_logicalRecordLockThreshold);
printf("\n\nYou can input the threshold you like:");
scanf("\n%c",&app_logicalRecordLockThreshold);
printf("\nThe physicalRecordLockThreshold of application:%d",app_physicalRecordLockThreshold);
printf("\n\nYou can input the threshold you like:");
scanf("\n%c",&app_physicalRecordLockThreshold);
TTSSetApplicationThresholds(app_logicalRecordLockThreshold-0x30,
app_physicalRecordLockThreshold-0x30);
TTSGetWorkstationThresholds(&wor_logicalRecordLockThreshold,
&wor_physicalRecordLockThreshold);
printf("\nThe logicalRecordLockThreshold of workstation:%d",wor_logicalRecordLockThreshold);
printf("\n\nYou can input the threshold you like:");
scanf("\n%c",&wor_logicalRecordLockThreshold);
printf("\nThe physicalRecordLockThreshold of workstation:%d",wor_physicalRecordLockThreshold);
printf("\n\nYou can input the threshold you like:");
scanf("\n%c",&wor_physicalRecordLockThreshold);
TTSSetWorkstationThresholds(wor_logicalRecordLockThreshold-0x30,
wor_physicalRecordLockThreshold-0x30);
}
GetExtendedFileAttribute(char *fileName,char *Attribute)
{
spregs.ds = FP_SEG(fileName);
ipregs.x.dx = FP_OFF(fileName);
ipregs.h.ah = 0xB6;
ipregs.h.al = 0x00;
intdosx(&ipregs,&opregs,&spregs);
*Attribute=opregs.h.cl;
return(opregs.h.al);
}
SetExtendedFileAttribute(char *fileName,char Attribute)
{
spregs.ds = FP_SEG(fileName);
ipregs.x.dx = FP_OFF(fileName);
ipregs.h.ah = 0xB6;
ipregs.h.al = 0x01;
ipregs.h.cl = Attribute;
intdosx(&ipregs,&opregs,&spregs);
return(opregs.h.al);
}
TTSIsAvailable()
{
ipregs.h.al = 0x02;
ipregs.h.ah = 0xC7;
intdosx(&ipregs,&opregs,&spregs);
return(opregs.h.al);
}
TTSBeginTransaction()
{
ipregs.h.al = 0x00;
ipregs.h.ah = 0xC7;
intdosx(&ipregs,&opregs,&spregs);
return(opregs.h.al);
}
TTSEndTransaction(long *transactionNumber)
{
union LongToWord tmp;
ipregs.h.al = 0x01;
ipregs.h.ah = 0xC7;
intdosx(&ipregs,&opregs,&spregs);
tmp.w.HiWord = opregs.x.dx ;
tmp.w.LoWord = opregs.x.cx ;
*transactionNumber = tmp.dw ;
return(opregs.h.al);
}
TTSTransactionStatus(long transactionNumber)
{
union LongToWord tmp;
tmp.dw = transactionNumber;
ipregs.h.al = 0x04;
ipregs.h.ah = 0xC7;
ipregs.x.dx = tmp.w.HiWord;
ipregs.x.cx = tmp.w.LoWord;
intdosx(&ipregs,&opregs,&spregs);
return(opregs.h.al);
}
TTSAbortTransaction()
{
ipregs.h.al = 0x03;
ipregs.h.ah = 0xC7;
intdosx(&ipregs,&opregs,&spregs);
return(opregs.h.al);
}
TTSSetApplicationThresholds(char logicalRecordLockThreshold,
char physicalRecordLockThreshold)
{
ipregs.h.al = 0x06;
ipregs.h.ah = 0xC7;
ipregs.h.cl = logicalRecordLockThreshold;
ipregs.h.ch = physicalRecordLockThreshold;
intdosx(&ipregs,&opregs,&spregs);
return(opregs.h.al);
}
TTSGetApplicationThresholds(char *logicalRecordLockThreshold,
char *physicalRecordLockThreshold)
{
ipregs.h.al = 0x05;
ipregs.h.ah = 0xC7;
intdosx(&ipregs,&opregs,&spregs);
*logicalRecordLockThreshold = opregs.h.cl;
*physicalRecordLockThreshold = opregs.h.ch;
return(opregs.h.al);
}
TTSSetWorkstationThresholds(char logicalRecordLockThreshold,
char physicalRecordLockThreshold)
{
ipregs.h.al = 0x08;
ipregs.h.ah = 0xC7;
ipregs.h.cl = logicalRecordLockThreshold;
ipregs.h.ch = physicalRecordLockThreshold;
intdosx(&ipregs,&opregs,&spregs);
return(opregs.h.al);
}
TTSGetWorkstationThresholds(char *logicalRecordLockThreshold,
char *physicalRecordLockThreshold)
{
ipregs.h.al = 0x07;
ipregs.h.ah = 0xC7;
intdosx(&ipregs,&opregs,&spregs);
*logicalRecordLockThreshold = opregs.h.cl;
*physicalRecordLockThreshold = opregs.h.ch;
return(opregs.h.al);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -