| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> c/c++ >> C++ tong guo WIN32 API huo qu luo ji ci pan xiang xi xin xi

C++ tong guo WIN32 API huo qu luo ji ci pan xiang xi xin xi

2008-06-01 02:06:53 编辑來源:互联网 评论
 
 
 
本文为【C++通过WIN32 API获取逻辑磁盘详细信息】的拼音翻译版
  zhong suo zhou zhi , zai wei ruan de cao zuo xi tong xia bian xie ying yong cheng xu , zui zhu yao de huan shi tong guo windows suo ti gong de api han shu lai shi xian ge zhong cao zuo de , zhe xie han shu tong chang shi ke yi zhi jie shi yong de , zhi yao bao han windows.h zhe ge tou wen jian 。
  jin tian wo men zhu yao jie shao de shi ji ge chang yong de api han shu , tong guo ta wo men ke yi huo qu yong hu ci pan de xiang guan xin xi 。
  shi li cheng xu : qing dian ji fu jian xia zai 。
C++通过WIN32 API获取逻辑磁盘详细信息

  qi zhu yao han shu yuan xing shuo ming ru xia :
  1. huo qu xi tong zhong luo ji qu dong qi de shu liang
  The GetLogicalDrives function retrieves a bitmask rePResenting the currently available disk drives.
  DWord GetLogicalDrives(void);
  2. huo qu suo you qu dong qi zi fu chuan xin xi
  The GetLogicalDriveStrings function fills a buffer with strings that specify valid drives in the system.
  DWORD GetLogicalDriveStrings(
  DWORD nBufferLength,
  LPTSTR lpBuffer
  );
  3. huo qu qu dong qi lei xing
  The GetDriveType function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive.
  UINT GetDriveType(
  LPCTSTR lpRootPathName
  );
  4. huo qu qu dong qi ci pan de kong jian zhuang tai , han shu fan hui de shi ge BOOL lei xing shu ju
  The GetDiskFreeSpaceEx function retrieves information about the amount of space available on a disk volume: the total amount of space, the total amount of free space, and the total amount of free space available to the user associated with the calling thread.
  BOOL GetDiskFreeSpaceEx(
  LPCTSTR lpDirectoryName,
  PULARGE_INTEGER lpFreeBytesAvailable,
  PULARGE_INTEGER lpTotalNumberOfBytes,
  PULARGE_INTEGER lpTotalNumberOfFreeBytes
  );
  yi xia shi wan zheng de shi li cheng xu dai ma :
