我正在尝试读取PC的COM端口的地址。我需要知道使用哪一个,我想这个程序应该对我很有帮助。但似乎我无法从内存中读取该地址,为什么?
void main(void)
{
unsigned int *ptraddr =nullptr; /* Pointer to location of Port Addresses */
unsigned int address =0; /* Address of Port */
int a=0;
ptraddr=(unsigned int*)0x00000402;
for (a = 0; a < 4; a++)
{
address = *ptraddr;
if (address == 0)
printf("No port found for COM%d \n",a+1);
else
printf("Address assigned to COM%d is %Xh\n",a+1,address);
*ptraddr++;
}
}
答案 0 :(得分:0)
正如Joachim所说,由于你有权直接访问这样的外围设备,所以已经很久了。请看一下本教程: