Hardware "initialization"

This is a discussion on Hardware "initialization" within the Windows Programming forums, part of the Platform Specific Boards category; Is there a way to detect maximum and available hard drive space? Also, is there a GetAllInputDevicesAndPrintEachToClientArea function? :-) Seriously, ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    207

    Hardware "initialization"

    Is there a way to detect maximum and available hard drive space?

    Also, is there a GetAllInputDevicesAndPrintEachToClientArea function? :-)

    Seriously, I was looking at GetSystemMetrics and the mouse detection looked a little weak and was wondering if there were a more reliable way to detect it than SM_MOUSEPRESENT?

    Microsoft says:

    Nonzero if a mouse is installed; otherwise, 0 (zero). This value is rarely zero, because of support for virtual mice and because some systems detect the presence of the port instead of the presence of a mouse.

    mw
    Blucast Corporation

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Code snippet below to detect maximum and available hard drive space.

    Bob

    Code:
    #include <windows.h>
    #include <stdio.h>
    
    int main(void)
    {
        unsigned __int64 i64TotalBytes, i64AvailableBytes;    
    
        BOOL  bReturn;
        char  *pDrive  = "C:\\";
        DWORD dwSectorsPerCluster,
            dwBytesPerSector,
            dwFreeClusters,
            dwTotalClusters;
    
        bReturn = GetDiskFreeSpace (pDrive, 
            &dwSectorsPerCluster,
            &dwBytesPerSector, 
            &dwFreeClusters,
            &dwTotalClusters);
        if (bReturn)
        {
            /* cast it to 64 bits for calculations */ 
            i64TotalBytes = (__int64)dwTotalClusters * dwSectorsPerCluster * dwBytesPerSector;
            i64AvailableBytes = (__int64)dwFreeClusters * dwSectorsPerCluster * dwBytesPerSector;
            printf ("Available = %I64u MB\n", i64AvailableBytes / (1024*1024));
            printf ("Total  = %I64u MB\n",i64TotalBytes / (1024*1024));
        }
        else 
            printf("GetDiskFreeSpace failed\n");
        return 0;
    }

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    207
    Thanks! It works great!

    mw
    Blucast Corporation

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 21
    Last Post: 06-24-2009, 10:49 AM
  2. Hardware interrupts
    By Sentral in forum Tech Board
    Replies: 5
    Last Post: 02-23-2009, 06:46 PM
  3. X-10 Hardware
    By jmd15 in forum Tech Board
    Replies: 1
    Last Post: 09-29-2005, 08:34 PM
  4. How does hardware interpret data?
    By Silvercord in forum Tech Board
    Replies: 3
    Last Post: 01-29-2003, 01:46 PM
  5. Linux Hardware Handbook
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 04-02-2002, 06:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21