首先下载winio库,查看readme在vc++下使用,参考写了个0x70读cmos和0x61控制speaker
void io_init()
{
DWORD dwPortVal;
DWORD dwPortVal2;
DWORD dwMemVal;
char port[128];
char mem[128];
char test[128];
bool bResult;
HANDLE hPhysicalMemory;
PBYTE pbLinAddr;
// Call InitializeWinIo to initialize the WinIo library.
bResult = InitializeWinIo();
if (bResult)
{
// Under Windows NT/2000/XP, after calling InitializeWinIo,
// you can call _inp/_outp instead of using GetPortVal/SetPortVal
OnReadCmos();
OnSpeakerSound();
// Map physical addresses 0xA0000 - 0xAFFFF into the linear address space
// of the application. The value returned from the call to MapPhysToLin is
// a linear address corresponding to physical address 0xA0000. In case of
// an error, the return value is NULL.
pb