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

本文介绍如何使用Windows API函数获取计算机上的磁盘驱动器信息,包括可用驱动器的位掩码及详细类型,如固定驱动器、可移动驱动器等。
  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;
}

 
### 第十三届微缩电磁会议相关信息 第十三届微缩电磁会议(13th International Conference on Miniaturized Electromagnetics, ICEM 2023)是一场专注于微缩电磁领域最新研究成果和技术发展的国际学术会议。该会议为全球学者、工程师和行业专家提供了一个交流平台,旨在促进微缩电磁技术在通信、传感、医疗、能源等领域的应用与发展[^1]。 会议的主题涵盖了微缩天线设计、射频电路与系统、纳米电磁材料、无线能量传输、电磁兼容性以及相关交叉学科的前沿研究。论文征集范围广泛,包括但不限于以下主题:小型化天线技术、可重构射频器件、先进电磁材料、电磁波传播特性分析及建模方法等[^2]。 活动安排通常包括主题演讲、特邀报告、分组讨论、海报展示以及工业展览等多个环节。这些活动形式不仅促进了学术界与产业界的深度合作,还为参会者提供了丰富的学习与 networking 机会[^3]。 此外,会议还特别设立了优秀论文奖,以表彰在微缩电磁领域做出突出贡献的研究成果。所有被录用并参加会议展示的论文将收录至会议论文集,并提交至知名数据库如 IEEE Xplore 和 Scopus 进行索引[^4]。 ```python # 示例代码:模拟会议论文提交系统的基本逻辑 class PaperSubmissionSystem: def __init__(self): self.submitted_papers = [] def submit_paper(self, title, authors, abstract): paper = { "title": title, "authors": authors, "abstract": abstract, "status": "submitted" } self.submitted_papers.append(paper) def review_paper(self, index, decision): if 0 <= index < len(self.submitted_papers): self.submitted_papers[index]["status"] = decision # 使用示例 system = PaperSubmissionSystem() system.submit_paper("Miniaturized Antenna Design", ["John Doe", "Jane Smith"], "This paper discusses...") system.review_paper(0, "accepted") ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值