Commits

overlord  committed be98dc8

A load of crap which could some day become a Windows utility library

  • Participants

Comments (0)

Files changed (24)

+/* This file is used to turn the cursor into a busy (IDC_WAIT) cursor
+for a while, until the next call to be exact.  The function toggles
+the cursor between that and ADC_ARROW. The function IsWindowsCursorBusy()
+returns TRUE if the cursor is in the state IDC_WAIT and FALSE if the cursor
+is any other state. */
+
+#include <Windows.H>
+#pragma hdrstop
+
+#include "WinStuff\BusyCur.H" /* Our header */
+/*-------------------------------------------------------------------------*/
+void ToggleWindowsCursorBusy()
+{
+  if (!IsWindowsCursorBusy()) /* Not bust cursor right now? */
+  {
+    HCURSOR hCursor;
+    hCursor = LoadCursor(NULL, IDC_WAIT);
+    if (hCursor) /* Ensuring this handle is valid to prevent the next function removing the cursor from the screen */
+    {
+      SetCursor(hCursor); /* Set the new busy cursor */
+    }
+  }
+  else /* It already was the busy cursor? */
+  {
+    /* Toggle it back to an arrow then */
+    HCURSOR hCursor;
+    hCursor = LoadCursor(NULL, IDC_ARROW);
+    if (hCursor)
+    {
+      SetCursor(hCursor); /* Set the standard arrow pointer */
+    }
+  }
+}
+/*-------------------------------------------------------------------------*/
+BOOL IsWindowsCursorBusy()
+{
+  /* How do we know whether the current cursor is the system's busy
+  (IDC_WAIT) cursor, well this is quite a tricky one really, so I
+  thought, maybe saving the current cursor's handle, then loading the
+  IDC_WAIT cursor, saving the handle without setting it on the display
+  and the compare the two handles, if they compare the IDC_WAIT
+  cursor is in use */
+
+  if (GetCursor() == LoadCursor(NULL, IDC_WAIT)) /* Matched handle? */
+    return TRUE; /* Yes, Windows cursor is busy */
+
+  return FALSE; /* No, Windows cursor is not busy */
+}
+/*-------------------------------------------------------------------------*/
+/* This file is used to turn the cursor into a busy (IDC_WAIT) cursor
+for a while, until the next call to be exact.  The function toggles
+the cursor between that and ADC_ARROW. The function IsWindowsCursorBusy()
+returns TRUE if the cursor is in the state IDC_WAIT and FALSE if the cursor
+is any other state. */
+
+#ifndef __INC_WINSTUFF_BUSYCUR_H
+#define __INC_WINSTUFF_BUSYCUR_H
+#include "Headers\BeginCH.H"
+/*-------------------------------------------------------------------------*/
+void ToggleWindowsCursorBusy(void);
+BOOL IsWindowsCursorBusy(void);
+/*-------------------------------------------------------------------------*/
+#include "Headers\EndCH.H"
+#endif /*__INC_WINSTUFF_BUSYCUR_H*/
+/* Microsoft Window - window centerer - David Duncan Ross Palmer */
+
+#include <Windows.H>
+#include <Assert.H>
+#pragma hdrstop
+
+#include "WinStuff\CntrWin.H" /* Our header */
+/*-------------------------------------------------------------------------*/
+BOOL CentreWindow(const HWND win, const HWND parentwin)
+{
+  /* locals */
+  RECT clientRect; /* Rectangle of client window */
+  RECT ourRect; /* Rectangle of our window */
+  int clientRectWidth, clientRectHeight, ourRectHeight, ourRectWidth;
+
+  /* Assertions */
+  assert(IsWindow(win)); /* Verify sent handle is valid */
+  assert(IsWindow(parentwin));
+
+  GetWindowRect(win, &ourRect);
+  GetWindowRect(parentwin, &clientRect);
+
+  clientRectWidth = clientRect.right - clientRect.left;
+  clientRectHeight = clientRect.bottom - clientRect.top;
+  ourRectWidth = ourRect.right - ourRect.left;
+  ourRectHeight = ourRect.bottom - ourRect.top;
+
+  ourRect.left = clientRect.left + ((clientRectWidth /2) - (ourRectWidth /2));
+  ourRect.top = clientRect.top + ((clientRectHeight /2) - (ourRectHeight /2));
+  ourRect.bottom = ourRect.top + ourRectHeight;
+  ourRect.right = ourRect.left + ourRectWidth;
+
+  /* send MoveWindow() our modified rectangle */
+  return MoveWindow(win, ourRect.left, ourRect.top, ourRectWidth, ourRectHeight, TRUE);
+}
+/*-------------------------------------------------------------------------*/
+#ifndef __INC_WINSTUFF_CENTREWIN_H
+#define __INC_WINSTUFF_CENTREWIN_H
+#include "Headers\BeginCH.H"
+/*-------------------------------------------------------------------------*/
+/* Call this function to centre a window to another window (usualy it's parent)*/
+BOOL CentreWindow(const HWND win, const HWND parentwin);
+/*-------------------------------------------------------------------------*/
+#include "Headers\EndCH.H"
+#endif /*__INC_WINSTUFF_CENTREWIN_H*/

