How do I discern between a 1.44 MB and a 720k floppy?

schtoom
schtoom used Ask the Experts™
on
I haven't the slightest idea how to start this.  Theory is fine, but sample code would be the best.  Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
BTW, this is a 16-bit problem.  Thanks!

Commented:
Borland C++ Builder Example:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  INT64 lpFreeBytesAvailableToCaller;
  INT64 lpTotalNumberOfBytes;
  INT64 lpTotalNumberOfFreeBytes;


  Sysutils::GetDiskFreeSpaceEx("A:\\",lpFreeBytesAvailableToCaller,lpTotalNumberOfBytes,&lpTotalNumberOfFreeBytes);

  ShowMessage("toal disk size="+IntToStr(lpTotalNumberOfBytes));




Good  luck!!

Commented:
Opps! I missed the post stating that this was 16 bit....
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Author

Commented:
Well, thanks for the effort at least :)
Anyone else?
Commented:
Got this from the M$ knowledgebase, I think it just might help...



   /*
      Determines the amount of free space available for the caller.
      Runs on Windows 95 retail and later, and on Windows 4.0 and later.  
      Uses GetDiskFreeSpaceEx if available, otherwise reverts to
      GetDiskFreeSpace.

      To determine the amount of available space correctly:

       * Use 64-bit math with the return values of both GetDiskFreeSpace
         and GetDiskFreeSpaceEx so that you can determine the sizes of
         volumes that are larger than 2GB.

      Programs that need to determine how much free space the current user
      can have (such as whether there is enough space to complete an
      installation) have an additional requirement:

       * Use the lpFreeBytesAvailableToCaller value from
         GetDiskFreeSpaceEx rather than lpTotalNumberOfFreeBytes.  
         This is because Windows 2000 has disk quota management that
         administrators may use to limit the amount of disk space that
         users may use.
   */


   #include <windows.h>
   #include <stdio.h>


   typedef BOOL (WINAPI *P_GDFSE)(LPCTSTR, PULARGE_INTEGER,
                                  PULARGE_INTEGER, PULARGE_INTEGER);

   void main (int argc, char **argv)
   {
      BOOL  fResult;

      char  *pszDrive  = NULL,
             szDrive[4];

      DWORD dwSectPerClust,
            dwBytesPerSect,
            dwFreeClusters,
            dwTotalClusters;

      P_GDFSE pGetDiskFreeSpaceEx = NULL;

      unsigned __int64 i64FreeBytesToCaller,
                       i64TotalBytes,
                       i64FreeBytes;

      /*
         Command line parsing.

         If the drive is a drive letter and not a UNC path, append a
         trailing backslash to the drive letter and colon.  This is
         required on Windows 95 and 98.
      */
      if (argc != 2)
      {
         printf ("usage:  %s <drive|UNC path>\n", argv[0]);
         printf ("\texample:  %s C:\\\n", argv[0]);
         return;
      }

      pszDrive = argv[1];

      if (pszDrive[1] == ':')
      {
         szDrive[0] = pszDrive[0];
         szDrive[1] = ':';
         szDrive[2] = '\\';
         szDrive[3] = '\0';

         pszDrive = szDrive;
      }

      /*
         Use GetDiskFreeSpaceEx if available; otherwise, use
         GetDiskFreeSpace.

         Note: Since GetDiskFreeSpaceEx is not in Windows 95 Retail, we
         dynamically link to it and only call it if it is present.  We
         don't need to call LoadLibrary on KERNEL32.DLL because it is
         already loaded into every Win32 process's address space.
      */
      pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress (
                               GetModuleHandle ("kernel32.dll"),
                                                "GetDiskFreeSpaceExA");
      if (pGetDiskFreeSpaceEx)
      {
         fResult = pGetDiskFreeSpaceEx (pszDrive,
                                 (PULARGE_INTEGER)&i64FreeBytesToCaller,
                                 (PULARGE_INTEGER)&i64TotalBytes,
                                 (PULARGE_INTEGER)&i64FreeBytes);
         if (fResult)
         {
            printf ("\n\nGetDiskFreeSpaceEx reports\n\n");
            printf ("Available space to caller = %I64u MB\n",
                    i64FreeBytesToCaller / (1024*1024));
            printf ("Total space               = %I64u MB\n",
                    i64TotalBytes / (1024*1024));
            printf ("Free space on drive       = %I64u MB\n",
                    i64FreeBytes / (1024*1024));
         }
      }
      else
      {
         fResult = GetDiskFreeSpace (pszDrive,
                                     &dwSectPerClust,
                                     &dwBytesPerSect,
                                     &dwFreeClusters,
                                     &dwTotalClusters);
         if (fResult)
         {
            /* force 64-bit math */
            i64TotalBytes = (__int64)dwTotalClusters * dwSectPerClust *
                              dwBytesPerSect;
            i64FreeBytes = (__int64)dwFreeClusters * dwSectPerClust *
                              dwBytesPerSect;

            printf ("GetDiskFreeSpace reports\n\n");
            printf ("Free space  = %I64u MB\n",
                    i64FreeBytes / (1024*1024));
            printf ("Total space = %I64u MB\n",
                    i64TotalBytes / (1024*1024));
         }
      }

      if (!fResult)
         printf ("error: %lu:  could not get free space for \"%s\"\n",
                 GetLastError(), argv[1]);
   }



Good luck!!
You can use 0x13 interruption (or biosdisk function : it is same) with AH = 08H: get status of disk
AH return status :
01h    360K
02h    1.2M
03h    720K
04h    1.44M
05h    ??? (reportedly an obscure drive type shipped on some IBM machines).
2.88M on some machines (at least AMI 486 BIOS)
06h    2.88M
10h    ATAPI Removable Media Device

see more details in
http://www.ctyme.com/intr/rb-0621.htm

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial