Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A thinking experiment, How can you tell
#1
Back in the early days ram was expensive, storage space much more so and CPU power the race was on.  Nowadays ungodly amount of ram is cheap, couple of buck per terabyte storage space and CPU's are now limited by Moore's law, must expand width wise (cores).  Why the history lesson ?

Operating systems are still written not caring about any of that stuff.  It's give me more, more, more.  Today I can identify how much ram is available, how much storage space there is and all kinds of info about the CPU.  So what is there to think about ???

So how can you tell what the storage medium is ?  Is it networked, HDD, SSD, Ramdrive and dare I say cough, cough Floppy ?  I have all kinds of programs written to create scripts running in dos CMD terminals.  Performance wise I go nuts with multiple task terminals when I know it's executing inside a Ramdrive.  Because I know it will be limited by the CPU quality performance and a small factor ram speed.  If I can tell the media type, I won't go nuts on something other than a Ramdrive.  Just thinking about 12 terminals executing on a floppy, give me shivers.

Your thoughts or solution ?
Reply
#2
Maybe shelling this out using Powershell and then parsing the results?

https://stackoverflow.com/questions/6718...powershell

Search "MediaType" in that post.

Pete
Shoot first and shoot people who ask questions, later.
Reply
#3
(03-30-2025, 01:39 PM)Pete Wrote: Maybe shelling this out using Powershell and then parsing the results?

https://stackoverflow.com/questions/6718...powershell

Search "MediaType" in that post.

Pete

That could work.  At least now I won't make the mistake of flooding a bad media type with lot's of parallel scripts.
I expected the answer would be some kind of shell event.  I will experiment with it.  Hopefully a Ramdrive won't be ID'ed as a HDD.
Reply
#4
Maybe this helps?
DriveType is one of the fields

(There might be unrelevant pieces in here; cut out from larger program)
Code: (Select All)
$Console:Only

Declare Library
  Function GetDriveTypeA& (nDrive As String)
  Function GetLogicalDriveStringsA (ByVal nBuff As Long, lpbuff As String)
End Declare
Declare Dynamic Library "Kernel32"
  Function GetVolumeInformationA (Drive As String, Label As String, ByVal nVol As Long, ByVal Serial As _Offset, ByVal Max As _Offset, ByVal Flags As _Offset, Sys As String, ByVal nSys As Long)
  'Function GetDiskFreeSpaceA (nDrive As String, Byval csectors As _Offset, Byval sbytes As _Offset, Byval cfree As _Offset, Byval ctotal As _Offset)
  Function GetDiskFreeSpaceExA& (ByVal lpDirectoryName As _Offset, ByVal lpFreeBytesAvailableToCaller As _Offset, ByVal lpTotalNumberOfBytes As _Offset, ByVal lpTotalNumberOfFreeBytes As _Offset)
End Declare

Type LogicalDiskType
  Letter As String
  DriveType As _Byte
  VolumeName As String
  FileSystem As String
  Serial As String
End Type
Dim Shared LogicalDisk(1000) As LogicalDiskType

Dim As Integer i, LDs
LDs = getDiskInfo
For i = 1 To LDs
  Print Using "## \\"; i; LogicalDisk(i).Letter;
  Print Using "(#) \          \"; LogicalDisk(i).DriveType; LogicalDisk(i).VolumeName;
  Print Using "\      \\      \"; LogicalDisk(i).FileSystem; LogicalDisk(i).Serial
Next i

Function getDiskInfo%
  Dim DList As String, Drive As String, ret As Long, DriveType As Long
  Dim Label As String, Serial As Long, nMax As Long, nFlags As Long, Sys As String
  Dim LDs As Integer
  ret = GetLogicalDriveStringsA(0, DList): If ret = 0 Then Exit Function
  DList = Space$(ret): ret = GetLogicalDriveStringsA(ret, DList): If ret = 0 Then Exit Function
  For n% = 65 To 90
    If InStr(DList, Chr$(n%)) Then
      Drive = Chr$(n%) + ":\" + Chr$(0): DriveType = GetDriveTypeA(Drive)
      Label = Space$(20): Sys = Space$(20)
      ret = GetVolumeInformationA(Drive, Label, Len(Label), _Offset(Serial), _Offset(nMax), _Offset(nFlags), Sys, Len(Sys))
      LDs = LDs + 1 'new one
      LogicalDisk(LDs).VolumeName = Left$(Label, _InStrRev(Label, Chr$(0)) - 1)
      LogicalDisk(LDs).Serial = Hex$(Serial)
      LogicalDisk(LDs).Letter = Left$(Drive, 2)
      LogicalDisk(LDs).DriveType = DriveType '0=unknown,1=NoRoot,2=Removable,3=Local,4=Network,5=CD,6=Ramdisk
      LogicalDisk(LDs).FileSystem = Left$(Sys, _InStrRev(Sys, Chr$(0)) - 1)
    End If
  Next n%
  getDiskInfo% = LDs
End Function
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply
#5
+1 for an API solution. I haven't messed with those for a year or two.

Pete
Reply
#6
I would have thought Squiggy would post an API and be first one.  What a let down, squiggy must be on vacation.

What I thought would happen, my Ramdrive is listed as local drive type 3.  Even the external hdd is listed as local.
Reply
#7
Or maybe it's because you refer to Spriggsy as "squiggy" who I think played aside of Lenny in an old TV sitcom called Laverne and Shirley, although I don't think he'd reply if referred to as The Fonz or The Big Ragu, either.

He does have some pretty great routines though. I love his recycle bin API.

Pete
Reply




Users browsing this thread: 3 Guest(s)