File DskSpace/DskSpace.DSW

Binary file added.

File DskSpace/DskSpace.H

+/* Master include file for DskSpace for Windows and Windows NT library.
+This include file hands over the stuff needed to use the library in Windows
+and Windows NT.  The library makes it easy to get disk free and total values
+for any drive which has been assigned a drive letter. */
+
+#ifndef __INC_WINSTUFFDSKSPACE_MASTER_H
+#define __INC_WINSTUFFDSKSPACE_MASTER_H
+
+#include "WinStuff\DskSpace\FreeSpac.H" /* Free space functions */
+
+#include "WinStuff\DskSpace\GetDskSp.H" /* Gets address of extended function, do not use from
+                                           outside the library if portability of the caller is
+                                           needed as this only exists in the Windows version */
+
+#endif /*__INC_WINSTUFFDSKSPACE_MASTER_H*/

File DskSpace/DskSpace.OBR

Binary file added.

File DskSpace/DskSpace.ide

Binary file added.

File DskSpace/DskSpace.mbt

Binary file added.

File DskSpace/DskSpace.mrt

Binary file added.

File DskSpace/DskSpace.~de

Binary file added.

File DskSpace/FreeSpac.H

+#ifndef __INC_WINSTUFFDSKSPACEFREESPAC_H
+#define __INC_WINSTUFFDSKSPACEFREESPAC_H
+#include "Headers\BeginCH.H"
+/*-------------------------------------------------------------------------*/
+/* Notes:
+  Input is Drive which is the ASCII letter of the drive to get the
+  free space of or if you prefer 0-25 for the drive letter in number
+  format.  Output is the return value the low 32-bits of the 64-bit
+  value of space free.  To get the high order 32-bits sent a pointer
+  to a MONSTERLONG64 and read the hi DWORD from it. Some versions
+  of Windows don't support the free space reading of more than  2 GB.
+  Please note that the function is confused by Windows NT disk space per
+  calling thread quotas, this is when an application/user is intentionally
+  limited to a section of the disk.  The function then returns the remaining
+  possible space, that is space it can use following the rules set by the
+  system administrator, and not the actual disk space free. */
+DWORD dskSpace_GetFreeSpace(PMONSTERLONG64 PFreeSp64, BYTE Drive);
+
+/* This one works almost the same as the free space one but gets the total
+   amount of space, it is not confused by disk quotas */
+DWORD dskSpace_GetTotalSpace(PMONSTERLONG64 PTotalSp64, BYTE Drive);
+/*-------------------------------------------------------------------------*/
+#include "Headers\EndCH.H"
+#endif /*__INC_WINSTUFFDSKSPACEFREESPAC_H*/

File DskSpace/GetDskSp.H

+/* This interface just get's GetDiskFreeSpaceEx()'s address or returns NULL if
+this version of Windows does not support that function */
+
+#ifndef __INC_WINSTUFFDSKSPACEGETDSKSP
+#define __INC_WINSTUFFDSKSPACEGETDSKSP
+#include "Headers\BeginCH.H"
+/*-------------------------------------------------------------------------*/
+/* NOTE: All params are outs, instance handle recieves the base address of the
+kernel / or base client dll in Windows NT.  Caller MUST supply PKrnlMod
+and call FreeLibrary(*PKrnlMod) when done with the address returned.  No
+address is returned if GetDiskFreeSpaceEx() is not supported in this version
+of Windows but FreeLibrary() must still be called */
+
+#include <Windows.H>
+FARPROC dskSpace_GetDiskFreeSpaceExProcAddress(HINSTANCE* PKrnlMod);
+/*-------------------------------------------------------------------------*/
+#include "Headers\EndCH.H"
+#endif /*__INC_WINSTUFFDSKSPACEGETDSKSP*/

File DskSpace/GetDskSp.~H

+/* This interface just get's GetDiskFreeSpaceEx()'s address or returns NULL if
+this version of Windows does not support that function */
+
+#ifndef __INC_WINSTUFFDSKSPACEGETDSKSP
+#define __INC_WINSTUFFDSKSPACEGETDSKSP
+#include "Headers\BeginCH.H"
+/*-------------------------------------------------------------------------*/
+/* NOTE: All params are outs, instance handle recieves the base address of the
+kernel / or base client dll in Windows NT.  Caller MUST supply PKrnlMod
+and call FreeLibrary(*PKrnlMod) when done with the address returned.  No
+address is returned if GetDiskFreeSpaceEx() is not supported in this version
+of Windows but FreeLibrary() must still be called */
+
+FARPROC dskSpace_GetDiskFreeSpaceExProcAddress(HINSTANCE* PKrnlMod);
+/*-------------------------------------------------------------------------*/
+#include "Headers\EndCH.H"
+#endif /*__INC_WINSTUFFDSKSPACEGETDSKSP*/

