sobota, 29 czerwca 2019

info file (class C++ Builder)

class info_my_FILE
{
private:
VS_FIXEDFILEINFO *type_File;
UnicodeString name;
void *temp_info;
unsigned long temp_Long;
char *buff_File;

int size_Buff;
UnicodeString result_File;


public:

void read_File(UnicodeString name_File)
{

name=name_File;
unsigned int temp_value_Size;
size_Buff=GetFileVersionInfoSize(name.w_str(),&temp_Long);
buff_File=new char[size_Buff];
GetFileVersionInfo(name.w_str(),0,size_Buff,buff_File);
if(VerQueryValue(buff_File,L"\\",&temp_info,&temp_value_Size))
{
type_File=(VS_FIXEDFILEINFO*)temp_info;
if(type_File->dwFileType==VFT_DLL)
result_File="library DLL";
else if(type_File->dwFileType==VFT_APP)
result_File="application .exe";
else if(type_File->dwFileType==VFT_DRV)
result_File="DRV Type";
else if(type_File->dwFileType==VFT_STATIC_LIB)
result_File="static Library";
else if(type_File->dwFileType==VFT_FONT)
result_File="font type";
else if(type_File->dwFileType==VFT_VXD)
result_File="virtual";
else
  result_File="unknown type";
}


}

int write_size_Buff()
{
return size_Buff;
}
UnicodeString writeType()
{
return result_File;
}
~info_my_FILE()
{
delete buff_File;
}
};


void __fastcall TForm1::Button1Click(TObject *Sender)
{
 UnicodeString files[3];
 files[0]=Application->ExeName;
 files[1]="C:\\BOOTSECT.BAK";
 files[2]="C:\\Windows\\PFRO.log";
 info_my_FILE *my_Files=new info_my_FILE[3];
 int i;
 for(i=0;i<3;i++)
 {
my_Files[i].read_File(files[i]);
 }
 for(i=0;i<3;i++)
 {
ListBox1->Items->Add(my_Files[i].writeType()+" - "+IntToStr(my_Files[i].write_size_Buff()));
 }


 delete my_Files;
}

Brak komentarzy:

Prześlij komentarz