Finding information about a user's hardware

BlitzPlus Forums/BlitzPlus Beginners Area/Finding information about a user's hardware

I recently downloaded a program called Everest (the free edition). It is as a one stop shop for all information about the PC (maker of the CD drive, speed of the processor, amount of RAM, etc.) in order to obtain new drivers or other miscellaneous maintenance jobs. The idea intrigued me. I want to create a program much like Everest, but which outputs the reports in a more readable format, not to mention, perhaps, downloading the drivers for the user. My question is how would i go about obtaining information such as processor speed or the maker of the HDD? Is there a Blitz userlib for getting these useful tidbits? Any answer to the first question would be appreciated, but i would just about crap myself with joy if someone could give me an answer for the second one other than "no".

You'll have to write your own lib, here's a start:-

DriveInfo DLL C++ Source (Built with VC++7)
#include <iostream.h>
#include <windows.h>
#include <stdlib.h>

#define BBDECL extern "C" _declspec(dllexport)
#define BBCALL _stdcall

//DriveInfo Definitions
#define FILESYSNAMEBUFSIZE		1024 
#define VOLUMENAMEBUFSIZE		1024
#define INFO_TYPE_VOLUME_NAME	0
#define INFO_TYPE_SYSTEM_NAME	1
#define INFO_TYPE_SERIEL		2

/*DriveInfo returns one of three 
drive properties(Example is in Blitz+):-

	DriveInfo$(root$,0) returns the volume name
	DriveInfo$(root$,1) returns the file system name (e.g. FAT32/NTFS)
	Hex$(DriveInfo$(root$,2)) returns the drive seriel number
*/
BBDECL char * BBCALL DriveInfo( const char * Buf, int infoType)
{
DWORD dwSysFlags; 
	char FileSysNameBuf[FILESYSNAMEBUFSIZE];
	char VolumeNameBuf[FILESYSNAMEBUFSIZE];
	DWORD serial;
	char strSeriel[255];

	GetVolumeInformation( Buf, VolumeNameBuf, VOLUMENAMEBUFSIZE, &serial, NULL,
                        &dwSysFlags, FileSysNameBuf, 
                        FILESYSNAMEBUFSIZE);
	if (infoType == INFO_TYPE_VOLUME_NAME)
	{
		return(VolumeNameBuf);
	}

	if (infoType == INFO_TYPE_SYSTEM_NAME)
	{
		return(FileSysNameBuf);
	}

	if (infoType == INFO_TYPE_SERIEL)
	{
		_itoa(serial,strSeriel,10);
		return(strSeriel);
	}
	return("Unknown");
}

/* Declaration file contents

.lib "lib.dll"
DriveInfo$(rootPath$,type%):"_DriveInfo@8"
*/


You could also check how many drives is on the system, and what type they are using these:-

;GetDriveType return codes
;Removable/fixed and CDROM are implemented in this file, if you
;need anything else, build new functions with these codes
Const DRIVE_UNKNOWN     = 0
Const DRIVE_NO_ROOT_DIR = 1
Const DRIVE_REMOVABLE   = 2
Const DRIVE_FIXED       = 3
Const DRIVE_REMOTE      = 4
Const DRIVE_CDROM       = 5
Const DRIVE_RAMDISK     = 6

Function IsDriveRemovable(rootPath$)
	If GetDriveType(rootPath$) = DRIVE_REMOVABLE
		Return(True)
	Else
		Return(False)
	End If
End Function

Function IsDriveFixed(rootPath$)
	If GetDriveType(rootPath$) = DRIVE_FIXED
		Return(True)
	Else
		Return(False)
	End If
End Function

Function IsDriveCDROM(rootPath$)
	If GetDriveType(rootPath$) = DRIVE_CDROM
		Return(True)
	Else
		Return(False)
	End If
End Function


;------ This function may take some explaining ------
Function GetDrives$(logicalSeperatorChar$)
	LogicalDrivesOnSystemBank = CreateBank(254)
	SizeOfLogicalDrivesBuffer = GetDriveStr(255,LogicalDrivesOnSystemBank)
	For n = 0 To SizeOfLogicalDrivesBuffer-1
		char = PeekByte(LogicalDrivesOnSystemBank,n)
		If char = 0
			char = Asc(logicalSeperatorChar$)
		End If
		allLogicalDrivesOnSystem$ = allLogicalDrivesOnSystem$ + Chr$(char)
	Next
	Return allLogicalDrivesOnSystem$
End Function

;The [logicalSeperatorChar$] parameter is a character that
;seperates each drive in the returned string, for example, if you
;call the GetDrives$ function like this:-
;
;		drives$ = GetDrives$("|")
;
;The returned string may look a little like this:-
;
;		"A:\|C:\|D:\|E:\|F:\|H:\|I:\|"
;
;So you can then use your defined character (which is '|') to chop
;the string up into different drives, sort of like this:-

;[example code]
;		Include "C:\BPinc\Windows.bbh" ;File that contains the GetDrives$ function
;
;		Const DRIVES_MAX = 99
;
;		Dim AvailableDrives$(DRIVES_MAX)
;
;		drives$ = GetDrives("|")
;
;		For loop = 0 To Len(drives$)
;			char$ = Mid$(drives$,loop,1)
;			If char$ <> "|"
;				tempDrive$ = tempDrive$ + char$
;			Else
;				AvailableDrives$(driveCount) = tempDrive$
;				driveCount = driveCount + 1
;				tempDrive$ = ""
;			End If
;		Next
;
;		For n = 0 To driveCount-1
;			Print AvailableDrives$(n)
;		Next

;		WaitKey
;
;
;
; DECLS FILE CONTENTS
;.lib "Kernel32.dll"
;GetDriveStr%(bufferLen%,buffer*):"GetLogicalDriveStringsA"
;GetDriveType%(rootPath$):"GetDriveTypeA"


There is a load more in WinAPI, not sure about drivers... I've never played with them yet! :)

Anyway, I hope this helps

Dabz

thanks, but i don't happen to have ANY C++ knowledge yet, Blitz has been more than sufficient for everything up until now... I know that i should learn it, just to have it there but its quite a bit of work to learn a new language (especially one not based in basic). Thanks for the info but unless someone will write it for me, i don't think im gonna get the lib.

Just play with C++ a little now and then, nothing fancy, and you will start to understand it, I mean, if you can make an application/game in BASIC, you've already got the skill's for C++ because you can think logically, and some of C++'s core principles are pretty much the same as Blitz's anyway, just a little syntaxidly (If that's a word?) different!

Making a userlib for what you want to achieve is the perfect excuse to begin learning it!

Dabz

ok, so say that i want to start learning C++, how much is it gonna cost for Compiler/IDE? I'm not a proffesional programmer (obviously) so I don't really feel like shelling out 2-3 hundred for ANOTHER programming language when I can already do almost everything I want in the blitz basic environment...

DEV-C++ is a free C++ IDE:

http://www.bloodshed.net/devcpp.html

It's actually pretty good, and is perfect for the beginner... That's where I started! :)

Or you could download Visual C++ 2005 Express Edition, which is like a downgraded version (But still powerful) of Visual C++ 2005 .NET, and it's free at the moment.

Your most likely to find it at MS.COM

Dabz