File DskSpace/MakeDrvL.H

+#ifndef __INC_MAKEDRVL_H /* Header name need not be over qualified because it's
+library specific and not meant to be included elsewhere by users of the lib. */
+#define __INC_MAKEDRVL_H
+#include "Headers\BeginCH.H"
+/*-------------------------------------------------------------------------*/
+BYTE dskSpace_MakeDriveLetterValid(const BYTE Drive);
+/*-------------------------------------------------------------------------*/
+#include "Headers\EndCH.H"
+#endif /*__INC_MAKEDRVL_H*/

File DskSpace/dskspace.lib

Binary file added.

File DskSpace/freespac.c

+/* Get volume free space by Overlord David Duncan Ross Palmer
+Revision --->("0")<---
+Created: 2nd Nov 1999
+Last modified: 5th Nov 1999
+Revision history: NONE
+*/
+
+#include "WinStuff\UniOff.H" /* Turn off Unicode in Windows NT builds */
+#include <Windows.H>
+#include "Stds\DLStdInc.H" /* The Daybo Logic standard inclusions header */
+#pragma hdrstop
+
+#include "Headers\DLMath.H" /* Daybo Logic math routines and constants */
+#include "WinStuff\DskSpace\MakeDrvL.H" /* Drive letter modifier */
+#include "WinStuff\DskSpace\FreeSpac.H" /* Our header */
+#include "WinStuff\DskSpace\GetDskSp.H" /* for GetDiskFreeSpaceExProcAddress() */
+
+static DWORD ____GetXSpaceEx(PMONSTERLONG64 PFreeSp64, BYTE Drive, const BOOL FreeSpace); /* FreeSpace is set to get free space, not for total space */
+static DWORD ____GetXSpace(PMONSTERLONG64 PFreeSp64, BYTE Drive, const BOOL FreeSpace);
+/*-------------------------------------------------------------------------*/
+static DWORD ____GetXSpaceEx(PMONSTERLONG64 PFreeSp64, BYTE Drive, const BOOL FreeSpace)
+{
+  /* locals */
+  BOOL failure;
+  MONSTERLONG64 result; /* This is the value we use, we can't use PFreeSp64 directly for use because the caller might not have supplied it */
+  char rootpath[4]; /* Root directly for Windows (under Windows a root directory looks like D:\ */
+  /* This is a pointer to GetFreeDiskSpaceEx() the Windows NT function (also available in Chicago OSR2),
+  can't use GetDiskFreeSpaceEx() if LPCTSTR is not defined.  We will use the
+  constant USEPTR */
+  #ifdef USEPTR /* Someone already defined USEPTR? */
+  #  undef USEPTR /* Don't use their def */
+  #endif /*USEPTR*/
+
+  #ifdef __WIN32__
+  #  define USEPTR
+  #endif /*__WIN32__*/
+
+  #ifdef USEPTR
+    BOOL (*PspaceEx)(LPCTSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER); /* Pointer to extended function in WinNT */
+    HINSTANCE dynKernel; /* Dynamic server base (client/server model Windows NT) */
+  #endif /*USEPTR*/
+
+  /* Result should be used incase it is read before it is written */
+  result.lo ^= result.lo; /* Zero lo-order 32-bits (DWORD)*/
+  result.hi ^= result.hi; /* Zero hi-order 32-bits (DWORD)*/
+
+  Drive = dskSpace_MakeDriveLetterValid(Drive); /* Force the drive letter to be valid (like 0 because A, a becomes a etc. Does not mean letter is valid though */
+  if (!Drive) /* Drive letter was bad like '%' or something */
+  {
+    if (PFreeSp64) /* Caller wants the damn thing back as a blank 64-bit number? */
+      *PFreeSp64 = result; /* Let C copy it to them in one go */
+    return result.lo; /* Use lo-DWORD as the return value */
+  }
+
+  /* Work out the path of the root directory */
+  rootpath[0] = (char)Drive; /* Put drive letter into the start of the root */
+  rootpath[1] = ':'; rootpath[2] = '\\'; rootpath[3] = '\0';
+  /* Made path to root for drive */
+
+  /* Now call the Windows function, use the extended function preferably, but
+  if this Windows is too old use the old function with the 2 GB limit */
+  #ifdef USEPTR
+    #pragma warn -sus /* Disable "suspicious pointer conversion" warning to avoid bad-ass cast */
+    PspaceEx = dskSpace_GetDiskFreeSpaceExProcAddress(&dynKernel); /* Get address of extended function */
+    #pragma warn .sus /* Restore status of warning to it's original setting */
+    if (PspaceEx) /* Extended function address recieved? */
+    {
+      ULARGE_INTEGER freebytes, totalbytes;
+
+      if (PspaceEx(rootpath, &freebytes, &totalbytes, NULL)) /* Call Windows NT function */
+      {
+        if (FreeSpace)
+        {
+          result.lo = freebytes.u.LowPart;
+          result.hi = freebytes.u.HighPart;
+        }
+        else /* Total Space */
+        {
+          result.lo = totalbytes.u.LowPart;
+          result.hi = totalbytes.u.HighPart;
+        }
+        failure = FALSE;
+      }
+      else /* Oops, GetFreeDiskSpaceEx() failed! */
+      {
+        failure = TRUE;
+      }
+    } /*(PspaceEx)*/
+    else /* The function was not included in this build of Windows, it's too old */
+    {
+      ____GetXSpace(&result, Drive, FreeSpace); /* Try simple function */
+      failure = FALSE; /* Safe */
+    }
+
+    FreeLibrary(dynKernel); /* Decrement kernel base ref count */
+    if (failure) /* GetDiskFreeSpaceEx() failed? */
+    {
+      if (PFreeSp64) /* Caller want's whole 64-bit value? */
+        *PFreeSp64 = result; /* Copy from local var */
+      return result.lo; /* Return the lo-order DWORD as the return value ((DWORD)(0UL)) */
+    }
+  #else /* An old copy of Windows where using the pointer to the extended function would cause problems */
+    ____GetXSpace(&result, Drive, FreeSpace); /* Try simple function */
+  #endif /*USEPTR*/
+
+  if (PFreeSp64) /* Caller wants a copy of the whole 64-bit value? */
+    *PFreeSp64 = result; /* Copy to the caller */
+  return result.lo; /* Return value is always lo-order DWORD (32-bit) */
+}
+/*-------------------------------------------------------------------------*/
+static DWORD ____GetXSpace(PMONSTERLONG64 PFreeSp64, BYTE Drive, const BOOL FreeSpace)
+{
+  /* THIS FUNCTION USES THE OLDER GETDISKFREESPACE METHOD OF WORKING WHICH DOES
+  NOT SUPPORT 64-BIT VALUES */
+
+  /* locals */
+  char rootpath[4]; /* Holds path to root directory of the drive in question */
+  MONSTERLONG64 result; /* The result we will be using incase the user does not use 64-bitness */
+  struct
+  {
+    DWORD sectorsPerCluster;
+    DWORD bytesPerSector;
+    DWORD numberOfFreeClusters;
+    DWORD totalNumberOfClusters;
+  } stats;
+  DWORD dwAddLoopCtrl;
+
+  /* Zero the result */
+  result.lo ^= result.lo; /* Zero the lo-order DWORD */
+  result.hi ^= result.hi; /* Zero the hi-order DWORD */
+
+  /* Get the drive letter */
+  Drive = dskSpace_MakeDriveLetterValid(Drive); /* Force the drive letter to be valid */
+  if (!Drive) /* The drive letter could not be validated */
+  {
+    if (PFreeSp64) /* Caller want the 64-bit value? */
+      *PFreeSp64 = result; /* Copy the result to the caller */
+    return result.lo; /* Give the lo-order DWORD as the return value of the function */
+  }
+
+  /* Begin building the path */
+  rootpath[0] = (char)Drive; /* Set drive letter at the begining of the path */
+  rootpath[1] = ':'; /* Path sep, it's the way DOS and Windows NT work */
+  rootpath[2] = '\\'; /* Root is designated by no dir name */
+  rootpath[3] = '\0'; /* Terminate string to indicate length */
+
+  /* Call Windows NT API function to get the stats */
+  if (!GetDiskFreeSpace(rootpath,
+                        &stats.sectorsPerCluster,
+                        &stats.bytesPerSector,
+                        &stats.numberOfFreeClusters,
+                        &stats.totalNumberOfClusters
+  ))
+  {
+    /* The call to Windows has failed for some unknown reason */
+    if (PFreeSp64) /* The caller wants the QWORD back? */
+      *PFreeSp64 = result; /* Copy it to the caller */
+    return result.lo; /* The return value is the lo-order DWORD of the QWORD */
+  }
+
+  /* The details have been returned by the Windows operating system, some computations
+  are neccersary to know */
+  for (dwAddLoopCtrl =0UL;
+       dwAddLoopCtrl < stats.bytesPerSector * stats.sectorsPerCluster;
+       dwAddLoopCtrl++)
+  {
+    if (FreeSpace)
+    {
+      ml64AddWORD(&result, stats.numberOfFreeClusters);
+    }
+    else /* Total space */
+    {
+      ml64AddWORD(&result, stats.totalNumberOfClusters);
+    }
+  }
+
+  if (PFreeSp64) /* Caller wants QWORD not just DWORD ? */
+    *PFreeSp64 = result; /* Copy to caller */
+  return result.lo; /* Returns the lo-order DWORD of the QWORD from the function */
+}
+/*-------------------------------------------------------------------------*/
+DWORD dskSpace_GetFreeSpace(PMONSTERLONG64 PFreeSp64, BYTE Drive)
+{
+  return ____GetXSpaceEx(PFreeSp64, Drive, TRUE);
+}
+/*-------------------------------------------------------------------------*/
+DWORD dskSpace_GetTotalSpace(PMONSTERLONG64 PTotalSp64, BYTE Drive)
+{
+  return ____GetXSpaceEx(PTotalSp64, Drive, FALSE);
+}
+/*-------------------------------------------------------------------------*/

