📄 ttxt.cpp
字号:
#include <windows.h>
#include <stdio.h>
char txt_head[24]={0,0,0,0,0,1,0,24,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0};
int AddTxtHead(char *name)
{
FILE *fp;
int filelen;
char *p;
if ((fp=fopen(name,"rb"))==NULL) return 0;
fseek(fp,0,SEEK_END);
filelen=ftell(fp);
fseek(fp,0,SEEK_SET);
if (filelen==0) return 0;
p=(char *)malloc(filelen+24);
if (p==NULL) {
fclose(fp);
return 0;
}
fread(p+24,1,filelen,fp);
fclose(fp);
memcpy(p,txt_head,24);
*(long *)(p+10)=filelen+24;
*(long *)(p+19)=filelen+24;
if (!GetTempPath(250,name)) {
free(p);
return 0;
}
strcat(name,"\\tmpfile");
if ((fp=fopen(name,"wb"))==NULL) {
free(p);
return 0;
}
fwrite(p,1,filelen+24,fp);
fclose(fp);
free(p);
return 1;
}
int AddGtxHead(char *name)
{
FILE *fp;
int filelen;
char *p;
if ((fp=fopen(name,"rb"))==NULL) return 0;
fseek(fp,0,SEEK_END);
filelen=ftell(fp)-16;
fseek(fp,16,SEEK_SET);
if (filelen<=0) return 0;
p=(char *)malloc(filelen+24);
if (p==NULL) {
fclose(fp);
return 0;
}
fread(p+24,1,filelen,fp);
fclose(fp);
memcpy(p,txt_head,24);
*(long *)(p+10)=filelen+24;
*(long *)(p+19)=filelen+24;
if (!GetTempPath(250,name)) {
free(p);
return 0;
}
strcat(name,"\\tmpfile");
if ((fp=fopen(name,"wb"))==NULL) {
free(p);
return 0;
}
fwrite(p,1,filelen+24,fp);
fclose(fp);
free(p);
return 1;
}
void CutTxtHead(char *tmpname,char *name)
{
FILE *fp;
int filelen;
char *p;
if ((fp=fopen(tmpname,"rb"))==NULL) return;
fseek(fp,0,SEEK_END);
filelen=ftell(fp);
if (filelen<24) {
fclose(fp);
return;
}
fseek(fp,24,SEEK_SET);
p=(char *)malloc(filelen-24);
if (p==NULL) {
fclose(fp);
return;
}
fread(p,1,filelen-24,fp);
fclose(fp);
if ((fp=fopen(name,"wb"))==NULL) {
free(p);
return;
}
fwrite(p,1,filelen-24,fp);
fclose(fp);
free(p);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -