if (sh! =NULL)
{
strcat (lpszSystemInfo, "Имя доступной локальной машины: \t");
strcat (lpszSystemInfo, sh->h_name);
strcat (lpszSystemInfo, " ");
int n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long] = 13;
lpszSystemInfo [n_long+1] = 10;
int nAdapter = 0;
while (sh->h_addr_list [nAdapter])
{
struct sockaddr_in adr;
memcpy (&adr. sin_addr,sh->h_addr_list [nAdapter],sh->h_length);
strcat (lpszSystemInfo, "IP адрес локальной машины: \t");
strcat (lpszSystemInfo, inet_ntoa (adr. sin_addr));
strcat (lpszSystemInfo, " ");
int n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long] = 13;
lpszSystemInfo [n_long+1] = 10;
nAdapter++;
}
}
WSACleanup (); }
}
/*NCB SNcb; // Структура для работы с NetBios
CHARrc= 0; // Код возврата
CHARStatus [256]; // Буфер для получения данных
CHARHostName [] ="SomeHost"; // Имя удалённого компа
CHARMAC [20]; // Буфер для нашего MAC-адреса.
memset (&SNcb, 0, sizeof (SNcb));
SNcb. ncb_command = NCBRESET;
SNcb. ncb_lana_num = 0;
rc=Netbios (&SNcb); // Сбрасываем NetBios
memset (&SNcb, 0, sizeof (NCB));
SNcb. ncb_command = NCBASTAT;
SNcb. ncb_buffer = (unsigned char*) Status;
SNcb. ncb_length = 256;
lstrcpy ( (char*) SNcb. ncb_callname, HostName);
SNcb. ncb_lana_num= 0; // Сетевой адаптор по умалчанию
rc = Netbios (&SNcb);
if (rc==NRC_GOODRET) // Если всё ОК
memcpy (MAC, Status,
6);
// itoa (MAC, tmp, 20);
strcat (lpszSystemInfo, Status);
strcat (lpszSystemInfo, " ");
int n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long] = 13;
lpszSystemInfo [n_long+1] = 10; */
SendMessage (StaticText, WM_SETTEXT, 0, (LPARAM) lpszSystemInfo);
}
void PrinterInfo ()
{
LPTSTR lpszSystemInfo = new char [BUFSIZE]; // указатель на строку, в которой
for (int a=0; a<BUFSIZE; a++)
lpszSystemInfo [a] = '\0';
PRINTER_INFO_2 printinfo;
char pname [100];
char strpPrinterName [100], strpPortName [100], strpDriverName [100], strpPrintProcessor [100];
printinfo. pPrinterName = strpPrinterName;
printinfo. pPortName = strpPortName;
printinfo. pDriverName = strpDriverName;
printinfo. pPrintProcessor = strpPrintProcessor;
PRINTER_INFO_2 *Pr;
DWORDbyteNeed= 0,prCount=0; // Кол-во необходимых байт, количество принтеров
// Делаем первый вызов с буфером NULL, чтоб узнать нужный размер буфера
EnumPrinters (PRINTER_ENUM_CONNECTIONS|PRINTER_ENUM_LOCAL,NULL,2,NULL,0,&byteNeed,&prCount);
// Создаем буфер
Pr = new PRINTER_INFO_2 [byteNeed];
// Делаем второй вызов уже с нужным буфером
if (EnumPrinters (PRINTER_ENUM_CONNECTIONS|PRINTER_ENUM_LOCAL,NULL,2, (LPBYTE) Pr,byteNeed,&byteNeed,&prCount))
{
for (int i = 0; i < prCount; ++i)
{
strcat (lpszSystemInfo, "Установленные принтеры: \t");
strcat (lpszSystemInfo, Pr [i]. pPrinterName);
strcat (lpszSystemInfo, " ");
int n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
strcat (lpszSystemInfo, "Порт принтера: \t\t");
strcat (lpszSystemInfo, Pr [i]. pPortName);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
strcat (lpszSystemInfo, "Драйвер принтера: \t");
strcat (lpszSystemInfo, Pr [i]. pDriverName);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
strcat (lpszSystemInfo, "Процессор печати: \t");
strcat (lpszSystemInfo, Pr [i]. pPrintProcessor);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
SendMessage (StaticText, WM_SETTEXT, 0, (LPARAM) lpszSystemInfo);
}
}
delete Pr;
}
void DxInfo ()
{
LPTSTR lpszSystemInfo = new char [BUFSIZE]; // указатель на строку, в которой
for (int a=0; a<BUFSIZE; a++)
lpszSystemInfo [a] = '\0';
char *tmp = new char [20];
GUID *lpGUID;
LPDIRECTDRAW lplpDD;
DirectDrawCreate (0,&lplpDD,NULL);
DDSURFACEDESC pDDS;
ZeroMemory (&pDDS, sizeof (DDSURFACEDESC));
pDDS. dwSize = sizeof (DDSURFACEDESC);
lplpDD->GetDisplayMode (&pDDS);
strcat (lpszSystemInfo, "Информация о текущем видеорежиме: ");
int n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long] = 13;
lpszSystemInfo [n_long+1] = 10;
lpszSystemInfo [n_long+2] = 13;
lpszSystemInfo [n_long+3] = 10;
itoa (pDDS. dwHeight, tmp,
10);
strcat (lpszSystemInfo, "Количество точек по вертикали: \t");
strcat (lpszSystemInfo, tmp);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
itoa (pDDS. dwWidth, tmp,
10);
strcat (lpszSystemInfo, "Количество точек по горизонтали: \t");
strcat (lpszSystemInfo, tmp);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
itoa (pDDS. dwRefreshRate, tmp,
10);
strcat (lpszSystemInfo, "Частота обновления, Гц: \t\t");
strcat (lpszSystemInfo, tmp);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
itoa (pDDS. dwAlphaBitDepth, tmp,
10);
strcat (lpszSystemInfo, "Глубина альфа-буффра (бит/пиксел): \t");
strcat (lpszSystemInfo, tmp);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
itoa (pDDS. ddpfPixelFormat. dwRGBBitCount, tmp,
10);
strcat (lpszSystemInfo, "Глубина RGB цвета (бит/пиксел): \t");
strcat (lpszSystemInfo, tmp);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
itoa (pDDS. ddpfPixelFormat. dwZBufferBitDepth, tmp,
10);
strcat (lpszSystemInfo, "Глубина Z-буффра (бит/пиксел): \t");
strcat (lpszSystemInfo, tmp);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
itoa (pDDS. ddpfPixelFormat. dwAlphaBitDepth, tmp,
10);
strcat (lpszSystemInfo, "Глубина альфа-канала (бит/пиксел): \t");
strcat (lpszSystemInfo, tmp);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
SendMessage (StaticText, WM_SETTEXT, 0, (LPARAM) lpszSystemInfo);
}
void DrivesInfo ()
{
LPTSTR lpszSystemInfo = new char [BUFSIZE]; // указатель на строку, в которой
for (int a=0; a<BUFSIZE; a++)
lpszSystemInfo [a] = '\0';
char cDevices [] = "A: \";
DWORD dwDevices = GetLogicalDrives (); // получаем все логические диски
bool flag = false;
for (int i = 0; dwDevices; i++) // проверяем на наличие дисков
{
if (dwDevices & 1)
{
cDevices [0] = 'A' + i;
flag = true;
}
if (flag)
{
flag = false;
strcat (lpszSystemInfo, "Диск ");
strcat (lpszSystemInfo, cDevices);
strcat (lpszSystemInfo, " ");
int n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long] = 13;
lpszSystemInfo [n_long+1] = 10;
UINT type = GetDriveType (cDevices);
switch (type)
{
case DRIVE_UNKNOWN:
strcat (lpszSystemInfo, "Не известный тип");
break;
case DRIVE_NO_ROOT_DIR:
strcat (lpszSystemInfo, "Не правильный путь");
break;
case DRIVE_REMOVABLE:
strcat (lpszSystemInfo, "Съёмный диск");
break;
case DRIVE_FIXED:
strcat (lpszSystemInfo, "Жесткий диск");
break;
case DRIVE_REMOTE:
strcat (lpszSystemInfo, "Удалённый или network диск. ");
break;
case DRIVE_CDROM:
strcat (lpszSystemInfo, "CD-ROM диск");
break;
case DRIVE_RAMDISK:
strcat (lpszSystemInfo, "RAM диск");
break;
}
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
/***********************************************************/
char VolumeNameBuffer [100];
VolumeNameBuffer [0] = '\0';
char FileSystemNameBuffer [100];
FileSystemNameBuffer [0] = '\0';
unsigned long VolumeSerialNumber;
BOOL GetVolumeInformationFlag = GetVolumeInformation (
cDevices,
VolumeNameBuffer,
100,&VolumeSerialNumber,
NULL, // &MaximumComponentLength,
NULL, // &FileSystemFlags,
FileSystemNameBuffer,
100
);
strcat (lpszSystemInfo, "Имя диска: ");
strcat (lpszSystemInfo, VolumeNameBuffer);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long] = 13;
lpszSystemInfo [n_long+1] = 10;
char *serial = new char [20];
serial [0] = '\0';
itoa (VolumeSerialNumber, serial,
10);
strcat (lpszSystemInfo, "Серийный номер: ");
strcat (lpszSystemInfo, serial);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long] = 13;
lpszSystemInfo [n_long+1] = 10;
strcat (lpszSystemInfo, "Файловая система: ");
strcat (lpszSystemInfo, FileSystemNameBuffer);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long] = 13;
lpszSystemInfo [n_long+1] = 10;
/***********************************************************/
if (type! = DRIVE_FIXED)
{
dwDevices >>= 1;
continue;
}
DWORD FreeBytesAvailable;
DWORD TotalNumberOfBytes;
DWORD TotalNumberOfFreeBytes;
BOOL GetDiskFreeSpaceFlag = GetDiskFreeSpaceEx (
cDevices, // directory name
(PULARGE_INTEGER) &FreeBytesAvailable, // bytes available to caller
(PULARGE_INTEGER) &TotalNumberOfBytes, // bytes on disk
(PULARGE_INTEGER) &TotalNumberOfFreeBytes // free bytes on disk
);
if (GetDiskFreeSpaceFlag! = FALSE)
{
char * free = new char [20];
itoa ( (unsigned long int) FreeBytesAvailable, free,
10);
char * total = new char [20];
itoa ( (unsigned long int) TotalNumberOfBytes, total,
10);
char * avaliable = new char [20];
itoa ( (unsigned long int) TotalNumberOfFreeBytes, avaliable,
10);
strcat (lpszSystemInfo, "Свободно: ");
strcat (lpszSystemInfo, free);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
strcat (lpszSystemInfo, "Общий объем: ");
strcat (lpszSystemInfo, total);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
strcat (lpszSystemInfo, "Доступно ");
strcat (lpszSystemInfo, avaliable);
strcat (lpszSystemInfo, " ");
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
}
}
dwDevices >>= 1;
}
strcat (lpszSystemInfo, " ");
int n_long = strlen (lpszSystemInfo);
lpszSystemInfo [n_long-2] = 13;
lpszSystemInfo [n_long-1] = 10;
SendMessage (StaticText, WM_SETTEXT, 0, (LPARAM) lpszSystemInfo);
}
Index. h
#pragma once
#include <ddraw. h>
#define BUFSIZE 1024
void SysInf ();
void MemStat ();
void CPUInfo ();
void GetCurentIP ();
void PrinterInfo ();
void DxInfo ();
void DrivesInfo ();
class Info
{
public:
Info ();
void CreateInfo (char* value, int Index, void (*function) ());
void (*function) ();
private:
int Index;
char *value;
};