File DskSpace/freespac.~c

+/* Get volume free space by Overlord David Duncan Ross Palmer
+Revision --->("0")<---
+Created: 2nd Nov 1999
+Last modified: 5th Nov 1999
+Revision history: NONE
+*/
+
+#include "WinStuff\UniOff.H" /* Turn off Unicode in Windows NT builds */
+#include <Windows.H>
+#include "Stds\DLStdInc.H" /* The Daybo Logic standard inclusions header */
+#pragma hdrstop
+
+#include "Headers\DLMath.H" /* Daybo Logic math routines and constants */
+#include "WinStuff\DskSpace\MakeDrvL.H" /* Drive letter modifier */
+#include "WinStuff\DskSpace\FreeSpac.H" /* Our header */
+#include "WinStuff\DskSpace\GetDskSp.H" /* for GetDiskFreeSpaceExProcAddress() */
+
+static DWORD ____GetXSpaceEx(PMONSTERLONG64 PFreeSp64, BYTE Drive, const BOOL FreeSpace); /* FreeSpace is set to get free space, not for total space */
+static DWORD ____GetXSpace(PMONSTERLONG64 PFreeSp64, BYTE Drive, const BOOL FreeSpace);
+/*-------------------------------------------------------------------------*/
+static DWORD ____GetXSpaceEx(PMONSTERLONG64 PFreeSp64, BYTE Drive, const BOOL FreeSpace)
+{
+  /* locals */
+  BOOL failure;
+  MONSTERLONG64 result; /* This is the value we use, we can't use PFreeSp64 directly for use because the caller might not have supplied it */
+  char rootpath[4]; /* Root directly for Windows (under Windows a root directory looks like D:\ */
+  /* This is a pointer to GetFreeDiskSpaceEx() the Windows NT function (also available in Chicago OSR2),
+  can't use GetDiskFreeSpaceEx() if LPCTSTR is not defined.  We will use the
+  constant USEPTR */
+  #ifdef USEPTR /* Someone already defined USEPTR? */
+  #  undef USEPTR /* Don't use their def */
+  #endif /*USEPTR*/
+
+  #ifdef __WIN32__
+  #  define USEPTR
+  #endif /*__WIN32__*/
+
+  #ifdef USEPTR
+    BOOL (*PspaceEx)(LPCTSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER); /* Pointer to extended function in WinNT */
+    HINSTANCE dynKernel; /* Dynamic server base (client/server model Windows NT) */
+  #endif /*USEPTR*/
+
+  /* Result should be used incase it is read before it is written */
+  result.lo ^= result.lo; /* Zero lo-order 32-bits (DWORD)*/
+  result.hi ^= result.hi; /* Zero hi-order 32-bits (DWORD)*/
+
+  Drive = dskSpace_MakeDriveLetterValid(Drive); /* Force the drive letter to be valid (like 0 because A, a becomes a etc. Does not mean letter is valid though */
+  if (!Drive) /* Drive letter was bad like '%' or something */
+  {
+    if (PFreeSp64) /* Caller wants the damn thing back as a blank 64-bit number? */
+      *PFreeSp64 = result; /* Let C copy it to them in one go */
+    return result.lo; /* Use lo-DWORD as the return value */
+  }
+
+  /* Work out the path of the root directory */
+  rootpath[0] = (char)Drive; /* Put drive letter into the start of the root */
+  rootpath[1] = ':'; rootpath[2] = '\\'; rootpath[3] = '\0';
+  /* Made path to root for drive */
+
+  /* Now call the Windows function, use the extended function preferably, but
+  if this Windows is too old use the old function with the 2 GB limit */
+  #ifdef USEPTR
+    #pragma warn -sus /* Disable "suspicious pointer conversion" warning to avoid bad-ass cast */
+    PspaceEx = dskSpace_GetDiskFreeSpaceExProcAddress(&dynKernel); /* Get address of extended function */
+    #pragma warn .sus /* Restore status of warning to it's original setting */
+    if (PspaceEx) /* Extended function address recieved? */
+    {
+      ULARGE_INTEGER freebytes, totalbytes;
+
+      if (PspaceEx(rootpath, &freebytes, &totalbytes, NULL)) /* Call Windows NT function */
+      {
+        if (FreeSpace)
+        {
+          result.lo = freebytes.u.LowPart;
+          result.hi = freebytes.u.HighPart;
+        }
+        else /* Total Space */
+        {
+          result.lo = totalbytes.u.LowPart;
+          result.hi = totalbytes.u.HighPart;
+        }
+        failure = FALSE;
+      }
+      else /* Oops, GetFreeDiskSpaceEx() failed! */
+      {
+        failure = TRUE;
+      }
+    } /*(PspaceEx)*/
+    else /* The function was not included in this build of Windows, it's too old */
+    {
+      ____GetXSpace(&result, Drive, FreeSpace); /* Try simple function */
+      failure = FALSE; /* Safe */
+    }
+
+    FreeLibrary(dynKernel); /* Decrement kernel base ref count */
+    if (failure) /* GetDiskFreeSpaceEx() failed? */
+    {
+      if (PFreeSp64) /* Caller want's whole 64-bit value? */
+        *PFreeSp64 = result; /* Copy from local var */
+      return result.lo; /* Return the lo-order DWORD as the return value ((DWORD)(0UL)) */
+    }
+  #else /* An old copy of Windows where using the pointer to the extended function would cause problems */
+    ____GetXSpace(&result, Drive, FreeSpace); /* Try simple function */
+  #endif /*USEPTR*/
+
+  if (PFreeSp64) /* Caller wants a copy of the whole 64-bit value? */
+    *PFreeSp64 = result; /* Copy to the caller */
+  return result.lo; /* Return value is always lo-order DWORD (32-bit) */
+}
+/*-------------------------------------------------------------------------*/
+static DWORD ____GetXSpace(PMONSTERLONG64 PFreeSp64, BYTE Drive, const BOOL FreeSpace)
+{
+  /* THIS FUNCTION USES THE OLDER GETDISKFREESPACE METHOD OF WORKING WHICH DOES
+  NOT SUPPORT 64-BIT VALUES */
+
+  /* locals */
+  char rootpath[4]; /* Holds path to root directory of the drive in question */
+  MONSTERLONG64 result; /* The result we will be using incase the user does not use 64-bitness */
+  struct
+  {
+    DWORD sectorsPerCluster;
+    DWORD bytesPerSector;
+    DWORD numberOfFreeClusters;
+    DWORD totalNumberOfClusters;
+  } stats;
+  DWORD dwAddLoopCtrl;
+
+  /* Zero the result */
+  result.lo ^= result.lo; /* Zero the lo-order DWORD */
+  result.hi ^= result.hi; /* Zero the hi-order DWORD */
+
+  /* Get the drive letter */
+  Drive = dskSpace_MakeDriveLetterValid(Drive); /* Force the drive letter to be valid */
+  if (!Drive) /* The drive letter could not be validated */
+  {
+    if (PFreeSp64) /* Caller want the 64-bit value? */
+      *PFreeSp64 = result; /* Copy the result to the caller */
+    return result.lo; /* Give the lo-order DWORD as the return value of the function */
+  }
+
+  /* Begin building the path */
+  rootpath[0] = (char)Drive; /* Set drive letter at the begining of the path */
+  rootpath[1] = ':'; /* Path sep, it's the way DOS and Windows NT work */
+  rootpath[2] = '\\'; /* Root is designated by no dir name */
+  rootpath[3] = '\0'; /* Terminate string to indicate length */
+
+  /* Call Windows NT API function to get the stats */
+  if (!GetDiskFreeSpace(rootpath,
+                        &stats.sectorsPerCluster,
+                        &stats.bytesPerSector,
+                        &stats.numberOfFreeClusters,
+                        &stats.totalNumberOfClusters
+  ))
+  {
+    /* The call to Windows has failed for some unknown reason */
+    if (PFreeSp64) /* The caller wants the QWORD back? */
+      *PFreeSp64 = result; /* Copy it to the caller */
+    return result.lo; /* The return value is the lo-order DWORD of the QWORD */
+  }
+
+  /* The details have been returned by the Windows operating system, some computations
+  are neccersary to know */
+  for (dwAddLoopCtrl =0UL;
+       dwAddLoopCtrl < stats.bytesPerSector * stats.sectorsPerCluster;
+       dwAddLoopCtrl++)
+  {
+    if (FreeSpace)
+    {
+      ml64AddWORD(&result, stats.numberOfFreeClusters);
+    }
+    else /* Total space */
+    {
+      ml64AddWORD(&result, stats.totalNumberOfClusters);
+    }
+  }
+
+  if (PFreeSp64) /* Caller wants QWORD not just DWORD ? */
+    *PFreeSp64 = result; /* Copy to caller */
+  return result.lo; /* Returns the lo-order DWORD of the QWORD from the function */
+}
+/*-------------------------------------------------------------------------*/
+DWORD dskSpace_GetFreeSpace(PMONSTERLONG64 PFreeSp64, BYTE Drive)
+{
+  return ____GetXSpaceEx(PFreeSp64, Drive, TRUE);
+}
+/*-------------------------------------------------------------------------*/
+DWORD dskSpace_GetTotalSpace(PMONSTERLONG64 PTotalSp64, BYTE Drive)
+{
+  return ____GetXSpaceEx(PTotalSp64, Drive, FALSE);
+}
+/*-------------------------------------------------------------------------*/

