怎样用CreateFile()ReadFile()WriteFile()来读写cmos ()

chenqsbeast 2003-06-11 02:57:22
如题
...全文
87 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
czj69 2003-06-27
  • 打赏
  • 举报
回复
呀,正好,被我找到了,请问用winio的高手们,如下是我发在其它版下的问题
我实在搞不定了,帮帮忙啊!!!

“不知道大家有没有用winio driver去在2000,xp下读过系统的I/O端口,现在我有
有一很大的问题,即这个winio.sys winio.dll 无法reload ,即,如果我有二个
程序同时去调用这个winio driver 就会有冲突,或无法正确的对I/O端口读写,
请问如何解决?难道要我自己写一个driver 吗?我可写不出啊!!! ”
chenqsbeast 2003-06-12
  • 打赏
  • 举报
回复
to :AthlonxpX86(一滴水)
winio中有些函数不能在2000里用,比如_outp(_ip)都不能用,所以我才想用CreateFile()ReadFile()WriteFile()
commandos 2003-06-12
  • 打赏
  • 举报
回复
up
AthlonxpX86 2003-06-12
  • 打赏
  • 举报
回复
MSN是什么啊,我不太会用,有QQ吗?我QQ上告诉你吧
我的QQ176156000
chenqsbeast 2003-06-12
  • 打赏
  • 举报
回复
to :AthlonxpX86(一滴水)
我的msn 是chenqs@gw.com.cn
chenqsbeast 2003-06-12
  • 打赏
  • 举报
回复
to :AthlonxpX86(一滴水)
确实我没用过winio,能够给以点源代码来看看嘛?我可以用我写的源代码来交换!
或者给以点提示也可以!
AthlonxpX86 2003-06-12
  • 打赏
  • 举报
回复
上面是所有winio的函数说明,我看过winio的源代码,如果你说winio不行,那2000下面就没有别的办法了
AthlonxpX86 2003-06-12
  • 打赏
  • 举报
回复
InitializeWinIo
This function initializes the WinIo library.

bool _stdcall InitializeWinIo();
Parameters
None
Return Values
If the function succeeds, the return value is true. Otherwise, the function returns false.
Remarks
The InitializeWinIo function must be called before using any other function in the library.

Note:

There is no need to invoke the InitializeWinIo function before calling the InstallWinIoDriver and RemoveWinIoDriver functions.
Under Windows NT/2000/XP, calling InitializeWinIo grants the application full access to the I/O address space. Following a call to this function, an application is free to use the _inp/_outp functions provided by the C run-time library to access I/O ports on the system.


ShutdownWinIo
This function performs cleanup of the WinIo library.

void _stdcall ShutdownWinIo();
Parameters
None
Return Values
None
Remarks
The ShutdownWinIo function must be called before terminating the application or in case the WinIo library is no longer required. This function shuts down the WinIo library and frees the resources which were allocated by a call to the InitializeWinIo function.

InstallWinIoDriver
This function installs the WinIo driver.

bool _stdcall InstallWinIoDriver(
PSTR pszWinIoDriverPath,
bool IsDemandLoaded
);
Parameters
pszWinIoDriverPath
[in] Pointer to a null-terminated string that specifies the path to the winio.sys driver.

IsDemandLoaded
[in] This parameter must be set to false.
Return Values
If the function succeeds, the return value is true. Otherwise, the function returns false.
Remarks
The InstallWinIoDriver function installs the WinIo driver and configures it to load automatically when Windows starts. This function fails if called from a non-administrative account.


RemoveWinIoDriver
This function removes the WinIo driver from the system.

bool _stdcall RemoveWinIoDriver();
Parameters
None
Return Values
If the function succeeds, the return value is true. Otherwise, the function returns false.
Remarks
The RemoveWinIoDriver function removes the WinIo driver. This function fails if called from a non-administrative account.





GetPortVal
This function reads a BYTE/WORD/DWORD value from an I/O port.

bool _stdcall GetPortVal(
WORD wPortAddr,
PDWORD pdwPortVal,
BYTE bSize
);
Parameters
wPortAddr
[in] I/O port address

pdwPortVal
[out] Pointer to a DWORD variable that receives the value obtained from the port.

bSize
[in] Number of bytes to read.
Can be 1 (BYTE), 2 (WORD) or 4 (DWORD).
Return Values
If the function succeeds, the return value is true. Otherwise, the function returns false.
Remarks
The GetPortVal function reads a byte, a word or a double word from the specified I/O port.

Note: 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.




