Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
15
Добавлен:
01.05.2014
Размер:
5.7 Кб
Скачать
#include<windows.h>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
using namespace std;

int ObGetComputerName();
int ObGetSystemInfo();
int ObGetLogicalDrives();
int ObGetDriveType(char* Name);
int ObGetDiskFreeSpace(char* Name);
int Menu();
int AskName(char* Name); 

//********************************************************************
//********************************************************************
//********************************************************************
int main(void)
{
 char Name[4]={' ',':','\\','\0'};	
 int Answer;

	do
	{
		Answer=Menu();
		system("cls");
		switch(Answer)
		{
			case 1 :
				ObGetComputerName();
				ObGetSystemInfo();
				getch();
				break;
			case 2 :
				ObGetLogicalDrives();
				getch();
				break;
			case 3:
				AskName(Name);
				ObGetDiskFreeSpace(Name);				
				ObGetDriveType(Name);
				getch();
		};
	}
	while(Answer!=4);
	return 1;
}
//********************************************************************
//********************************************************************
//********************************************************************
int ObGetComputerName()
{	char buff[MAX_COMPUTERNAME_LENGTH + 1];
	DWORD size=MAX_COMPUTERNAME_LENGTH + 1;

	GetComputerName(buff,(LPDWORD)&size);
	cout<<buff<<endl;
	return 1;
}
//********************************************************************
//********************************************************************
//********************************************************************
int ObGetSystemInfo()
{	SYSTEM_INFO SysInfo;
	
	GetSystemInfo((LPSYSTEM_INFO) &SysInfo);
	cout<<SysInfo.dwOemId <<" - OemId"<<endl;
	cout<<SysInfo.wProcessorArchitecture <<" - ProcessorArchitecture"<<endl;
	cout<<SysInfo.wReserved <<" - Reserved"<<endl;
	cout<<SysInfo.dwPageSize <<" - PageSize"<<endl;
	cout<<SysInfo.lpMinimumApplicationAddress <<" - MinimumApplicationAddress"<<endl;
	cout<<SysInfo.lpMaximumApplicationAddress <<" - MaximumApplicationAddress"<<endl;
	cout<<SysInfo.dwActiveProcessorMask<<" - ActiveProcessorMask"<<endl;
	cout<<SysInfo.dwNumberOfProcessors <<" - NumberOfProcessors"<<endl;
	cout<<SysInfo.dwProcessorType <<" - ProcessorType"<<endl;
	cout<<SysInfo.dwAllocationGranularity <<" -  AllocationGranularity"<<endl;
	cout<<SysInfo.wProcessorLevel <<" - ProcessorLevel"<<endl;
	cout<<SysInfo.wProcessorRevision <<" - ProcessorRevision"<<endl;
	return 1;
}
//********************************************************************
//********************************************************************
//********************************************************************
int ObGetLogicalDrives()
{	DWORD mask;
	
	mask=GetLogicalDrives();
	for(char i=0;i<26;i++)
		if((mask>>i)&1)
			cout<<(char)('A'+i)<<endl;
	return 1;
}
//********************************************************************
//********************************************************************
//********************************************************************
int ObGetDriveType(char* Name)
{	UINT Type; 

	Type=GetDriveType(Name);
	switch(Type)
	{
		case 0 : cout<<"Tip nakopitela ne opredelen"<<endl;
			break;
		case 1 : cout<<"Kornevoi derektorii ne sushestvuet"<<endl;
			break;
		case DRIVE_REMOVABLE : cout<<"Nakopitel moget udalyatsya s nakopitela"<<endl;
			break;
		case DRIVE_FIXED : cout<<"Fiksirovanii disk(ne moget bit udalen)"<<endl; 
			break;
		case DRIVE_REMOTE : cout<<"Udalennii nakopitel(setevoi disk)"<<endl; 
			break;
		case DRIVE_CDROM : cout<<"CD-ROM"<<endl; 
			break;
		case DRIVE_RAMDISK : cout<<"Nakopitel yavlyaetsa virtualnim RAM DISK'om"<<endl; 
	};
	return 1;
}
//********************************************************************
//********************************************************************
//********************************************************************
int ObGetDiskFreeSpace(char* Name)
{
 DWORD 	SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, TotalNumberOfClusters;

	GetDiskFreeSpace(Name,(LPDWORD) &SectorsPerCluster,(LPDWORD) &BytesPerSector,(LPDWORD) &NumberOfFreeClusters,(LPDWORD) &TotalNumberOfClusters);
	cout<<Name[0]<<endl;
	cout<<SectorsPerCluster<<" - SectorsPerCluster"<<endl;
	cout<<BytesPerSector<<" - BytesPerSector"<<endl;
	cout<<NumberOfFreeClusters<<" - NumberOfFreeClusters"<<endl;
	cout<<TotalNumberOfClusters<<" - TotalNumberOfClusters"<<endl;
	cout<<"Free  space: "<<SectorsPerCluster*BytesPerSector*NumberOfFreeClusters<<" bytes"<<endl;
	cout<<"Total space: "<<SectorsPerCluster*BytesPerSector*TotalNumberOfClusters<<" bytes"<<endl;
	return 1;
}
//********************************************************************
//********************************************************************
//********************************************************************
int Menu(void)
{
 int number;

	do
	{
		system("cls");
		cout<<"1  -  System Information"<<endl;
		cout<<"2  -  Drives list"<<endl;
		cout<<"3  -  Drive Information"<<endl;
		cout<<"4  -  Exit"<<endl;
		cout<<"Vash vibor: "; 
		cin>>number;
	}
	while(number>4 || number<1);
	return number;
}
//********************************************************************
//********************************************************************
//********************************************************************
int AskName(char* Name)
{
	cout<<"please enter Drive Name: ";
	cin>>Name[0];
	cout<<endl;
	while(Name[0]<'A' || Name[0]>'Z')
	{
		cout<<"Wrong Drive Name. Please enter Drive Name(A-Z): ";
		cin>>(char)Name[0];
		cout<<endl;
	}
	return 1;
}
Соседние файлы в папке Лабораторная работа1