在Windows 7下访问风扇

时间:2011-10-25 11:50:35

标签: c# windows io hardware

我尝试在64位Windows 7操作系统上从WinIO编译示例“DumbPort”但是当我运行该程序时,我总是得到这个错误,用户权限不足。我把winIO64.dll和winIO64.sys放在像DumbPort这样的目录中。在示例的源代码中,错误消息不是很有用,因为它意味着找到了WinIo库但无法初始化它。我正在使用Visual Studio 8,我不知道如何调试它。这是代码:

 private void Form1_Load(object sender, EventArgs e)
    {
        // Check if this is a 32 bit or 64 bit system
        if (IntPtr.Size == 4)
        {
            hMod = LoadLibrary("WinIo32.dll");

        }
        else if (IntPtr.Size == 8)
        {
            hMod = LoadLibrary("WinIo64.dll");
        }

        if (hMod == IntPtr.Zero)
        {
            MessageBox.Show("Can't find WinIo dll.\nMake sure the WinIo library files are located in the same directory as your executable file.", "DumpPort", MessageBoxButtons.OK, MessageBoxIcon.Error);
            this.Close();
        }

        IntPtr pFunc = GetProcAddress(hMod, "InitializeWinIo");

        if (pFunc != IntPtr.Zero)
        {
            InitializeWinIoType InitializeWinIo = (InitializeWinIoType)Marshal.GetDelegateForFunctionPointer(pFunc, typeof(InitializeWinIoType));
            bool Result = InitializeWinIo();

            if (!Result)
            {
                MessageBox.Show("Error returned from InitializeWinIo.\nMake sure you are running with administrative privileges and that the WinIo library files are located in the same directory as your executable file.", "DumpPort", MessageBoxButtons.OK, MessageBoxIcon.Error);
                FreeLibrary(hMod);
                this.Close();
            }
        }

1 个答案:

答案 0 :(得分:0)

到目前为止,我已经用winring0:http://www.chihoang.de/code-schnipsel/amilo-xa-3530/fsc-xa-3530-fan-control-v01-windows.html解决了我的问题。目前我正在尝试编写内核驱动程序和systray程序来控制它。