1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
|
// 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 <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <strstream>
#include <string>
#include <rpc.h>
//#include <iostream>
#include <snmp.h>
#include <conio.h>
//#include <stdio.h>
#include <direct.h>
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 <iostream.h>
// #include <winsock.h>
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 <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <fcntl.h>
#include <nwshare.h>
#include <nwdir.h>
#include <nwbitops.h>
#include <nwtts.h>
#include <nwbindry.h>
#include <time.h>
*/
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;
}
*/
|