home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 8.ddi / SYSINFO.ZIP / SYSINFO.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  4.5 KB  |  152 lines

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #include <owl.h>
  4. #include <dialog.h>
  5. #include <static.h>
  6.  
  7. #include <dos.h>
  8. #include <string.h>
  9.  
  10. #include "sysinfo.h"
  11.  
  12. class TSysInfoApp : public TApplication
  13. {
  14. public:
  15.     TSysInfoApp( LPSTR name, HINSTANCE hInstance,
  16.           HINSTANCE hPrevInstance, LPSTR lpCmd,
  17.           int nCmdShow)
  18.             : TApplication(name, hInstance,
  19.                    hPrevInstance, lpCmd, nCmdShow) {};
  20.     virtual void InitMainWindow( void );
  21. };
  22.  
  23. struct SysInfoRecord
  24. {
  25.     char InstanceNumber[ 31 ];
  26.     char WindowsVersion[ 31 ];
  27.     char OperationMode[ 31 ];
  28.     char CPUType[ 31 ];
  29.     char CoProcessor[ 31 ];
  30.     char Global[ 31 ];
  31.     char VersionDos[ 31 ];
  32. };
  33.  
  34. class TSysInfoWindow : public TDialog
  35. {
  36.     SysInfoRecord TransferRecord;
  37. public:
  38.     TSysInfoWindow( PTWindowsObject aParent, LPSTR aTitle );
  39.     void GetSysInformation( void );
  40.     void InitChildren( void );
  41. };
  42.  
  43. typedef TSysInfoWindow* pSysInfoWindow;
  44.  
  45. TSysInfoWindow::TSysInfoWindow( PTWindowsObject aParent, LPSTR aTitle ) :
  46.     TDialog( aParent, aTitle )
  47. {
  48.     InitChildren();
  49.     GetSysInformation();
  50. }
  51.  
  52. void TSysInfoWindow::InitChildren( void )
  53. {
  54.       PTStatic TmpStatic;
  55.  
  56.     TmpStatic = new TStatic( this, ID_INSTANCENUMBER, sizeof( TransferRecord.InstanceNumber ) );
  57.       TmpStatic->EnableTransfer();
  58.  
  59.     TmpStatic = new TStatic( this, ID_WINDOWSVERSION, sizeof( TransferRecord.WindowsVersion ) );
  60.       TmpStatic->EnableTransfer();
  61.  
  62.     TmpStatic = new TStatic( this, ID_OPERATIONMODE, sizeof( TransferRecord.OperationMode ) );
  63.       TmpStatic->EnableTransfer();
  64.  
  65.     TmpStatic = new TStatic( this, ID_CPUTYPE, sizeof( TransferRecord.CPUType ) );
  66.       TmpStatic->EnableTransfer();
  67.  
  68.     TmpStatic = new TStatic( this, ID_COPROCESSOR, sizeof( TransferRecord.CoProcessor ) );
  69.       TmpStatic->EnableTransfer();
  70.  
  71.     TmpStatic = new TStatic( this, ID_GLOBAL, sizeof( TransferRecord.Global ) );
  72.       TmpStatic->EnableTransfer();
  73.  
  74.     TmpStatic = new TStatic( this, ID_VERSIONDOS, sizeof( TransferRecord.VersionDos ) );
  75.       TmpStatic->EnableTransfer();
  76. }
  77.  
  78. void TSysInfoWindow::GetSysInformation( void )
  79. {
  80.     DWORD SysFlags;
  81.     char tempstr[ 31 ];
  82.     WORD ArgList[ 2 ];
  83.     WORD Ver;
  84.     DWORD Available;
  85.     HINSTANCE hInstance = GetApplication()->hInstance;
  86.  
  87.     SysFlags = GetWinFlags();
  88.  
  89.     ArgList[ 0 ] = GetModuleUsage( hInstance );
  90.     wvsprintf( (LPSTR) TransferRecord.InstanceNumber, (LPSTR) "%d", (LPSTR) ArgList );
  91.  
  92.     Ver = GetVersion();
  93.     ArgList[0] = (WORD) LOBYTE(LOWORD( Ver ));
  94.     ArgList[1] = (WORD) HIBYTE(LOWORD( Ver ));
  95.     wvsprintf( (LPSTR) TransferRecord.WindowsVersion, (LPSTR) "%d.%d", (LPSTR) ArgList );
  96.  
  97.     if ( SysFlags & WF_ENHANCED )
  98.         LoadString( hInstance, ID_ENHANCED, tempstr, sizeof( tempstr ) );
  99.     else if ( SysFlags & WF_STANDARD )
  100.         LoadString( hInstance, ID_STANDARD, tempstr, sizeof( tempstr ) );
  101.     else if ( SysFlags & WF_PMODE )
  102.         LoadString( hInstance, ID_REAL, tempstr, sizeof( tempstr ) );
  103.     else
  104.         LoadString( hInstance, ID_UNKNOWN, tempstr, sizeof( tempstr ) );
  105.     strcpy( TransferRecord.OperationMode, tempstr );
  106.  
  107.     if ( SysFlags & WF_CPU086 )
  108.         LoadString( hInstance, ID_CPU8086, tempstr, sizeof( tempstr ) );
  109.     else if ( SysFlags & WF_CPU186 )
  110.         LoadString( hInstance, ID_CPU80186, tempstr, sizeof( tempstr ) );
  111.     else if ( SysFlags & WF_CPU286 )
  112.         LoadString( hInstance, ID_CPU80286, tempstr, sizeof( tempstr ) );
  113.     else if ( SysFlags & WF_CPU386 )
  114.         LoadString( hInstance, ID_CPU80386, tempstr, sizeof( tempstr ) );
  115.     else if ( SysFlags & WF_CPU486 )
  116.         LoadString( hInstance, ID_CPU80486, tempstr, sizeof( tempstr ) );
  117.     else
  118.         LoadString( hInstance, ID_UNKNOWN, tempstr, sizeof( tempstr ) );
  119.     strcpy( TransferRecord.CPUType, tempstr );
  120.  
  121.     if ( SysFlags & WF_80x87 )
  122.         LoadString( hInstance, ID_YES, tempstr, sizeof( tempstr ) );
  123.     else
  124.         LoadString( hInstance, ID_NO, tempstr, sizeof( tempstr ) );
  125.     strcpy( TransferRecord.CoProcessor, tempstr );
  126.  
  127.     Available = GetFreeSpace( 0 ) / 1024;
  128.     ArgList[0] = LOWORD( Available );
  129.     ArgList[1] = HIWORD( Available );
  130.     wvsprintf( (LPSTR) TransferRecord.Global, (LPSTR) "%lu", (LPSTR) ArgList );
  131.  
  132.     ArgList[0] = _osmajor;
  133.     ArgList[1] = _osminor;
  134.     wvsprintf( (LPSTR) TransferRecord.VersionDos, (LPSTR) "%d.%d", (LPSTR) ArgList );
  135.  
  136.     TransferBuffer = (LPSTR) &TransferRecord;
  137. }
  138.  
  139. void TSysInfoApp::InitMainWindow( void )
  140. {
  141.     MainWindow = new TSysInfoWindow( NULL, (LPSTR) "SysInfo" );
  142. }
  143.  
  144. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  145.            LPSTR lpCmd, int nCmdShow)
  146. {
  147.     TSysInfoApp SysInfoApp( "SysInfo", hInstance, hPrevInstance,
  148.         lpCmd, nCmdShow);
  149.     SysInfoApp.Run();
  150.     return ( SysInfoApp.Status );
  151. }
  152.