SDK编程获取硬盘序列号

         最近硬盘问题总是不断,拿去换了几个每次都说是新的结果一用就出问题...妈的奸商居然奸到我头上了,于是写个查ID的工具,看看还出问题还说换新的是不是给我新的!-_-#!!
          代码基本上是网上抄得-_-#,结构太复杂,所以只能是边参考边敲代码了
          主程序代码:
#include  < stdio.h >
#include 
< stdlib.h >
#include 
< string .h >
#include 
< iostream.h >
#include 
< windows.h >  
#include 
" HardID.h "  

void  CopyRight()
{
    cout
<<"/**************************************"<<" "
        
<<"         HardDisk ID GetClass          "<<" "
        
<<"     Writen By Red_angelX 2007.3.23    "<<" "
        
<<"**************************************/"<<endl;
}


char *  ConvertToString(DWORD diskdata [ 256 ],  int  firstIndex,  int  lastIndex)
{
   
static char string [1024];
   
int index = 0;
   
int position = 0;

      
//  each integer has two characters stored in it backwards
   for (index = firstIndex; index <= lastIndex; index++)
   
{
         
//  get high byte for 1st character
      string [position] = (char) (diskdata [index] / 256);
      position
++;

         
//  get low byte for 2nd character
      string [position] = (char) (diskdata [index] % 256);
      position
++;
   }

      
//  end the string 
   string [position] = '';

      
//  cut off the trailing blanks
   for (index = position - 1; index > 0 && ' ' == string [index]; index--)
      
string [index] = '';
   
return string;
}


// Print Out The Result
void  PrintInfo( int  drive,DWORD diskdata[ 256 ])
{
    
char string1 [1024];
    __int64 sectors 
= 0;
    
int bytes = 0;

    cout
<<"Drive"<<drive<<" : "<<ConvertToString(diskdata, 2746)<<endl;

    cout
<<"Serial Number : "<<ConvertToString (diskdata, 1019)<<endl;

    cout
<<"Revision Number :"<<ConvertToString (diskdata, 2326)<<endl;
    
char* str_HardDesk_Form = new char[256];
    
switch (drive / 2)
    
{
      
case 0: str_HardDesk_Form ="Primary Controller";
              
break;
      
case 1: str_HardDesk_Form 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值