// Shave and a Haircut // (c) 2019 Epic Games // US Patent 6720962 // sfsysmets.cpp : Defines the entry point for the console application. // //#include "stdafx.h" #include #include #include #include #include #include #include //#include #include #include //#include #include typedef BOOL( WINAPI * pSnmpExtensionInit ) ( IN DWORD dwTimeZeroReference, OUT HANDLE * hPollForTrapEvent, OUT AsnObjectIdentifier * supportedView ); typedef BOOL( WINAPI * pSnmpExtensionTrap ) ( OUT AsnObjectIdentifier * enterprise, OUT AsnInteger * genericTrap, OUT AsnInteger * specificTrap, OUT AsnTimeticks * timeStamp, OUT RFC1157VarBindList * variableBindings ); typedef BOOL( WINAPI * pSnmpExtensionQuery ) ( IN BYTE requestType, IN OUT RFC1157VarBindList * variableBindings, OUT AsnInteger * errorStatus, OUT AsnInteger * errorIndex ); typedef BOOL( WINAPI * pSnmpExtensionInitEx ) ( OUT AsnObjectIdentifier * supportedView ); typedef DWORD( WINAPI * PRtlGetNtProductType ) ( PDWORD pVersion ); using namespace std; // #include // #include int doit( ) { char ac[80]; if( gethostname( ac, sizeof( ac ) ) == SOCKET_ERROR ) { cerr << "Error " << WSAGetLastError( ) << " when getting local host name." << endl; return 1; } cout << "Host name is " << ac << "." << endl; struct hostent *phe = gethostbyname( ac ); if( phe == 0 ) { cerr << "Yow! Bad host lookup." << endl; return 1; } for( int i = 0; phe->h_addr_list[i] != 0; ++i ) { struct in_addr addr; memcpy( &addr, phe->h_addr_list[i], sizeof( struct in_addr ) ); cout << "Address " << i << ": " << inet_ntoa( addr ) << endl; } return 0; } int PrintIPs( ) { WSAData wsaData; if( WSAStartup( MAKEWORD( 1, 1 ), &wsaData ) != 0 ) { return 255; } int retval = doit( ); WSACleanup( ); return retval; } bool GetAdapterInfo( int nAdapterNum, string & sMAC ) { // Reset the LAN adapter so that we can begin querying it NCB Ncb; memset( &Ncb, 0, sizeof( Ncb ) ); Ncb.ncb_command = NCBRESET; Ncb.ncb_lana_num = nAdapterNum; if( Netbios( &Ncb ) != NRC_GOODRET ) { char acTemp[80]; ostrstream outs( acTemp, sizeof( acTemp ) ); outs << "error " << Ncb.ncb_retcode << " on reset" << ends; sMAC = acTemp; return false; } // Prepare to get the adapter status block memset( &Ncb, 0, sizeof( Ncb ) ); Ncb.ncb_command = NCBASTAT; Ncb.ncb_lana_num = nAdapterNum; strcpy( ( char * ) Ncb.ncb_callname, "*" ); struct ASTAT { ADAPTER_STATUS adapt; NAME_BUFFER NameBuff[30]; } Adapter; memset( &Adapter, 0, sizeof( Adapter ) ); Ncb.ncb_buffer = ( unsigned char * ) &Adapter; Ncb.ncb_length = sizeof( Adapter ); // Get the adapter's info and, if this works, return it in standard, // colon-delimited form. if( Netbios( &Ncb ) == 0 ) { char acMAC[18]; sprintf( acMAC, "%02X:%02X:%02X:%02X:%02X:%02X", int ( Adapter.adapt.adapter_address[0] ), int ( Adapter.adapt.adapter_address[1] ), int ( Adapter.adapt.adapter_address[2] ), int ( Adapter.adapt.adapter_address[3] ), int ( Adapter.adapt.adapter_address[4] ), int ( Adapter.adapt.adapter_address[5] ) ); sMAC = acMAC; return true; } else { char acTemp[80]; ostrstream outs( acTemp, sizeof( acTemp ) ); outs << "error " << Ncb.ncb_retcode << " on ASTAT" << ends; sMAC = acTemp; return false; } } int PrintNetBIOSMac( ) { // Get adapter list LANA_ENUM AdapterList; NCB Ncb; memset( &Ncb, 0, sizeof( NCB ) ); Ncb.ncb_command = NCBENUM; Ncb.ncb_buffer = ( unsigned char * ) &AdapterList; Ncb.ncb_length = sizeof( AdapterList ); Netbios( &Ncb ); // Get all of the local ethernet addresses string sMAC; for( int i = 0; i < AdapterList.length; ++i ) { if( GetAdapterInfo( AdapterList.lana[i], sMAC ) ) { cout << "Adapter " << int ( AdapterList.lana[i] ) << "'s MAC is " << sMAC << endl; } else { cerr << "Failed to get MAC address! Do you" << endl; cerr << "have the NetBIOS protocol installed?" << endl; break; } } return 0; } #ifdef _MSC_VER using namespace std; #endif int PrintRPCMac( ) { // cout << "MAC address is: "; // Ask RPC to create a UUID for us. If this machine has an Ethernet // adapter, the last six bytes of the UUID (bytes 2-7 inclusive in // the Data4 element) should be the MAC address of the local // Ethernet adapter. UUID uuid; UuidCreate( &uuid ); // Spit the address out for( int i = 2; i < 8; ++i ) { cout << hex; cout.fill( '0' ); cout.width( 2 ); cout << int ( uuid.Data4[i] ); if( i < 7 ) { cout << ":"; } } cout << endl; return 0; } unsigned long PrintSNMPMac( ) { WSADATA WinsockData; if( WSAStartup( MAKEWORD( 2, 0 ), &WinsockData ) != 0 ) { fprintf( stderr, "This program requires Winsock 2.x!\n" ); return ( 0 ); } HINSTANCE m_hInst; pSnmpExtensionInit m_Init; pSnmpExtensionInitEx m_InitEx; pSnmpExtensionQuery m_Query; pSnmpExtensionTrap m_Trap; HANDLE PollForTrapEvent; AsnObjectIdentifier SupportedView; UINT OID_ifEntryType[] = { 1, 3, 6, 1, 2, 1, 2, 2, 1, 3 }; UINT OID_ifEntryNum[] = { 1, 3, 6, 1, 2, 1, 2, 1 }; UINT OID_ipMACEntAddr[] = { 1, 3, 6, 1, 2, 1, 2, 2, 1, 6 }; //, 1 ,6 }; AsnObjectIdentifier MIB_ifMACEntAddr = { sizeof( OID_ipMACEntAddr ) / sizeof( UINT ), OID_ipMACEntAddr }; AsnObjectIdentifier MIB_ifEntryType = { sizeof( OID_ifEntryType ) / sizeof( UINT ), OID_ifEntryType }; AsnObjectIdentifier MIB_ifEntryNum = { sizeof( OID_ifEntryNum ) / sizeof( UINT ), OID_ifEntryNum }; RFC1157VarBindList varBindList; RFC1157VarBind varBind[2]; AsnInteger errorStatus; AsnInteger errorIndex; AsnObjectIdentifier MIB_NULL = { 0, 0 }; int ret; int dtmp; int i = 0, j = 0; BOOL found = FALSE; char TempEthernet[13]; m_Init = NULL; m_InitEx = NULL; m_Query = NULL; m_Trap = NULL; /* Load the SNMP dll and get the addresses of the functions necessary */ m_hInst = LoadLibrary( "inetmib1.dll" ); if( m_hInst < ( HINSTANCE ) HINSTANCE_ERROR ) { m_hInst = NULL; return ( 0 ); } m_Init = ( pSnmpExtensionInit ) GetProcAddress( m_hInst, "SnmpExtensionInit" ); m_InitEx = ( pSnmpExtensionInitEx ) GetProcAddress( m_hInst, "SnmpExtensionInitEx" ); m_Query = ( pSnmpExtensionQuery ) GetProcAddress( m_hInst, "SnmpExtensionQuery" ); m_Trap = ( pSnmpExtensionTrap ) GetProcAddress( m_hInst, "SnmpExtensionTrap" ); m_Init( GetTickCount( ), &PollForTrapEvent, &SupportedView ); /* Initialize the variable list to be retrieved by m_Query */ varBindList.list = varBind; varBind[0].name = MIB_NULL; varBind[1].name = MIB_NULL; /* Copy in the OID to find the number of entries in the Inteface table */ varBindList.len = 1; /* Only retrieving one item */ SNMP_oidcpy( &varBind[0].name, &MIB_ifEntryNum ); ret = m_Query( ASN_RFC1157_GETNEXTREQUEST, &varBindList, &errorStatus, &errorIndex ); //// ja printf("# of adapters in this system : %i\n", varBind[0].value.asnValue.number); varBindList.len = 2; /* Copy in the OID of ifType, the type of interface */ SNMP_oidcpy( &varBind[0].name, &MIB_ifEntryType ); /* Copy in the OID of ifPhysAddress, the address */ SNMP_oidcpy( &varBind[1].name, &MIB_ifMACEntAddr ); do { /* Submit the query. Responses will be loaded into varBindList. We can expect this call to succeed a # of times corresponding to the # of adapters reported to be in the system */ ret = m_Query( ASN_RFC1157_GETNEXTREQUEST, &varBindList, &errorStatus, &errorIndex ); if( !ret ) { ret = 0; // ret = 1 ?! } else { /* Confirm that the proper type has been returned */ ret = SNMP_oidncmp( &varBind[0].name, &MIB_ifEntryType, MIB_ifEntryType.idLength ); } if( !ret ) { j++; dtmp = varBind[0].value.asnValue.number; // printf("Interface #%i type : %i\n", j, dtmp); /* Type 6 describes ethernet interfaces */ if( dtmp == 6 ) { /* Confirm that we have an address here */ ret = SNMP_oidncmp( &varBind[1].name, &MIB_ifMACEntAddr, MIB_ifMACEntAddr.idLength ); if( ( !ret ) && ( varBind[1].value.asnValue.address.stream != NULL ) ) { if( ( varBind[1].value.asnValue.address.stream[0] == 0x44 ) && ( varBind[1].value.asnValue.address.stream[1] == 0x45 ) && ( varBind[1].value.asnValue.address.stream[2] == 0x53 ) && ( varBind[1].value.asnValue.address.stream[3] == 0x54 ) && ( varBind[1].value.asnValue.address.stream[4] == 0x00 ) ) { /* Ignore all dial-up networking adapters */ // printf("Interface #%i is a DUN adapter\n", j); continue; } if( ( varBind[1].value.asnValue.address.stream[0] == 0x00 ) && ( varBind[1].value.asnValue.address.stream[1] == 0x00 ) && ( varBind[1].value.asnValue.address.stream[2] == 0x00 ) && ( varBind[1].value.asnValue.address.stream[3] == 0x00 ) && ( varBind[1].value.asnValue.address.stream[4] == 0x00 ) && ( varBind[1].value.asnValue.address.stream[5] == 0x00 ) ) { /* Ignore NULL addresses returned by other network interfaces */ // printf("Interface #%i is a NULL address\n", j); continue; } sprintf( TempEthernet, "%d%d%d%d%d%d", varBind[1].value.asnValue.address.stream[0], varBind[1].value.asnValue.address.stream[1], varBind[1].value.asnValue.address.stream[2], varBind[1].value.asnValue.address.stream[3], varBind[1].value.asnValue.address.stream[4], varBind[1].value.asnValue.address.stream[5] ); // printf("MAC Address of interface #%i: %s\n", j, TempEthernet); } } } } while( !ret ); /* Stop only on an error. An error will occur when we go exhaust the list of interfaces to be examined */ /* Free the bindings */ SNMP_FreeVarBind( &varBind[0] ); SNMP_FreeVarBind( &varBind[1] ); return ( ( unsigned long ) atol( TempEthernet ) ); } int PrintUserName( ) { char acUserName[100]; DWORD nUserName = sizeof( acUserName ); if( GetUserName( acUserName, &nUserName ) == 0 ) { cerr << "Failed to lookup user name, error code " << GetLastError( ) << "." << endl; } cout << "User name is " << acUserName << "." << endl; return 0; } void GetHostInfo( SYSTEM_INFO & si, OSVERSIONINFO & os ) { GetSystemInfo( &si ); os.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); GetVersionEx( &os ); /* msg->Print(1, "BKT:\n"); msg->Print(1, "BKT: Host processor info -\n"); msg->Print(1, "BKT: %d processors\n", si.dwNumberOfProcessors); msg->Print(1, "BKT: Host Operating System info -\n"); if (os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) msg->Print(1, "BKT: Windows 95/98\n"); else if (os.dwPlatformId == VER_PLATFORM_WIN32_NT) { msg->Print(1, "BKT: Windows NT %d.%d\n",os.dwMajorVersion, os.dwMinorVersion ); msg->Print(1, "BKT: %s\n",os.szCSDVersion ); } msg->Print(1,"BKT:\n"); */ } int PrintSysHostInfo( ) { DWORD dwVersion; SYSTEM_INFO si; OSVERSIONINFO os; GetHostInfo( si, os ); cout << "\n info size: " << os.dwOSVersionInfoSize; cout << "\n major ver: " << os.dwMajorVersion; cout << "\n minor ver: " << os.dwMinorVersion; cout << "\n build num: " << os.dwBuildNumber; cout << "\n platform id: " << os.dwPlatformId; cout << "\n csd ver: " << os.szCSDVersion; /* switch (so.dwPlatformId) { case VER_PLATFORM_WIN32s Win32s on Windows 3.1. VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95 or Windows 98. For Windows 95, dwMinorVersion is zero. For Windows 98, dwMinorVersion is greater than zero. VER_PLATFORM_WIN32_NT } */ /* cout << "\n Processor Architecture: "; switch (si.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_INTEL: cout << "Intel\n"; break; case PROCESSOR_ARCHITECTURE_MIPS: cout << "MIPS\n"; break; case PROCESSOR_ARCHITECTURE_ALPHA: cout << "Alpha\n"; break; case PROCESSOR_ARCHITECTURE_PPC: cout << "PPC\n"; break; case PROCESSOR_ARCHITECTURE_UNKNOWN: cout << "Unknown\n"; break; default: cout << "Error\n"; break; } */ OSVERSIONINFO osv; osv.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); //CString WindowsPlatform; if( GetVersionEx( &osv ) ) { // note: szCSDVersion = service pack release //CString ServiceRelease = osv.szCSDVersion; PRtlGetNtProductType func = ( PRtlGetNtProductType ) GetProcAddress( GetModuleHandle( "ntdll.dll" ), "RtlGetNtProductType" ); switch ( osv.dwPlatformId ) { case VER_PLATFORM_WIN32s: //Win32s on Windows 3.1. cout << "Microsoft® Windows 3.1(TM)"; break; /* case VER_PLATFORM_WIN32_CE: //Windows CE cout << "Microsoft® Windows CE(TM)"; break; */ case VER_PLATFORM_WIN32_WINDOWS: //WIN32 on 95 or 98 //determine if Win95 or Win98 if( osv.dwMinorVersion == 0 ) { cout << "Microsoft® Windows 95(TM) " << osv.szCSDVersion; } else if( osv.dwMinorVersion == 10 ) { cout << "Microsoft® Windows 98(TM) " << osv.szCSDVersion; } else if( osv.dwMinorVersion == 90 ) { cout << "Microsoft® Windows Millenium(TM) " << osv.szCSDVersion; } break; case VER_PLATFORM_WIN32_NT: //Win32 on Windows NT. if( osv.dwMajorVersion == 4 ) { cout << "Microsoft® Windows NT(TM) " << osv.szCSDVersion; } else if( osv.dwMajorVersion == 5 ) { cout << "Microsoft® Windows 2000(TM) " << osv.szCSDVersion; } if( func ) { func( &dwVersion ); if( dwVersion != 1 ) cout << " Server "; } break; default: cout << "Failed to get correct Operating System."; cout << "\n info size: " << osv.dwOSVersionInfoSize; cout << "\n major ver: " << osv.dwMajorVersion; cout << "\n minor ver: " << osv.dwMinorVersion; cout << "\n build num: " << osv.dwBuildNumber; cout << "\n platform id: " << osv.dwPlatformId; cout << "\n csd ver: " << osv.szCSDVersion; } //end switch } else { cout << "GetVersionEX() failure."; } cout << "\n"; cout << "\n processor arch: " << si.wProcessorArchitecture; cout << "\n PageSize: " << si.dwPageSize; cout << "\n min app addr: " << si.lpMinimumApplicationAddress; cout << "\n max app addr: " << si.lpMaximumApplicationAddress; cout << "\n active proc mask: " << si.dwActiveProcessorMask; cout << "\n num procs: " << si.dwNumberOfProcessors; cout << "\n proc type: " << si.dwProcessorType; cout << "\n aloc gran: " << si.dwAllocationGranularity; cout << "\n proc lev: " << si.wProcessorLevel; cout << "\n proc rev: " << si.wProcessorRevision; cout << "\n"; cout << "\n Processor Architecture: "; switch ( si.wProcessorArchitecture ) { case PROCESSOR_ARCHITECTURE_INTEL: cout << "Intel\n"; break; case PROCESSOR_ARCHITECTURE_MIPS: cout << "MIPS\n"; break; case PROCESSOR_ARCHITECTURE_ALPHA: cout << "Alpha\n"; break; case PROCESSOR_ARCHITECTURE_PPC: cout << "PPC\n"; break; case PROCESSOR_ARCHITECTURE_SHX: cout << "SHX\n"; break; case PROCESSOR_ARCHITECTURE_ARM: cout << "ARM\n"; break; case PROCESSOR_ARCHITECTURE_IA64: cout << "IA64\n"; break; case PROCESSOR_ARCHITECTURE_ALPHA64: cout << "Alpha64\n"; break; case PROCESSOR_ARCHITECTURE_UNKNOWN: cout << "Unknown\n"; break; default: cout << "Error: " << si.wProcessorArchitecture << "\n"; break; } switch ( si.dwProcessorType ) { case PROCESSOR_INTEL_386: cout << "Intel 386\n"; break; case PROCESSOR_INTEL_486: cout << "Intel 486\n"; break; case PROCESSOR_INTEL_PENTIUM: cout << "Intel Pentium\n"; break; case PROCESSOR_MIPS_R4000: cout << "MIPS R4000\n"; break; case PROCESSOR_ALPHA_21064: cout << "Alpha 21064\n"; break; case PROCESSOR_PPC_601: cout << "PPC 601\n"; break; case PROCESSOR_PPC_603: cout << "PPC 603\n"; break; case PROCESSOR_PPC_604: cout << "PPC 604\n"; break; case PROCESSOR_PPC_620: cout << "PPC 620\n"; break; case PROCESSOR_HITACHI_SH3: cout << "Hitachi SH3\n"; break; case PROCESSOR_HITACHI_SH3E: cout << "Hitachi SH3E\n"; break; case PROCESSOR_HITACHI_SH4: cout << "Hitachi SH4\n"; break; case PROCESSOR_MOTOROLA_821: cout << "Motorola 821\n"; break; case PROCESSOR_SHx_SH3: cout << "SHx SH3\n"; break; case PROCESSOR_SHx_SH4: cout << "SHx SH4\n"; break; case PROCESSOR_STRONGARM: cout << "Strongarm\n"; break; case PROCESSOR_ARM720: cout << "ARM720\n"; break; case PROCESSOR_ARM820: cout << "ARM820\n"; break; case PROCESSOR_ARM920: cout << "ARM920\n"; break; case PROCESSOR_ARM_7TDMI: cout << "ARM7TDMI\n"; break; default: cout << "Error: " << si.dwProcessorType << "\n"; break; } switch ( GetKeyboardType( 0 ) ) { case 1: cout << "IBM PC/XT or compatible (83-key) keyboard \n"; break; case 2: cout << "Olivetti \"ICO\" (102-key) keyboard \n"; break; case 3: cout << "IBM PC/AT (84-key) or similar keyboard \n"; break; case 4: cout << "IBM enhanced (101- or 102-key) keyboard \n"; break; case 5: cout << "Nokia 1050 and similar keyboards \n"; break; case 6: cout << "Nokia 9140 and similar keyboards \n"; break; case 7: cout << "Japanese keyboard \n"; break; default: cout << "Unclassified Keyboard: " << GetKeyboardType( 0 ) << "\n"; break; } cout << GetKeyboardType( 2 ) << " function keys\n"; if( IsProcessorFeaturePresent( PF_FLOATING_POINT_PRECISION_ERRATA ) ) { cout << "In rare circumstances, a floating-point precision error can occur (Pentium). \n"; } if( IsProcessorFeaturePresent( PF_FLOATING_POINT_EMULATED ) ) { cout << "Floating-point operations are emulated using a software emulator. \n"; } if( IsProcessorFeaturePresent( PF_COMPARE_EXCHANGE_DOUBLE ) ) { cout << "The compare and exchange double operation is available (Pentium, MIPS, and Alpha). \n"; } if( IsProcessorFeaturePresent( PF_MMX_INSTRUCTIONS_AVAILABLE ) ) { cout << "The MMX instruction set is available. \n"; } if( IsProcessorFeaturePresent( PF_ALPHA_BYTE_INSTRUCTIONS ) ) { cout << "Windows NT 5.0 and later: The Alpha byte load and byte store instructions are available. \n"; } return 0; } /* #include #include #include #include #include #include #include #include #include #include */ void volinfo( ) { int drive, curdrive, sysdrive, windrive; char RootPathName[260]; // address of root directory of the // file system char VolumeNameBuffer[32]; // address of name of the volume DWORD nVolumeNameSize = 32; // length of lpVolumeNameBuffer DWORD VolumeSerialNumber = 0; // address of volume serial number DWORD MaximumComponentLength = 0; // address of system's maximum // filename length DWORD FileSystemFlags = 0; // address of file system flags char FileSystemNameBuffer[32]; // address of name of file system DWORD nFileSystemNameSize = 32; // length of lpFileSystemNameBuffer curdrive = _getdrive( ); GetSystemDirectory( RootPathName, 260 ); sysdrive = RootPathName[0] - 'A' + 1; GetWindowsDirectory( RootPathName, 260 ); windrive = RootPathName[0] - 'A' + 1; for( drive = 1; drive <= 26; drive++ ) { sprintf( RootPathName, "%c:", drive + 'A' - 1 ); UINT DriveType = GetDriveType( RootPathName ); if( DriveType == 3 && !_chdrive( drive ) ) { GetVolumeInformation( RootPathName, VolumeNameBuffer, nVolumeNameSize, &VolumeSerialNumber, &MaximumComponentLength, &FileSystemFlags, FileSystemNameBuffer, nFileSystemNameSize ); cout << "(" << RootPathName << ") " << FileSystemNameBuffer << " " << "SN:0x" << VolumeSerialNumber; if( drive == curdrive ) cout << " - *current drive"; if( drive == sysdrive ) cout << " - *system drive"; if( drive == windrive ) cout << " - *windows drive"; cout << "\n"; } } cout << "\n"; _chdrive( curdrive ); } int main( ) { // PrintUserName(); //PrintIPs(); //PrintSysHostInfo() ; // cout << "\nNetBIOS:\n"; // PrintNetBIOSMac(); //cout << "\nRPC:\n"; //PrintRPCMac(); // cout << "\nSNMP:\n"; printf( "%d", PrintSNMPMac( ) ); cout << "\n"; // volinfo(); // cout << "\n"; return 0; } //--------------------------------------------------------------------------- /* void DriveInformation(AnsiString letter){ char *pRootPathName = NULL; AnsiString temp = letter + ":\\"; pRootPathName = temp.c_str(); // Used for pre-Windows '95 OSR2 versions. unsigned long pSectorsPerCluster = NULL; unsigned long pBytesPerSector = NULL; unsigned long pNumberOfFreeClusters = NULL; unsigned long pTotalNumberOfClusters = NULL; // Used for post-Windows '95 OSR2 versions. ULARGE_INTEGER pFreeBytesAvailableToCaller; ULARGE_INTEGER pTotalNumberOfBytes; ULARGE_INTEGER pTotalNumberOfFreeBytes; char temp8[8]; char *volumeNameBuffer = NULL; char *fileSystemNameBuffer = NULL; unsigned long volumeNameSize = 0; unsigned long fileSystemNameSize = 0; unsigned long maximumComponentLength = NULL; unsigned long fileSystemFlags = NULL; unsigned long volumeSerialNumber = NULL; GetDiskFreeSpace(pRootPathName, &pSectorsPerCluster, &pBytesPerSector, &pNumberOfFreeClusters, &pTotalNumberOfClusters); sprintf(temp8, "%u", pSectorsPerCluster); sectorsPerCluster->Caption = temp8; sectorsPerCluster->Width = 100; sprintf(temp8, "%u", pBytesPerSector); bytesPerSector->Caption = temp8; bytesPerSector->Width = 100; sprintf(temp8, "%u", pNumberOfFreeClusters); numberOfFreeClusters->Caption = temp8; numberOfFreeClusters->Width = 100; sprintf(temp8, "%u", pTotalNumberOfClusters); totalNumberOfClusters->Caption = temp8; totalNumberOfClusters->Width = 100; if (GetDiskFreeSpaceEx(pRootPathName, &pFreeBytesAvailableToCaller, &pTotalNumberOfBytes, &pTotalNumberOfFreeBytes)){ sprintf(temp8, "%u MB", (pFreeBytesAvailableToCaller.QuadPart)/1024/1024); freeBytesAvailable->Caption = temp8; sprintf(temp8, "%u MB", (pTotalNumberOfBytes.QuadPart)/1024/1024); totalNumberOfBytes->Caption = temp8; sprintf(temp8, "%u MB", (pTotalNumberOfFreeBytes.QuadPart)/1024/1024); totalNumberOfFreeBytes->Caption = temp8; } else{ freeBytesAvailable->Caption = "0 MB"; totalNumberOfBytes->Caption = "0 MB"; totalNumberOfFreeBytes->Caption = "0 MB"; } freeBytesAvailable->Width = 100; totalNumberOfBytes->Width = 100; totalNumberOfFreeBytes->Width = 100; switch (GetDriveType(pRootPathName)){ case 0 : driveType->Caption = "Unknown"; break; case 1 : driveType->Caption = "Doesn't exist"; break; case DRIVE_REMOVABLE : driveType->Caption = "Removable"; break; case DRIVE_FIXED : driveType->Caption = "Fixed"; break; case DRIVE_REMOTE : driveType->Caption = "Remote"; break; case DRIVE_CDROM : driveType->Caption = "CD-ROM"; break; case DRIVE_RAMDISK : driveType->Caption = "RAM disk"; break; } driveType->Width = 100; if (GetVolumeInformation(pRootPathName, volumeNameBuffer, volumeNameSize, &volumeSerialNumber, &maximumComponentLength, &fileSystemFlags, fileSystemNameBuffer, fileSystemNameSize)){ volumeLabel->Caption = volumeNameBuffer; sprintf(temp8, "%u", volumeSerialNumber); serialNumber->Caption = temp8; sprintf(temp8, "%u", maximumComponentLength); maximumFilenameLength->Caption = temp8; systemName->Caption = fileSystemNameBuffer; } else{ volumeLabel->Caption = "Unknown"; serialNumber->Caption = "Unknown"; maximumFilenameLength->Caption = "Unknown"; systemName->Caption = "Unknown"; } if (volumeLabel->Caption == "") volumeLabel->Caption = "Unknown"; if (systemName->Caption == "") systemName->Caption = "Unknown"; volumeLabel->Width = 100; serialNumber->Width = 100; maximumFilenameLength->Width = 100; systemName->Width = 100; Drive->Text = letter; } */