Finding information about a user's hardware

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

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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