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. Res 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. 看明白了没有啊!!! 因为你的系统根本就没有安装上winio,所以你是需要先调用InstallWinIoDriver函数的。当然你一旦曾经调用了这个函数,以后就即使不要InstallWinIoDriver函数调用,程序也不会出现你现在出现的问题了。你自己在程序里把这个函数加上就可以了。 做事情的时候一定不要盲目,要认真的看说明
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. Res 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. 知道是怎么回事了吗?不管怎样都需要有那么一次 InstallWinIoDriver函数调用才行的啊。 明白怎么做了吧
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.
Res
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.
看明白了没有啊!!!
因为你的系统根本就没有安装上winio,所以你是需要先调用InstallWinIoDriver函数的。当然你一旦曾经调用了这个函数,以后就即使不要InstallWinIoDriver函数调用,程序也不会出现你现在出现的问题了。你自己在程序里把这个函数加上就可以了。
做事情的时候一定不要盲目,要认真的看说明
解决方法时把winio.dll和winio.syscopy到VB编译执行(F5)时,程序运行的实际目录(我肯定和编译后运行不同,但具体是哪里我不知道,也许可以用app.path看看)
{
PSTR pszSlash; if (!GetModuleFileName(GetModuleHandle(NULL), szWinIoDriverPath, sizeof(szWinIoDriverPath)))
return false;
从这里可以看出,winio.sys必须处于和应用程序相同的目录里,但VB中F5运行时,目录是?
pszSlash = strrchr(szWinIoDriverPath, '\\'); if (pszSlash)
pszSlash[1] = 0;
else
return false; strcat(szWinIoDriverPath, "winio.sys"); return true;
}
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.
Res
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.
知道是怎么回事了吗?不管怎样都需要有那么一次 InstallWinIoDriver函数调用才行的啊。
明白怎么做了吧
我认为StdAfx(任杰)说的没道理,那个例子程序里确实每次都调用了那个函数的。
if (!GetModuleFileName(GetModuleHandle(NULL), szWinIoDriverPath, sizeof(szWinIoDriverPath)))
这是那个DLL源代码中的一部分。
我在FormLoad里加上相应的代码,可以看到按F5调试时,路径和编译后运行是不一样的。
解决方法是把winio.sys复制到c:\Program Files\Microsoft Visual Studio\vb98里。