File DskSpace/getdsksp.c

+/* This interface just get's GetDiskFreeSpaceEx()'s address or returns NULL if
+this version of Windows does not support that function.
+Revision -->("0")<---
+Created: 02/11/1999, last modified: THEN
+History: (none)
+*/
+
+#include "WinStuff\UniOff.H" /* Turn off unicode mode */
+#include <Windows.H>
+#include "Stds\DLStdInc.H" /* Daybo Logic standard inclusions */
+#pragma hdrstop
+
+#include "WinStuff\DskSpace\GetDskSp.H" /* Our header, for function decl. */
+/*-------------------------------------------------------------------------*/
+FARPROC dskSpace_GetDiskFreeSpaceExProcAddress(HINSTANCE* PKrnlMod)
+{
+  /* locals */
+  FARPROC _funcptr = NULL;
+
+  if (!PKrnlMod) /* No pointer to module handle variable! */
+    abort(); /* There must be, we need to use it as much as the caller does */
+
+  #ifdef __WIN32__
+    *PKrnlMod = LoadLibrary("KERNEL32"); /* Get handle to the Windows NT base client DLL or Windows kernel */
+  #else /* Win16? */
+    *PKrnlMod = LoadLibrary("KERNEL"); /* Get handke to the Windows kernel */
+  #endif /*__WIN32__*/
+  if (*PKrnlMod) /* Got handle? */
+  {
+    _funcptr = GetProcAddress(*PKrnlMod, "GetDiskFreeSpaceExA"); /* Attempt to get address */
+    /* If _funcptr holds an address all well and good, if not then
+    I guess GetDiskFreeSpaceEx had not been made in this version of
+    Windows. */
+    /*FreeLibrary(*PKrnlMod); /* Decrements the reference count on the DLL's loads within the address space,
+    it is never actually unloaded because all programs have to load-time
+    link to Kernel before thay can get anything done.  In all honestly,
+    if I forgot to decrement the ref count on the kernel DLL not a lot would
+    happen as when the program exits the kernel would have to be removed
+    from the program's address space anyway.  Still I suppose we could be called millions
+    of times until Windows couln't cope with the count and said it couldn't load
+    the DLL so I guess while not so efficient it's better practice to call FreeLibrary().
+    Actually in the end I decided not to, the caller should deal with
+    unloading it seeing as thay are going to use the address! */
+  }
+
+  return _funcptr; /* Give address to caller */
+}
+/*-------------------------------------------------------------------------*/