C++通过WIN32 API获取逻辑磁盘详细信息
geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo
  #include <iostream>
  #include <windows.h>
  using namespace std;
  int main()
  {
   int DiskCount = 0;
   DWORD DiSKINfo = GetLogicalDrives();
   // li yong GetLogicalDrives() han shu ke yi huo qu xi tong zhong luo ji qu dong qi de shu liang , han shu fan hui de shi yi ge 32 wei wu fu hao zheng xing shu ju 。
   while(DiskInfo)// tong guo xun huan cao zuo cha kan mei yi wei shu ju shi fou wei 1, jia ru wei 1 ze ci pan wei zhen , jia ru wei 0 ze ci pan bu cun zai 。
   {
   if(DiskInfo&1)// tong guo wei yun suan de luo ji yu cao zuo , pan ding shi fou wei 1
   {
   ++DiskCount;
  
   }
   DiskInfo = DiskInfo >> 1;// tong guo wei yun suan de you yi cao zuo bao zheng mei xun huan yi ci suo jian cha de wei zhi xiang you yi dong yi wei 。
   //DiskInfo = DiskInfo/2;
   }
   cout<<" luo ji ci pan shu liang :"<<DiskCount<<endl;
  //-------------------------------------------------------------------
   int DSLength = GetLogicalDriveStrings(0,NULL);
   // tong guo GetLogicalDriveStrings() han shu huo qu suo you qu dong qi zi fu chuan xin xi chang du 。
   char* DStr = new char[DSLength];// yong huo qu de chang du zai dui qu chuang jian yi ge c feng ge de zi fu chuan shu zu
   GetLogicalDriveStrings(DSLength,(LPTSTR)DStr);
   // tong guo GetLogicalDriveStrings jiang zi fu chuan xin xi fu zhi dao dui qu shu zu zhong , qi zhong bao cun le suo you qu dong qi de xin xi 。
   int DType;
   int si=0;
   BOOL fResult;
   unsigned _int64 i64FreeBytesToCaller;
   unsigned _int64 i64TotalBytes;
   unsigned _int64 i64FreeBytes;
   for(int i=0;i<DSLength/4;++i)
   // wei le xian shi mei ge qu dong qi de zhuang tai , ze tong guo xun huan shu chu shi xian , you yu DStr nei bu bao cun de shu ju shi A:\NULLB:\NULLC:\NULL, zhe yang de xin xi , suo yi DSLength/4 ke yi huo de ju ti da xun huan fan wei
   {
   char dir[3]={DStr[si],':','\\'};
   cout<<dir;
   DType = GetDriveType(DStr+i*4);
   //GetDriveType han shu , ke yi huo qu qu dong qi lei xing , shen shu wei qu dong qi de gen mu lu
   if(DType == DRIVE_FIXED)
   {
   cout<<" ying pan ";
   }
   else if(DType == DRIVE_CDROM)
   {
   cout<<" guang qu ";
   }
   else if(DType == DRIVE_REMOVABLE)
   {
   cout<<" ke yi dong shi ci pan ";
   }
   else if(DType == DRIVE_REMOTE)
   {
   cout<<" wang luo ci pan ";
   }
   else if(DType == DRIVE_RAMDISK)
   {
  
   cout<<" xu ni RAM ci pan ";
   }
   else if (DType == DRIVE_UNKNOWN)
   {
   cout<<" wei zhi she bei ";
   }
   fResult = GetDiskFreeSpaceEx (
   dir,
   (PULARGE_INTEGER)&i64FreeBytesToCaller,
   (PULARGE_INTEGER)&i64TotalBytes,
   (PULARGE_INTEGER)&i64FreeBytes);
   //GetDiskFreeSpaceEx han shu , ke yi huo qu qu dong qi ci pan de kong jian zhuang tai , han shu fan hui de shi ge BOOL lei xing shu ju
   if(fResult)// tong guo fan hui de BOOL shu ju pan ding qu dong qi shi fou zai gong zuo zhuang tai
   {
   cout<<" totalspace:"<<(float)i64TotalBytes/1024/1024<<" MB";// ci pan zong rong liang
   cout<<" freespace:"<<(float)i64FreeBytesToCaller/1024/1024<<" MB";// ci pan sheng yu kong jian
   }
   else
   {
   cout<<" she bei wei yu bei hao ";
   }
   cout<<endl;
   si+=4;
   }
   system("pause");
  }
  WIN API han shu zuo wei windows cao zuo xi tong huan jing xia bian cheng de jie kou , zai qi ta yu yan , li ru VB VB.NET C# Delphi zhong shi yong de shi hou cao zuo de fang fa ye shi cha bu duo de , ju ti ke yi shen kao xiang guan yu yan de shu ji 。【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
