有没有这样的函数?

解决方案 »

  1.   

    http://wlbookwl.myrice.com/jck/1031ypxl.htm
      

  2.   

    DOS4.0 以 上 的 版 本, 在 磁 盘 格 式 化 时 给 磁 盘 设 置 了 一 个 卷 系 列 号, 即 磁 盘ID, 用 作 磁 盘 的 标 识 信 息, 使 用dir 命 令 可 以 显 示 卷 系 列 号: ----Volume in drive C is KSW100 ----Volume Serial Number is 4160 -9FE5 ----... ----其 中 开 始 的 第 二 行 为 卷 系 列 号 显 示。 DOS 利 用 卷 系 列 号 与 驱 动 器 上 的 磁 盘 保 持 联 系, 如 果 你 用 过 Win95( 或Win98) 就 会 有 感 受, 当 你 在 使 用 某 一 张 软 磁 盘 或 光 盘 时, 你 将 其 取 走 或 是 换 了 一 张 盘,Windows 要 使 用 该 盘 时 就 会 叫 你 插 入 序 列 号 为 × × × × - × × × × 的 磁 盘, 或 者 在 读 光 盘 出 错 时 也 会 显 示 此 信 息。 ----由 于format 命 令 格 式 化 磁 盘 时 生 成 的 卷 系 列 号 是 一 固 定 格 式 的 随 机 数, 两 次 格 式 化 生 成 的 卷 系 列 号 相 同 的 几 率 几 乎 为 零, 因 此 一 些 商 业 软 件 或 共 享 软 件 经 常 利 用 卷 系 列 号 进 行 软 件 加 密。 比 如, 某 些 共 享 软 件 要 求 你 用C 盘 的 序 列 号 到 他 们 的 互 连 网 主 页 上 去 申 请 软 件 的 授 权 号 或 许 可 证, 有 了 授 权 号 你 才 能 安 装 该 软 件 或 是 获 得 许 可 证 后 你 才 能 使 用 该 软 件 的 所 有 功 能( 通 常 被 禁 止 的 功 能 也 是 最 关 键 的 功 能)。 如 果 你 要 将 该 软 件 安 装 于 多 台 微 机 上, 就 得 为 每 一 台 微 机 申 请 一 个 授 权 号 或 许 可 证, 或 是 你 重 新 格 式 化 硬 盘 后, 也 得 重 新 去 申 请 授 权 号 或 许 可 证。 ----那 么, 磁 盘 序 列 号 可 不 可 以 修 改 呢 ? ----DOS 的INT 21H 中 断 的69H 功 能 号 为 我 们 提 供 了 这 样 一 个 功 能, 其 入、 出 口 参 数 如 下:  ----用C 语 言 的DOS 功 能 调 用 函 数dosx() 可 以 方 便 地 取 或 置 磁 盘ID 号, 用Turbo C 2.0 写 的 源 程 序 如 下: #include<stdio.h> 
    #include<conio.h> 
    #include<dos.h> 
    #include<ctype.h> 
    main() 
    {int i,j; 
     union REGS regs; struct SREGS sregs; 
     unsigned char ch,tp[8],id[6]; 
     clrscr(); 
     printf(“\n\nPlease select one operation!"); 
     printf(“\n  0--Get disk ID 
     1--Set disk ID\n"); 
     ch=getch(); 
     if(ch==27) return 0; 
     printf(“\nPlease select one disk to operate."); 
     printf(“\n  0--Current disk  
     1--disk A 2--disk B 3--disk  
    C  ...\n"); 
     j=getch()-48; 
     if(ch==49) 
    {printf(“\nPlease enter eight  
    HEX numerals(such as 1f23e35b):"); 
    /*下面这一段程序是将输入的字符串转化成相应的 
    十六进制数(四字节)*/ 
       scanf(“%s",tp); 
       for(i=0;i<8;i++) 
          if(isalpha(tp[i])) 
            { tp[i]=tolower(tp[i]); 
             tp[i]=tp[i]-87; 
            } 
          else tp[i]=tp[i]-48; 
       id[5]=tp[0]*16+tp[1]; id[4]=tp[2]*16+tp[3]; 
       id[3]=tp[4]*16+tp[5]; id[2]=tp[6]*16+tp[7]; 
       /*-------------*/ 
       regs.h.ah=0x69; regs.h.al=0x01; 
       regs.h.bl=j; 
       regs.x.dx=FP_OFF(id); 
       sregs.ds=FP_SEG(id); 
       intdosx(&regs,&regs,&sregs); 
       if(regs.x.cflag==0)  
       printf(“This operation is successful!"); 
       } 
     else 
      {regs.h.ah=0x69; 
       regs.h.al=0x00; 
       regs.h.bl=j; 
       regs.x.dx=FP_OFF(id); 
       sregs.ds=FP_SEG(id); 
       intdosx(&regs,&regs,&sregs); 
       if(regs.x.cflag==0) 
       {printf(“\nThis disk ID is "); 
       printf(“%x%x-%x%x\n", 
       id[5],id[4],id[3],id[2]); 
          } 
       else printf(“\nTo get ID is failure.\n"); 
      } 
     return 0; 
    }  
     
     
     
     
      

  3.   

    GetVolumeInformation
    The GetVolumeInformation function returns information about a file system and volume whose root directory is specified. BOOL GetVolumeInformation(
      LPCTSTR lpRootPathName,        // address of root directory of the 
                                     // file system
      LPTSTR lpVolumeNameBuffer,     // address of name of the volume
      DWORD nVolumeNameSize,         // length of lpVolumeNameBuffer
      LPDWORD lpVolumeSerialNumber,  // address of volume serial number 此为序列号
      LPDWORD lpMaximumComponentLength,
                                     // address of system's maximum 
                                     // filename length
      LPDWORD lpFileSystemFlags,     // address of file system flags
      LPTSTR lpFileSystemNameBuffer, // address of name of file system
      DWORD nFileSystemNameSize      // length of lpFileSystemNameBuffer
    );