File DskSpace/getdsksp.~c

+/* This interface just get's GetDiskFreeSpaceEx()'s address or returns NULL if
+this version of Windows does not support that function.
+Revision -->("0")<---
+Created: 02/11/1999, last modified: THEN
+History: (none)
+*/
+
+#include "WinStuff\UniOff.H" /* Turn off unicode mode */
+#include <Windows.H>
+#include "Stds\DLStdInc.H" /* Daybo Logic standard inclusions */
+#pragma hdrstop
+
+#include "WinStuff\DskSpace\GetDskSp.H" /* Our header, for function decl. */
+/*-------------------------------------------------------------------------*/
+FARPROC dskSpace_GetDiskFreeSpaceExProcAddress(HINSTANCE* PKrnlMod)
+{
+  /* locals */
+  FARPROC _funcptr = NULL;
+
+  if (!PKrnlMod) /* No pointer to module handle variable! */
+    abort(); /* There must be, we need to use it as much as the caller does */
+
+  #ifdef __WIN32__
+    *PKrnlMod = LoadLibrary("KERNEL32"); /* Get handle to the Windows NT base client DLL or Windows kernel */
+  #else /* Win16? */
+    *PKrnlMod = LoadLibrary("KERNEL"); /* Get handke to the Windows kernel */
+  #endif /*__WIN32__*/
+  if (*PKrnlMod) /* Got handle? */
+  {
+    _funcptr = GetProcAddress(*PKrnlMod, "GetDiskFreeSpaceEx"); /* Attempt to get address */
+    /* If _funcptr holds an address all well and good, if not then
+    I guess GetDiskFreeSpaceEx had not been made in this version of
+    Windows. */
+    /*FreeLibrary(*PKrnlMod); /* Decrements the reference count on the DLL's loads within the address space,
+    it is never actually unloaded because all programs have to load-time
+    link to Kernel before thay can get anything done.  In all honestly,
+    if I forgot to decrement the ref count on the kernel DLL not a lot would
+    happen as when the program exits the kernel would have to be removed
+    from the program's address space anyway.  Still I suppose we could be called millions
+    of times until Windows couln't cope with the count and said it couldn't load
+    the DLL so I guess while not so efficient it's better practice to call FreeLibrary().
+    Actually in the end I decided not to, the caller should deal with
+    unloading it seeing as thay are going to use the address! */
+  }
+
+  return _funcptr; /* Give address to caller */
+}
+/*-------------------------------------------------------------------------*/

