Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

会员投稿 投稿指南 本期推荐:
搜索:
您的位置: Linux安全网 > Linux编程 > » 正文

Windows_Programing_English_To_Chinese_1_MSVC_C运行库(16)

来源: 未知 分享至:

§ 下面的程序代码使用_getdrives() 函数来列举出本机当前可以使用的驱动器。

#include<windows.h>

#include<direct.h>

#include<stdio.h>

#include<tchar.h>

 

// buffer, be careful with terminated NULL. Must match with ++mydrives[1]...that is one space

//for example if no one space: \"A:\"--> ++mydrives[0];

// you may try char mydrives[ ] = {\" A: \"}; or char mydrives[ ] = \" A: \";

TCHAR mydrives[ ] = \" A: \";

 

intmain()

{

  // get the drives bit masks...1 is available, 0 is not available A = least significant bit...

   ULONG DriveMask = _getdrives();

  // if something wrong

   if(DriveMask == 0)

      printf(\"_getdrives() failed with failure code: %dn\", GetLastError());

  else

   {

     printf(\"This machine has the following logical drives:n\");

     while (DriveMask)

     {   // list all the drives...

         if(DriveMask & 1)

            printf(mydrives);

        // go to the next drive strings with one space

        ++mydrives[1];

        // shift the bit masks binary to the right and repeat

         DriveMask >>= 1;


Tags:
分享至:
最新图文资讯
1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史