找到了个C源程序,读取硬盘序列号,但我用TC2编译出错。
错误提示为: undefined symbol ‘_inpw’ in module hd1.c
是不是TC2里CONIO.H里没有INPW这个函数?
(我没入门请大侠帮忙。。。)
++++++++++++++我已经搞明白了,TC2没这函数,TC3有+++++++++
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <conio.h>
#include <string.h>
char *getascii (unsigned int in_data , int off_start, int off_end);
void main (void)
{
unsigned int dd [256]; /* DiskData /
unsigned int dd_off; / DiskData offset */
while (inp (0x1F7) != 0x50) /* Wait for controller not busy */
;
outp (0x1F6, 0xA0); /* Get first/second drive */
outp (0x1F7, 0xEC); /* Get drive info data */
while (inp (0x1F7) != 0x58) /* Wait for data ready */
;
for (dd_off = 0; dd_off != 256; dd_off++) /* Read “sector” */
dd [dd_off] = inpw (0x1F0);
printf (“The Serial Number Hard Disk [C] is %s”, getascii (dd, 10, 19));
}
char *getascii (unsigned int in_data , int off_start, int off_end)
{
static char ret_val [255];
int loop, loop1;
for (loop = off_start, loop1 = 0; loop <= off_end; loop++)
{
ret_val [loop1++] = (char) (in_data [loop] / 256); /* Get High byte /
ret_val [loop1++] = (char) (in_data [loop] % 256); / Get Low byte /
}
/ ret_val [loop1] = “”; /* Make sure it ends in a NULL character */
return (ret_val);
}