File DskSpace/makedrvl.c

+/* Make drive letter valid for the internal use of the DskSpace library,
+it's possible to access this from outside, but there's no prototype for
+it because it's meant to be internal.
+
+Programmer: Overlord David Duncan Ross Palmer
+Company: Daybo Logic
+Copyright: Daybo Logic 1999
+Created: 5th November 1999
+Last modifed: THE SAME
+*/
+
+#include "Stds\DLStdInc.H" /* The Daybo Logic standard inclusions */
+#pragma hdrstop
+
+#include "WinStuff\DskSpace\MakeDrvL.H" /* Our header (private to library) */
+/*-------------------------------------------------------------------------*/
+BYTE dskSpace_MakeDriveLetterValid(const BYTE Drive)
+{
+  BYTE newDrive = Drive; /* Drive letter to send back to the caller */
+
+  if (newDrive <= 25) /* Drive number rather than letter sent? */
+  {
+    newDrive += (BYTE)65; /* Convert to uppercase letter */
+  }
+  else /* Probable letter sent */
+  {
+    if (newDrive >= 97 && newDrive <= 122) /* Lower case letter? */
+      newDrive -= (BYTE)32; /* Make upper case */
+    if (newDrive < 65 || newDrive > 90) /* Not a valid letter!? */
+      return 0; /* Get out of here! */
+  }
+
+  return newDrive; /* Give validated drive letter to the caller */
+}
+/*-------------------------------------------------------------------------*/
+/* This module stores the HINSTANCE calue of the main executable module,
+it may be only set once. */
+
+#ifndef __INC_HINST_H
+#define __INC_HINST_H
+#include "Headers\BeginCH.H"
+/*-------------------------------------------------------------------------*/
+const HINSTANCE GetInstanceHandle(void); /* Returns handle */
+BOOL SetInstanceHandle(const HINSTANCE SetTo); /* Sets handle, can only do once */
+BOOL IsInstanceHandleSet(void); /* Tells you if the handle has been set */
+/*-------------------------------------------------------------------------*/
+#include "Headers\EndCH.H"
+#endif /*__INC_HINST_H*/
+/* For Win32 only, turns of Unicode mode at a compile level : written by
+Overlord David Duncan Ross Palmer on 2nd November 1999 */
+
+#ifndef __INC_WINSTUFF_UNICODEOFF
+#define __INC_WINSTUFF_UNICODEOFF
+/*----------------------------------------------------------------*/
+#ifdef __WIN32__ /* At least a 32-bit architecture build for Windows? */
+#  ifdef _WINDOWS_ /* Windows already included!? */
+#    error "WinStuff\UniOff.H was included after Windows.H, reverse that or trying to switch off Unicode is not effective"
+#  endif /*_WINDOWS_*/
+
+#  ifdef UNICODE /* Microsoft's UNICODE flag set? */
+#    undef UNICODE /* Switch it off before Windows is included */
+#  endif /*UNICODE*/
+
+#  ifdef _UNICODE /* I've seen this somewhere, posibly some Borland headers */
+#    undef UNICODE /* Switch it off, what am I switching off though, will the world fall apart if Borland uses it for something undocumented? */
+#  endif /*_UNICODE - Perhaps I'll never know */
+
+#endif /*__WIN32__*/
+/*----------------------------------------------------------------*/
+#endif /*__INC_WINSTUFF_UNICODEOFF*/
+/* This module stores the HINSTANCE calue of the main executable module,
+it may be only set once. */
+
+#include <Windows.H>
+#pragma hdrstop
+
+#include "WinStuff\HInst.H" /* Our header */
+/*-------------------------------------------------------------------------*/
+static HINSTANCE HInstance; /* HINSTANCE of application */
+static BOOL IsSet = FALSE; /* If HINSTANCE is set or not */
+/*-------------------------------------------------------------------------*/
+const HINSTANCE GetInstanceHandle() /* Returns handle */
+{
+  if (IsSet) /* Handle set? */
+    return HInstance;
+  return NULL; /* Else give dummy, blank handle */
+}
+/*-------------------------------------------------------------------------*/
+BOOL SetInstanceHandle(const HINSTANCE SetTo) /* Sets handle, can only do once */
+{
+  if (IsSet) /* Already set? */
+    return FALSE; /* Cannot set more than once! */
+
+  HInstance = SetTo; /* Set the handle */
+  IsSet = TRUE; /* Remember set */
+  return TRUE; /* Success, set handle */
+}
+/*-------------------------------------------------------------------------*/
+BOOL IsInstanceHandleSet()
+{
+  return IsSet; /* Give flag */
+}
+/*-------------------------------------------------------------------------*/