September 13th Thursday (九月 十三日 木曜日)

原创 2007年10月14日 13:38:00
  DWORD GetLogicalDrives(VOID);

MSDN Description: If the function succeeds, the return value is a bitmask representing the currently available disk drives. Bit position 0 (the least-significant bit) is drive A, bit position 1 is drive B, bit position 2 is drive C, and so on.

DWORD GetLogicalDriveStrings( DWORD nBufferLength, // size of buffer
                              LPTSTR lpBuffer // pointer to buffer for drive strings );
Parameters

nBufferLength
    Specifies the maximum size, in characters, of the buffer pointed to by lpBuffer. This size does not include the terminating null character.
lpBuffer
    Pointer to a buffer that receives a series of null-terminated strings, one for each valid drive in the system, that end with a second null character. The following example shows the buffer contents with <null> representing the terminating null character.

    c:/<null>d:/<null><null>

Return Values

If the function succeeds, the return value is the length, in characters, of the strings copied to the buffer, not including the terminating null character. Note that an ANSI-ASCII null character uses one byte, but a Unicode null character uses two bytes.

If the buffer is not large enough, the return value is greater than nBufferLength. It is the size of the buffer required to hold the drive strings.

If the function fails, the return value is zero.

UINT GetDriveType( LPCTSTR lpRootPathName // pointer to root path );
The GetDriveType function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.
Parameters

lpRootPathName
    Pointer to a null-terminated string that specifies the root directory of the disk to return information about. If lpRootPathName is NULL, the function uses the root of the current directory.

Return Values

The return value specifies the type of drive. It can be one of the following values:
Value Meaning
DRIVE_UNKNOWN The drive type cannot be determined.
DRIVE_NO_ROOT_DIR The root directory does not exist.
DRIVE_REMOVABLE The disk can be removed from the drive.
DRIVE_FIXED The disk cannot be removed from the drive.
DRIVE_REMOTE The drive is a remote (network) drive.
DRIVE_CDROM The drive is a CD-ROM drive.
DRIVE_RAMDISK The drive is a RAM disk.


/* GetDriveInfo1.c */
#include <stdio.h>
#include <windows.h>

int main()
{
    DWORD dwRtn = GetLogicalDrives();
    char c = 'A';
    char drive[4];
    char output[64];

    while ( dwRtn )
    {
        if ( dwRtn & 1  )
        {
            sprintf(drive, "%c://",  c);
            switch ( GetDriveType(drive) )
            {
            case DRIVE_FIXED:
                sprintf(output, "%c: -- Drive Fixed/n", c);
                break;
            case DRIVE_REMOVABLE:
                sprintf(output, "%c: -- Drive Removable/n", c);
                break;
            case DRIVE_REMOTE:
                sprintf(output, "%c: -- Drive Remote/n", c);
                break;
            case DRIVE_CDROM:
                sprintf(output, "%c: -- CD-Rom/n", c);
                break;
            case DRIVE_RAMDISK:
                sprintf(output, "%c: -- Ram Disk/n", c);
                break;
            default:
                sprintf(output, "%c: -- Unknown drive/n", c);
                break;
            }
            printf("%s", output);
        }
        c++;
        dwRtn >>= 1;
    }
    return 0;
}

/* GetDriveInfo2.c */

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

int main()
{
  
    char Buf[256];
    char TmpDrive[4];
    int i, j = 0;
    char strType[32];
    UINT uType;
    DWORD dwRtn ;
  
    memset(Buf, 0, 256);
    dwRtn = GetLogicalDriveStrings(256, Buf);
  
    for ( i=0; i < (int)dwRtn; i++ )
    {
        if ( Buf[i] == 0  )
        {
            if ( Buf[i+1] != 0 || (Buf[i+1] == 0 && Buf[i+2] == 0 ))
            {
                TmpDrive[j] = Buf[i];
                j = 0;
                uType = GetDriveType(TmpDrive);
                switch(uType)
                {
                case DRIVE_REMOVABLE:
                    sprintf(strType, "Removable");
                    break;
                case DRIVE_FIXED:
                    sprintf(strType, "Fixed Drive");
                    break;
                case DRIVE_REMOTE:
                    sprintf(strType, "Remote Drive");
                    break;
                case DRIVE_CDROM:
                    sprintf(strType, "CD-Rom");
                    break;
                case DRIVE_RAMDISK:
                    sprintf(strType, "Ram disk");
                    break;
                default:
                    sprintf(strType, "Unknow type");
                    break;
                }
                printf("%s - %s/n", TmpDrive, strType);
            }
        }
        if ( Buf[i])
            TmpDrive[j++] = Buf[i];

        if ( Buf[i] == 0 && Buf[i+1] == 0 && Buf[i+2] == 0)
            return 0;
    }
  
    return 0;
}

 

Java基础(二)巧用Java中Calendar工具类

Java的JDK中提供了一系列好用的util工具类。Calendar就是java.util中用于处理日期的工具类。且该工具类易学易用实用。 工具类Calendar是抽象类。 PS:为什么把Ca...
  • liu765023051
  • liu765023051
  • 2015年07月30日 09:57
  • 5502

Android 日期选择器,实现年月日三级联动

最近项目里面用到了一个日期选择器,实现现在主流的WheelView滑动选择,整理了下,做了个Demo.废话不多说,直接上代码: 主布局:activity_main.xml ...
  • hubeiqiyuan
  • hubeiqiyuan
  • 2016年08月08日 16:21
  • 5026

自写日期年月日三级联动效果jquery插件

哈哈,好久没写新博文啦,原因是最近一直在研究用jquery UI实现截取头像的功能,哈哈 言归正传,有时候呢,我们会在用户资料的页面用到一个年月日日期的三级联动效果。在网上找了找,没看到有多么合适...
  • u010480479
  • u010480479
  • 2014年07月17日 13:50
  • 4135

CentOS6.5菜鸟之旅:文件权限详解 一、前言                                 Linux下所有资源、设备均被视作文件来操作,而文件权限则是决定用户可各文件

CentOS6.5菜鸟之旅:文件权限详解 一、前言                                   Linux下所有资源、设备均被视作文件来操作,而文件权限则是...
  • cdnight
  • cdnight
  • 2017年05月31日 19:49
  • 401

JSP应用开发详解第三版 源代码 ch13

  • 2007年08月15日 13:38
  • 2.61MB
  • 下载

     基于局域网的扫雷对战游戏的设计与实现                            

  • 2014年05月20日 14:47
  • 609KB
  • 下载

Linux 编程第四版; Begin Linux Programming 4th

  • 2009年05月08日 17:43
  • 4.18MB
  • 下载

作业13: 文件的输入与输出

作业13: 文件的输入与输出/*************************** 第13章  14题  P458   ******************************4.建立两个磁盘文...
  • neicole
  • neicole
  • 2011年07月13日 11:43
  • 2185

Localization in Clinical Neurology  5th Edition

  • 2010年04月25日 09:17
  • 10.63MB
  • 下载

September 17th 模拟赛C T3 石子游戏 Solution

一个傻逼写的题解。
  • Ace_Killing
  • Ace_Killing
  • 2016年09月21日 19:49
  • 323
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:September 13th Thursday (九月 十三日 木曜日)
举报原因:
原因补充:

(最多只允许输入30个字)