當前位置:首頁 » 文件管理 » 壓縮編寫

壓縮編寫

發布時間: 2022-08-05 15:58:27

『壹』 如何編寫數據壓縮系統

那麼有兩種情況,1是第三方的文件,2是自身程序
也不是絕對不能做到,能做到但是效果不好,並且也十分復雜.
主要思路說說吧
利用Hook來監視文件操作,更高級的方式是監控硬碟的操作,需要有個常駐內存的程序來監控,就象360等一樣,
但這樣的話別人隨便用什麼PE進入系統,監視就無效了
自身程序想防止拷貝和壓縮很難做到,至少我還沒有這方面的思路,因為所有軟體都是以數據形式存儲在硬碟中的,它本身就是一段數據,除了使用外部程序的控制,按照目前的存儲技術很難做到自防止.這也是目前盜版較容易的原由所在.也因此各種軟體採取了注冊碼,網上驗證方式來防止程序的共享.
不好意思,這個技術很難,恐怕得從存儲機理上下功夫,如果被發明出來,可能會引發全球的存儲技術的革新,目前也沒有其他好的方法.
另外,虛機團上產品團購,超級便宜

『貳』 如何用VB編寫壓縮與解壓縮的程序

自己編寫一個好的壓縮與解壓縮程序,演算法是相當復雜的,如果只是想把多個文件打個包並不難,把多個文件寫入一個二進制文件即可,當然這裡面也要有文件名如何保存,每個文件到哪結束等的問題。
最簡單的方法是調用第三方軟比如zip等,建議調用ARJ.EXE或LHARC.EXE因為它們只一個文件並且體積都很小壓縮比也不錯。

『叄』 如何用C語言編寫一個簡單的壓縮程序

覺得難度夠大了,談談我的方法吧:比如字元串"aabbccddeeffgg123456789"可以看到裡面有字母重復,並且有規律,是否可以表示成2a to 2g 1 to 9?因該可以的,數據壓縮的原理也都是把冗餘的數據簡化表示從而減少數據的大小,解壓時就是反向過程,但是怎麼完整表示這些被壓縮的數據就是個要研究的問題。

『肆』 我能自己編寫壓縮代碼嗎不用壓縮工具來進行

這是用是用霍夫曼樹做的C語言文件壓縮解壓縮程序
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
struct head
{
unsigned char b; /*the charactor*/
long count; /*the frequency*/
long parent,lch,rch; /*make a tree*/
char bits[256]; /*the haffuman code*/
}
header[512],tmp;