zhong suo zhou zhi , zai wei ruan de cao zuo xi tong xia bian xie ying yong cheng xu , zui zhu yao de huan shi tong guo windows suo ti gong de api han shu lai shi xian ge zhong cao zuo de , zhe xie han shu tong chang shi ke yi zhi jie shi yong de , zhi yao bao han windows.h zhe ge tou wen jian 。    jin tian wo men zhu yao jie shao de shi ji ge chang yong de api han shu , tong guo ta wo men ke yi huo qu yong hu ci pan de xiang guan xin xi 。    shi li cheng xu : qing dian ji fu jian xia zai 。 [url=http://www.wangchao.net.cn/bbs/pydetail_1785384.html][img]http://image.wangchao.net.cn/it/1323423631038.gif[/img][/url]    qi zhu yao han shu yuan xing shuo ming ru xia :   1. huo qu xi tong zhong luo ji qu dong qi de shu liang The GetLogicalDrives function retrieves a bitmask rePResenting the currently available disk drives. DWord GetLogicalDrives(void);   2. huo qu suo you qu dong qi zi fu chuan xin xi The GetLogicalDriveStrings function fills a buffer with strings that specify valid drives in the system. DWORD GetLogicalDriveStrings( DWORD nBufferLength, LPTSTR lpBuffer );   3. huo qu qu dong qi lei xing The GetDriveType function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive. UINT GetDriveType( LPCTSTR lpRootPathName );   4. huo qu qu dong qi ci pan de kong jian zhuang tai , han shu fan hui de shi ge BOOL lei xing shu ju The GetDiskFreeSpaceEx function retrieves information about the amount of space available on a disk volume: the total amount of space, the total amount of free space, and the total amount of free space available to the user associated with the calling thread. BOOL GetDiskFreeSpaceEx( LPCTSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailable, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes );    yi xia shi wan zheng de shi li cheng xu dai ma : [url=http://www.wangchao.net.cn/bbs/pydetail_1785384.html][img]http://image.wangchao.net.cn/it/1323423631421.gif[/img][/url] geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo #include <iostream> #include <windows.h> using namespace std; int main() { int DiskCount = 0; DWORD DiSKINfo = GetLogicalDrives(); // li yong GetLogicalDrives() han shu ke yi huo qu xi tong zhong luo ji qu dong qi de shu liang , han shu fan hui de shi yi ge 32 wei wu fu hao zheng xing shu ju 。 while(DiskInfo)// tong guo xun huan cao zuo cha kan mei yi wei shu ju shi fou wei 1, jia ru wei 1 ze ci pan wei zhen , jia ru wei 0 ze ci pan bu cun zai 。 { if(DiskInfo&1)// tong guo wei yun suan de luo ji yu cao zuo , pan ding shi fou wei 1 { ++DiskCount; } DiskInfo = DiskInfo >> 1;// tong guo wei yun suan de you yi cao zuo bao zheng mei xun huan yi ci suo jian cha de wei zhi xiang you yi dong yi wei 。 //DiskInfo = DiskInfo/2; } cout<<" luo ji ci pan shu liang :"<<DiskCount<<endl; //------------------------------------------------------------------- int DSLength = GetLogicalDriveStrings(0,NULL); // tong guo GetLogicalDriveStrings() han shu huo qu suo you qu dong qi zi fu chuan xin xi chang du 。 char* DStr = new char[DSLength];// yong huo qu de chang du zai dui qu chuang jian yi ge c feng ge de zi fu chuan shu zu GetLogicalDriveStrings(DSLength,(LPTSTR)DStr); // tong guo GetLogicalDriveStrings jiang zi fu chuan xin xi fu zhi dao dui qu shu zu zhong , qi zhong bao cun le suo you qu dong qi de xin xi 。 int DType; int si=0; BOOL fResult; unsigned _int64 i64FreeBytesToCaller; unsigned _int64 i64TotalBytes; unsigned _int64 i64FreeBytes; for(int i=0;i<DSLength/4;++i) // wei le xian shi mei ge qu dong qi de zhuang tai , ze tong guo xun huan shu chu shi xian , you yu DStr nei bu bao cun de shu ju shi A:\NULLB:\NULLC:\NULL, zhe yang de xin xi , suo yi DSLength/4 ke yi huo de ju ti da xun huan fan wei { char dir[3]={DStr[si],':','\\'}; cout<<dir; DType = GetDriveType(DStr+i*4); //GetDriveType han shu , ke yi huo qu qu dong qi lei xing , shen shu wei qu dong qi de gen mu lu if(DType == DRIVE_FIXED) { cout<<" ying pan "; } else if(DType == DRIVE_CDROM) { cout<<" guang qu "; } else if(DType == DRIVE_REMOVABLE) { cout<<" ke yi dong shi ci pan "; } else if(DType == DRIVE_REMOTE) { cout<<" wang luo ci pan "; } else if(DType == DRIVE_RAMDISK) { cout<<" xu ni RAM ci pan "; } else if (DType == DRIVE_UNKNOWN) { cout<<" wei zhi she bei "; } fResult = GetDiskFreeSpaceEx ( dir, (PULARGE_INTEGER)&i64FreeBytesToCaller, (PULARGE_INTEGER)&i64TotalBytes, (PULARGE_INTEGER)&i64FreeBytes); //GetDiskFreeSpaceEx han shu , ke yi huo qu qu dong qi ci pan de kong jian zhuang tai , han shu fan hui de shi ge BOOL lei xing shu ju if(fResult)// tong guo fan hui de BOOL shu ju pan ding qu dong qi shi fou zai gong zuo zhuang tai { cout<<" totalspace:"<<(float)i64TotalBytes/1024/1024<<" MB";// ci pan zong rong liang cout<<" freespace:"<<(float)i64FreeBytesToCaller/1024/1024<<" MB";// ci pan sheng yu kong jian } else { cout<<" she bei wei yu bei hao "; } cout<<endl; si+=4; } system("pause"); }   WIN API han shu zuo wei windows cao zuo xi tong huan jing xia bian cheng de jie kou , zai qi ta yu yan , li ru VB VB.NET C# Delphi zhong shi yong de shi hou cao zuo de fang fa ye shi cha bu duo de , ju ti ke yi shen kao xiang guan yu yan de shu ji 。
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
时尚秀气模特裴裴(8)
时尚秀气模特裴裴(7)
时尚秀气模特裴裴(6)
时尚秀气模特裴裴(5)
白墙黑瓦
广州东郊[原创]
八美至丹巴的东谷天然盆景
不一样的
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有