SetPortVal
This function writes a BYTE/WORD/DWORD value to an I/O port.

bool _stdcall SetPortVal(
WORD wPortAddr,
DWORD dwPortVal,
BYTE bSize
);
Parameters
wPortAddr
[in] I/O port address

dwPortVal
[in] Value to be written to the port

bSize
[in] Number of bytes to write.
Can be 1 (BYTE), 2 (WORD) or 4 (DWORD).
Return Values
If the function succeeds, the return value is true. Otherwise, the function returns false.
Remarks
The SetPortVal function writes a byte, a word or a double word to the specified I/O port.

Note: Under Windows 98/ME, an application must use the SetPortVal function to write values to an I/O port. Under Windows NT/2000/XP, it is possible to use the _outp/_outpw/_outpd functions instead of using SetPortVal, provided that the InitializeWinIo function has been called beforehand.





GetPhysLong
This function reads a double word from the specified physical memory location.

bool _stdcall GetPhysLong(
PBYTE pbPhysAddr,
PDWORD pdwPhysVal
);
Parameters
pbPhysAddr
[in] Pointer to the physical address

pdwPhysVal
[out] Pointer to a DWORD variable that receives the value obtained from the physical memory location.
Return Values
If the function succeeds, the return value is true. Otherwise, the function returns false.
Remarks
The GetPhysLong function reads a double word from the specified physical memory location.



SetPhysLong
This function writes a double word to the specified physical memory location.

bool _stdcall SetPhysLong(
PBYTE pbPhysAddr,
DWORD dwPhysVal
);
Parameters
pbPhysAddr
[in] Pointer to the physical address

dwPhysVal
[in] Specifies a DWORD value to be written to the physical memory location.
Return Values
If the function succeeds, the return value is true. Otherwise, the function returns false.
Remarks
The SetPhysLong function writes a double word to the specified physical memory location.



MapPhysToLin
This function maps a region of physical memory into the linear address space of the application.

PBYTE _stdcall MapPhysToLin(
PBYTE pbPhysAddr,
DWORD dwPhysSize,
HANDLE *pPhysicalMemoryHandle
);
Parameters
pbPhysAddr
[in] Pointer to the physical address

dwPhysSize
[in] Number of bytes to map

pPhysicalMemoryHandle
[out] Points to a variable that will receive the physical memory section handle if this call is successful. This handle should be used as the first parameter when calling the UnmapPhysicalMemory function.
Return Values
If the function succeeds, the return value is the linear address corresponding to the physical address that was passed in pbPhysAddr. Otherwise, the return value is NULL.
Remarks
The MapPhysToLin function maps a region of physical memory into the linear address space of the calling application.




UnmapPhysicalMemory
This function unmaps a region of physical memory which was previously mapped to the linear address space of the application using the MapPhysToLin function.

bool _stdcall UnmapPhysicalMemory(
HANDLE PhysicalMemoryHandle,
PBYTE pbLinAddr
);
Parameters
PhysicalMemoryHandle
[in] Handle to the physical memory section which was returned from the call to the MapPhysToLin function.

pbLinAddr
[in] Linear address which was returned from the call to the MapPhysToLin function.
Return Values
If the function succeeds, the return value is true. Otherwise, the function returns false.
Remarks
The UnmapPhysicalMemory function unmaps a region of physical memory which was previously mapped to the linear address space of the application using the MapPhysToLin function.

Note: Windows 98/ME applications are not required to call this function.


AthlonxpX86 2003-06-12
  • 打赏
  • 举报
回复
你不会不会用winio啊,我的好多程序都用winio,还有winio中根本没有_outp这个函数?你在哪里找的winio????看看说明
AthlonxpX86 2003-06-11
  • 打赏
  • 举报
回复
daphant说的对,你应该先写驱动程序,CreateFile()ReadFile()WriteFile()其实就是操作驱动程序,如果你觉的太难,就用winio吧
NowCan 2003-06-11
  • 打赏
  • 举报
回复
没听说过。
daphant 2003-06-11
  • 打赏
  • 举报
回复
这些api实际上是调用驱动程序的,你可以写一个驱动去操作coms,在就可以用这些api调用你的驱动去实现相应的功能了
AthlonxpX86 2003-06-11
  • 打赏
  • 举报
回复
应该不行吧CreateFile()ReadFile()WriteFile()必须有想赢得是被才可以,CMOS应该不能算是一个设备吧

2,640

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 硬件/系统
社区管理员
  • 硬件/系统社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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