void compress()
{
char filename[255],outputfile[255],buf[512];
unsigned char c;
long i,j,m,n,f;
long min1,pt1,flength;
FILE *ifp,*ofp;
printf("source filename:");
gets(filename);
ifp=fopen(filename,"rb");
if(ifp==NULL)
{
printf("source file open error!\n");
return;
}
printf("destination filename:");
gets(outputfile);
ofp=fopen(outputfile,"wb");
if(ofp==NULL)
{
printf("destination file open error!\n");
return;
}
flength=0;
while(!feof(ifp))
{
fread(&c,1,1,ifp);
header[c].count++;
flength++;
}
flength--;
header[c].count--;
for(i=0;i<512;i++)
{
if(header[i].count!=0) header[i].b=(unsigned char)i;
else header[i].b=0;
header[i].parent=-1;
header[i].lch=header[i].rch=-1;
}
for(i=0;i<256;i++)
{
for(j=i+1;j<256;j++)
{
if(header[i].count<header[j].count)
{
tmp=header[i];
header[i]=header[j];
header[j]=tmp;
}
}
}
for(i=0;i<256;i++) if(header[i].count==0) break;
n=i;
m=2*n-1;
for(i=n;i<m;i++)
{
min1=999999999;
for(j=0;j<i;j++)
{
if(header[j].parent!=-1) continue;
if(min1>header[j].count)
{
pt1=j;
min1=header[j].count;
continue;
}
}
header[i].count=header[pt1].count;
header[pt1].parent=i;
header[i].lch=pt1;
min1=999999999;
for(j=0;j<i;j++)
{
if(header[j].parent!=-1) continue;
if(min1>header[j].count)
{
pt1=j;
min1=header[j].count;
continue;
}
}
header[i].count+=header[pt1].count;
header[i].rch=pt1;
header[pt1].parent=i;
}
for(i=0;i<n;i++)
{
f=i;
header[i].bits[0]=0;
while(header[f].parent!=-1)
{
j=f;
f=header[f].parent;
if(header[f].lch==j)
{
j=strlen(header[i].bits);
memmove(header[i].bits+1,header[i].bits,j+1);
header[i].bits[0]='0';
}
else
{
j=strlen(header[i].bits);
memmove(header[i].bits+1,header[i].bits,j+1);
header[i].bits[0]='1';
}
}
}
fseek(ifp,0,SEEK_SET);
fwrite(&flength,sizeof(int),1,ofp);
fseek(ofp,8,SEEK_SET);
buf[0]=0;
f=0;
pt1=8;
while(!feof(ifp))
{
c=fgetc(ifp);
f++;
for(i=0;i<n;i++)
{
if(c==header[i].b) break;
}
strcat(buf,header[i].bits);
j=strlen(buf);
c=0;
while(j>=8)
{
for(i=0;i<8;i++)
{
if(buf[i]=='1') c=(c<<1)|1;
else c=c<<1;
}
fwrite(&c,1,1,ofp);
pt1++;
strcpy(buf,buf+8);
j=strlen(buf);
}
if(f==flength) break;
}
if(j>0)
{
strcat(buf,"00000000");
for(i=0;i<8;i++)
{
if(buf[i]=='1') c=(c<<1)|1;
else c=c<<1;
}
fwrite(&c,1,1,ofp);
pt1++;
}
fseek(ofp,4,SEEK_SET);
fwrite(&pt1,sizeof(long),1,ofp);
fseek(ofp,pt1,SEEK_SET);
fwrite(&n,sizeof(long),1,ofp);
for(i=0;i<n;i++)
{
fwrite(&(header[i].b),1,1,ofp);
c=strlen(header[i].bits);
fwrite(&c,1,1,ofp);
j=strlen(header[i].bits);
if(j%8!=0)
{
for(f=j%8;f<8;f++)
strcat(header[i].bits,"0");
}
while(header[i].bits[0]!=0)
{
c=0;
for(j=0;j<8;j++)
{
if(header[i].bits[j]=='1') c=(c<<1)|1;
else c=c<<1;
}
strcpy(header[i].bits,header[i].bits+8);
fwrite(&c,1,1,ofp);
}
}
fclose(ifp);
fclose(ofp);
printf("compress successfully!\n");
return;
}
void uncompress()
{
char filename[255],outputfile[255],buf[255],bx[255];
unsigned char c;
long i,j,m,n,f,p,l;
long flength;
FILE *ifp,*ofp;
printf("source filename:");
gets(filename);
ifp=fopen(filename,"rb");
if(ifp==NULL)
{
printf("source file open error!\n");
return;
}
printf("destination filename:");
gets(outputfile);
ofp=fopen(outputfile,"wb");
if(ofp==NULL)
{
printf("destination file open error!\n");
return;
}
fread(&flength,sizeof(long),1,ifp);
fread(&f,sizeof(long),1,ifp);
fseek(ifp,f,SEEK_SET);
fread(&n,sizeof(long),1,ifp);
for(i=0;i<n;i++)
{
fread(&header[i].b,1,1,ifp);
fread(&c,1,1,ifp);
p=(long)c;
header[i].count=p;
header[i].bits[0]=0;
if(p%8>0) m=p/8+1;
else m=p/8;
for(j=0;j<m;j++)
{
fread(&c,1,1,ifp);
f=c;
itoa(f,buf,2);
f=strlen(buf);
for(l=8;l>f;l--)
{
strcat(header[i].bits,"0");
}
strcat(header[i].bits,buf);
}
header[i].bits[p]=0;
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(strlen(header[i].bits)>strlen(header[j].bits))
{
tmp=header[i];
header[i]=header[j];
header[j]=tmp;
}
}
}
p=strlen(header[n-1].bits);
fseek(ifp,8,SEEK_SET);
m=0;
bx[0]=0;
while(1)
{
while(strlen(bx)<(unsigned int)p)
{
fread(&c,1,1,ifp);
f=c;
itoa(f,buf,2);
f=strlen(buf);
for(l=8;l>f;l--)
{
strcat(bx,"0");
}
strcat(bx,buf);
}
for(i=0;i<n;i++)
{
if(memcmp(header[i].bits,bx,header[i].count)==0) break;
}
strcpy(bx,bx+header[i].count);
c=header[i].b;
fwrite(&c,1,1,ofp);
m++;
if(m==flength) break;
}
fclose(ifp);
fclose(ofp);
printf("Uncompress successfully!\n");
return;
}
int main()
{
int c;
printf("1--Compress file\n");
printf("2--Uncompress file\n");
printf("Select 1 or 2:");
c=getch();
printf("%c\n",c);
if(c=='1') compress();
else if(c=='2') uncompress();
return 0;
}

