舊硬盤的oem分區怎麼删除?/* 硬盤分區表的保存及恢複 */,現在小編就來說說關于舊硬盤的oem分區怎麼删除?下面内容希望能幫助到你,我們來一起看看吧!
舊硬盤的oem分區怎麼删除
/* 硬盤分區表的保存及恢複 */
# include<stdio.h>
# include<bios.h>
# include<fcntl.h>
# include<sys\types.h>
# include<sys\stat.h>
void helpmsg(void);
int main(int argc,char *argv[])
{
int result;
char buffer[512];
FILE *fp;
if(argc==1)
helpmsg();
if(*argv[1]=='a'||*argv[1]=='A')
{
result=biosdisk(2,0x80,0,0,1,1,buffer);
if(!result)
{
printf("讀硬盤分區表成功\n");
if((fp=fopen("a:part.doc","wb "))==NULL)
{
fprintf(stderr,"不能創建文件:a:\part.doc\n");
exit(1);
}
fwrite(buffer,1,512,fp);
fclose(fp);
printf("硬盤分區表保存成功\n");
return 0;
}
else
{
fprintf(stderr,"讀硬盤分區表失敗");
exit(1);
}
}
if(*argv[1]=='c'||*argv[1]=='C')
{
if((fp=fopen("a:part.doc","rb "))==NULL)
{
fprintf(stderr,"文件打開失敗");
exit(1);
}
fread(buffer,1,512,fp);
result=biosdisk(3,0x80,0,0,1,1,buffer);
if(!result)
{
printf("硬盤分區表恢複成功");
fclose(fp);
return 0;
}
else
{
fprintf(stderr,"硬盤分區表恢複失敗");
fclose(fp);
exit(1);
}
}
return 0;
}
void helpmsg(void)
{
puts("程序使用的正确格式為:Boot[A]或Boot[C]");
puts("其中參數:B---保存硬盤分區表到B盤");
puts("其中參數:C---從B盤恢複硬盤分區表");
exit(0);
}
,