求助,为什么返回值总是0

yugehalo 2007-04-19 11:38:10
这是一段获取cpu温度的代码,可是为什么返回值总是0?
请高人指点,拜谢
#include "stdafx.h"

#include <windows.h>
#include "WinIo.h"

#pragma comment(lib,"WinIo.lib")


int _tmain(int argc, _TCHAR* argv[])

{

DWORD temp_dwPortVal=0;
InitializeWinIo();
SetPortVal(0x6C,0x80,1);//将命令写入命令端口0x6C
SetPortVal(0x68,0x0E7,1);//将要访问的寄存器号写入数据端口0x68
GetPortVal(0x68,&temp_dwPortVal, 4);//将数据从数据端口读出
printf("%d",temp_dwPortVal);


}
...全文
510 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
yugehalo 2007-04-26
  • 打赏
  • 举报
回复
不知道是不是因为不同的系统要用不同的参数呢
yugehalo 2007-04-19
  • 打赏
  • 举报
回复
那个地方改了也是一样,还是返回0
pass86 2007-04-19
  • 打赏
  • 举报
回复
要求很COOL,偶以为有现成的API呢?原来还是要考技术啊。学习。关注。
iu_81 2007-04-19
  • 打赏
  • 举报
回复
GetPortVal(0x68,&temp_dwPortVal, 1);//
yugehalo 2007-04-19
  • 打赏
  • 举报
回复
最好能帮我指出来为什么会失败
我是按照说明写的。。。。。
iu_81 2007-04-19
  • 打赏
  • 举报
回复
bool _stdcall GetPortVal(WORD wPortAddr, PDWORD pdwPortVal, BYTE bSize);

Use this function to read a BYTE/WORD/DWORD value from an I/O port.

Parameters:

wPortAddr - I/O port address

pdwPortVal - Pointer to a DWORD variable that receives the value
obtained from the port.

bSize - Number of bytes to read.
Can be 1 (BYTE), 2 (WORD) or 4 (DWORD).

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero
yugehalo 2007-04-19
  • 打赏
  • 举报
回复
"没有WinIo.h啊"
有啊 那个不是问题了
ouyh12345 2007-04-19
  • 打赏
  • 举报
回复
有没有提供demo?
demo里能得到温度吗?
thinkinnight 2007-04-19
  • 打赏
  • 举报
回复
没有WinIo.h啊
FingerStyle 2007-04-19
  • 打赏
  • 举报
回复
...
yugehalo 2007-04-19
  • 打赏
  • 举报
回复
再winxp里能用_inp/_inpw/_inpd吗?怎么用呢 有谁能给个完整点的例子?谢谢了
iu_81 2007-04-19
  • 打赏
  • 举报
回复
Under Windows 98/ME, an application must use the GetPortVal function to read values from an I/O port. Under Windows NT/2000/XP, it is possible to use the _inp/_inpw/_inpd functions instead of using GetPortVal, provided that the InitializeWinIo function has been called beforehand.
iu_81 2007-04-19
  • 打赏
  • 举报
回复
Direct Hardware Access Under Windows 9x/NT/2000

65,213

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