『伍』 怎麼編寫bat文件,對文件夾進行壓縮

@echo off

set rar="%ProgramFiles%\WinRAR\winrar.exe"
%rar% a -afzip -r -ep1 "D:\a\b" "5.zip"

『陸』 請問用C語言怎麼編寫壓縮軟體啊

二大要點:
一、文件操作:
打開需要壓縮的原文件並讀取之;
新建寫入的壓縮文件寫入之;

二、壓縮演算法

『柒』 C語言求助:請編寫一個字元串壓縮程序,將字元串中連續出席的重復字母進行壓縮,並輸出壓縮後的字元串。

#include <stdio.h>

void stringZip(const char

*pInputStr, long lInputLen, char *pOutputStr)

{ int n=1;

char c,*p1=pInputStr,*p2=pOutputStr;

while(*p1)

{

c=*(p1++);

while(*p1==c){n++;p1++;}

if(n>1)

{

if(n>999){*(p2++)=48+n/1000; n/=10;}

if(n>99){*(p2++)=48+n/100; n/=10;}

if(n>9){*(p2++)=48+n/10; n/=10;}

*(p2++)=48+n;

}

*(p2++)=c;

n=1;

}

*p2='';

}

void main()

{ char s1[200],s2[200];

gets(s1);

stringZip(s1,strlen(s1),s2);

puts(s2);

}

『捌』 用C語言如何對文件進行壓縮

winrar軟體安裝後,所在的安裝目錄下有個rar.exe,開一個命令窗口到該目錄下運行rar
/?就能看到用法了,在你的程序裡面調用它的相應命令行是最簡單的方法,自己編寫壓縮演算法的話,先不談效率,起碼演算法就是相當復雜的了

熱點內容
VB訪問sqlserver 發布:2025-05-07 04:23:05 瀏覽:589
apachephp編譯 發布:2025-05-07 04:22:34 瀏覽:636
怎麼查電腦的軟體配置 發布:2025-05-07 04:22:27 瀏覽:951
伺服器限制ip訪問了怎麼辦 發布:2025-05-07 04:07:35 瀏覽:876
php語法基礎 發布:2025-05-07 04:07:26 瀏覽:473
阿里雲伺服器發郵件 發布:2025-05-07 03:52:27 瀏覽:111
php頁面靜態化 發布:2025-05-07 03:48:09 瀏覽:825
程序編程入門書籍推薦 發布:2025-05-07 03:40:32 瀏覽:449
資料庫的配置信息 發布:2025-05-07 03:25:48 瀏覽:853
瘋狂腳本 發布:2025-05-07 03:24:23 瀏覽:723