http://www.internals.com/utilities/winio.zip下载后,打开例子中的vb程序,当使用源程序编译执行时,会报“InitializeWinIo出错”,当使用源程序生成的exe后,执行该源程序,就不会报出错误,这是什么原因造成的,能否能解释解决。我的系统是2000server,administrator

解决方案 »

  1.   

    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函数调用,程序也不会出现你现在出现的问题了。你自己在程序里把这个函数加上就可以了。
    做事情的时候一定不要盲目,要认真的看说明
      

  2.   

    我猜测一下,可能是因为VB编译执行(F5)时,程序运行的目录下没有winio.sys,这时会出现你说得那个错误。
      

  3.   

    可能性很大,我看了一下,那个例子在Close的时候调用了ShutdownWinIo,而这里会删除已经安装的驱动程序。
    解决方法时把winio.dll和winio.syscopy到VB编译执行(F5)时,程序运行的实际目录(我肯定和编译后运行不同,但具体是哪里我不知道,也许可以用app.path看看)
      

  4.   

    bool GetDriverPath()
    {
      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;
    }
      

  5.   

    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函数调用才行的啊。
    明白怎么做了吧
      

  6.   

    也就是说你现在根本就没有安装上winio驱动,所以你需要先调用InstallWinIoDriver把它安装上,当然安装好了后你就可以不再需要InstallWinIoDriver函数了。
      

  7.   

    NowCan(能量、激情、雨水、彩虹——雷雨云)兄:你是否调试过?若当前目录下没有该winio.dll和winio.sys,并且该dll也不存在系统目录system32中,则源程序调试时,会报找不到该dll文件而造成无法编译错误,所以你的说法好像不是太准确
      

  8.   

    StdAfx(任杰) 兄:为什么我运行编译好的exe文件就不存在上述问题呢?
      

  9.   

    我就是没有VB无法调试才说是猜测。我回去试试看。
    我认为StdAfx(任杰)说的没道理,那个例子程序里确实每次都调用了那个函数的。
      

  10.   

    证实了。就是我说的问题。
    if (!GetModuleFileName(GetModuleHandle(NULL), szWinIoDriverPath, sizeof(szWinIoDriverPath)))
    这是那个DLL源代码中的一部分。
    我在FormLoad里加上相应的代码,可以看到按F5调试时,路径和编译后运行是不一样的。
    解决方法是把winio.sys复制到c:\Program Files\Microsoft Visual Studio\vb98里。
      

  11.   

    NowCan(能量、激情、雨水、彩虹——雷雨云) 兄:辛苦了