C++ Builder
| | | | FAQ | | Downloads | | | RXLib | |

 , ( | )   | | |
  :   y   
     
 
.,
« | » | E-mail |
R()m]{@r
: 22.02.2007, 17:13


-


:
: 2
4488
: 22.02.07



.
, :
1)
2)
3)
4)
5)
(ID) .
1024768 12801024 ????
 
  E-mail   Top
AVC
: 22.02.2007, 17:21





:
: 1583
655
: 19.05.04



, , .
 
  E-mail  ICQ  Top
R()m]{@r
: 19.03.2007, 23:47


-


:
: 2
4488
: 22.02.07



, , . yahoo.gif
WinAPI : !!!!

CODE

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "unit_Start.h"

#include <dos.h>
#include <math.h>
#include <setupapi.h>
#include <stdio.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

/////////////////////////////////
//
double GetCPUSpeed()
{
int DelayTime = 500;

DWORD TimerHi, TimerLo;
int PriorityClass, Priority;

PriorityClass = GetPriorityClass(GetCurrentProcess);
Priority = GetThreadPriority(GetCurrentThread);

SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL);

Sleep(10);

asm {
dw 310Fh
mov TimerLo, eax
mov TimerHi, edx
}

Sleep(DelayTime);

asm {
dw 310Fh
sub eax, TimerLo
sbb edx, TimerHi
mov TimerLo, eax
mov TimerHi, edx
}

SetThreadPriority(GetCurrentThread, Priority);
SetPriorityClass(GetCurrentProcess, PriorityClass);

return (TimerLo/(1000.0 * DelayTime));
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{

/////////////////////////////////
// "init.log"

FILE *F;
if ((F = fopen("init.log", "wt")) == NULL)
{
ShowMessage(" ""init.log"" !");
return;
}

/////////////////////////////////
//

struct date d;
getdate(&d);

fprintf(F,": %d.%d.%d \n",d.da_day,d.da_mon,d.da_year);

/////////////////////////////////
//

fprintf(F,"\n");
fprintf(F," : %f \n",GetCPUSpeed());

/////////////////////////////////
//

fprintf(F,"\n");
fprintf(F,"[ ]\n");
MEMORYSTATUS MemStat;
GlobalMemoryStatus(&MemStat);
fprintf(F," : %i \n",MemStat.dwTotalPhys/1024/1024);
fprintf(F," : %i \n",MemStat.dwAvailPhys/1024/1024);
fprintf(F," : %i \n",MemStat.dwTotalVirtual/1024/1024);
fprintf(F," : %i \n",MemStat.dwAvailVirtual/1024/1024);

/////////////////////////////////
//

fprintf(F,"\n");
fprintf(F,"[ ]\n");
fprintf(F," : %s / %s \n",IntToStr(DiskSize(3)),IntToStr(DiskSize(3)/1048576));
fprintf(F," : %s / %s \n",IntToStr(DiskFree(3)),IntToStr(DiskFree(3)/1048576));
if(DiskSize(4)== -1)
{
}
else
{
fprintf(F," D: %s / %s \n",IntToStr(DiskSize(4)),IntToStr(DiskSize(4)/1048576));
fprintf(F," D: %s / %s \n",IntToStr(DiskFree(4)),IntToStr(DiskFree(4)/1048576));
}
if(DiskSize(5)== -1)
{
}
else
{
fprintf(F," E: %s / %s \n",IntToStr(DiskSize(5)),IntToStr(DiskSize(5)/1048576));
fprintf(F," E: %s / %s \n",IntToStr(DiskFree(5)),IntToStr(DiskFree(5)/1048576));
}
if(DiskSize(6)== -1)
{
}
else
{
fprintf(F," F: %s / %s \n",IntToStr(DiskSize(6)),IntToStr(DiskSize(6)/1048576));
fprintf(F," F: %s / %s \n",IntToStr(DiskFree(6)),IntToStr(DiskFree(6)/1048576));
}

/////////////////////////////////
//

TDisplayDevice lpDisplayDevice;
DWORD dwFlags;
DWORD cc;

lpDisplayDevice.cb = sizeof(lpDisplayDevice);
dwFlags = 0;
cc = 0;

EnumDisplayDevices(NULL,cc,&lpDisplayDevice,dwFlags);

fprintf(F,"\n");
fprintf(F,"[ ]\n");
fprintf(F,"%s\n",lpDisplayDevice.DeviceString);
fprintf(F," : %i \n",lpDisplayDevice.StateFlags/1024/1024);
fprintf(F,"%s\n",lpDisplayDevice.DeviceKey); //

/////////////////////////////////
//

int DeskHor; //. . .
fprintf(F,"\n");
fprintf(F,"[ ]\n");
fprintf(F," : %i\n",DeskHor=GetDeviceCaps(Form1->Canvas->Handle,DESKTOPHORZRES));
fprintf(F," : %i\n",GetDeviceCaps(Form1->Canvas->Handle,DESKTOPVERTRES));
fprintf(F," (): %i\n",GetDeviceCaps(Form1->Canvas->Handle,BITSPIXEL));
fprintf(F," : %i \n",GetDeviceCaps(Form1->Canvas->Handle,VREFRESH));
fprintf(F," : %i \n",GetDeviceCaps(Form1->Canvas->Handle,HORZSIZE));
fprintf(F," : %i \n",GetDeviceCaps(Form1->Canvas->Handle,VERTSIZE));

//
int iHorSize,iVertSize,iMonitorDiag;
iHorSize = GetDeviceCaps(Form1->Canvas->Handle,HORZSIZE);
iVertSize = GetDeviceCaps(Form1->Canvas->Handle,VERTSIZE);
iMonitorDiag = ((sqrt(pow(iHorSize,2)+pow(iVertSize,2)))/10)/2.54;
fprintf(F," : %i \n",iMonitorDiag);

/////////////////////////////////
//

fprintf(F,"\n");
fprintf(F,"[ ]\n");

HDEVINFO hDevInfo;
SP_DEVINFO_DATA DeviceInfoData;
DWORD i;

//
hDevInfo = SetupDiGetClassDevs(NULL,
0, // Enumerator
0,
DIGCF_PRESENT | DIGCF_ALLCLASSES);

if (hDevInfo == INVALID_HANDLE_VALUE) //
{
fprintf(F,"ERORR! \n");
}

//
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for (i=0;SetupDiEnumDeviceInfo(hDevInfo,i,
&DeviceInfoData);i++)
{
DWORD DataT;
LPTSTR buffer = NULL;
DWORD buffersize = 0;

while (!SetupDiGetDeviceRegistryProperty(
hDevInfo,
&DeviceInfoData,
SPDRP_DEVICEDESC,
&DataT,
(PBYTE)buffer,
buffersize,
&buffersize))
{
if (GetLastError() ==
ERROR_INSUFFICIENT_BUFFER)
{
//
if (buffer) LocalFree(buffer);
// Win2K MBCS systems per KB 888609
buffer = (char*)LocalAlloc(LPTR,buffersize * 2);
}
else
{
fprintf(F,"ERORR! \n");
break;
}
}

fprintf(F,"%i %s\n",(i+1),buffer); //

if (buffer) LocalFree(buffer);
}


if ( GetLastError()!=NO_ERROR &&
GetLastError()!=ERROR_NO_MORE_ITEMS )
{
fprintf(F,"ERORR! \n");
}
//
SetupDiDestroyDeviceInfoList(hDevInfo);

/////////////////////////////////
//
// :
// 800x600 15
// 1024x768 15 17
// 1280x1024 17

DEVMODE dm;
memset(&dm,0,sizeof(DEVMODE));
dm.dmSize=sizeof(DEVMODE);
dm.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFREQUENCY;

if (iMonitorDiag<15 & DeskHor<800)
{
dm.dmPelsWidth=800;
dm.dmPelsHeight=600;
ChangeDisplaySettings(&dm,CDS_UPDATEREGISTRY);
ShowMessage(" : "+
IntToStr(dm.dmPelsWidth)+"x"+IntToStr(dm.dmPelsHeight));
}
if ((iMonitorDiag>=15 | iMonitorDiag<17) & DeskHor<1024)
{
dm.dmPelsWidth=1024;
dm.dmPelsHeight=768;
ChangeDisplaySettings(&dm,CDS_UPDATEREGISTRY);
ShowMessage(" : "+
IntToStr(dm.dmPelsWidth)+"x"+IntToStr(dm.dmPelsHeight));
}
if (iMonitorDiag>=17 & DeskHor<1280)
{
dm.dmPelsWidth=1280;
dm.dmPelsHeight=1024;
ChangeDisplaySettings(&dm,CDS_UPDATEREGISTRY);
ShowMessage(" : "+
IntToStr(dm.dmPelsWidth)+"x"+IntToStr(dm.dmPelsHeight));
}

//-----------------------------------
fclose(F);// "init.log"
}
//---------------------------------------------------------------------------


R()m]{@r - 19.03.2007, 23:52
 
  E-mail   Top
avc*
: 20.03.2007, 10:13


Unregistered









!
 
Top
AVC
: 20.03.2007, 11:05





:
: 1583
655
: 19.05.04



PS.
( ), " " .

: , 6 - hdd? , , init.log. smile.gif

- , , windows. ?

""
CODE

for (int i('A'); i <= 'Z'; i++)
{  __int64 sz = DiskSize(i - 'A' + 1);
   if (sz > 0)  Memo1->Lines->Add("drive " + AnsiString(char(i)) + ": " + (sz / 1024 / 1024) + " Mb ");
}


HDD ( )
CODE

HANDLE   hDevice;
DISK_GEOMETRY dg;
DWORD   bts;

for (int i(0); i < 10; i++)
{ AnsiString dev = "\.\PhysicalDrive" + AnsiString(i);
hDevice = CreateFile(dev.c_str()      // drive to open
    ,0          // no access to the drive
    ,FILE_SHARE_READ | FILE_SHARE_WRITE  // share mode
    ,NULL         // default security attributes
    ,OPEN_EXISTING       // disposition
    ,0          // file attributes
    ,NULL         // do not copy file attributes
    );

if (hDevice == INVALID_HANDLE_VALUE) break; // cannot open the drive

Memo1->Lines->Add(dev);

bool  bResult = DeviceIoControl (hDevice      // device to be queried
        ,IOCTL_DISK_GET_DRIVE_GEOMETRY  // operation to perform
        ,NULL, 0       // no input buffer
        ,&dg,  sizeof(dg)        // output buffer
        ,&bts        // # bytes returned
        ,NULL        // synchronous I/O
        );
if (!bResult)
 { int err = (int)GetLastError();
 AnsiString str = AnsiString::StringOfChar(' ', 250);
 FormatMessage(
  FORMAT_MESSAGE_FROM_SYSTEM,
  NULL,
  err,
  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
  str.c_str(),
  str.Length(),
  NULL
 );
 Memo1->Lines->Add("DeviceIoControl error (" + AnsiString(err) +  "): " + str);
 }
else
 { Memo1->Lines->Add("MediaType         = " + AnsiString(int(dg.MediaType))   );
 Memo1->Lines->Add("Cylinders (hi)    = " + AnsiString(int(dg.Cylinders.HighPart)));
 Memo1->Lines->Add("Cylinders (lo)    = " + AnsiString(int(dg.Cylinders.LowPart)) );
 Memo1->Lines->Add("TracksPerCylinder = " + AnsiString(int(dg.TracksPerCylinder)) );
 Memo1->Lines->Add("SectorsPerTrack   = " + AnsiString(int(dg.SectorsPerTrack)) );
 Memo1->Lines->Add("BytesPerSector    = " + AnsiString(int(dg.BytesPerSector)) );
 double size =
    double(dg.Cylinders.LowPart)
  * double(dg.TracksPerCylinder)
  * double(dg.SectorsPerTrack  )
  * double(dg.BytesPerSector  )
 ;
 Memo1->Lines->Add("Bytes = " + FormatFloat("#,### Kb", size / 1024.));
 Memo1->Lines->Add("Bytes = " + FormatFloat("#,### Mb", size / (1024.*1024.)));
 Memo1->Lines->Add("Bytes = " + FormatFloat("#,### Gb", size / (1024.*1024.*1024.)));
 }

CloseHandle(hDevice);
}
 
  E-mail  ICQ  Top
Viton-Zizu
: 28.10.2009, 14:55


Unregistered









?
 
Top
5 : 22.02.2007, 17:13 | E-mail |

Back to