use*_*747 5 winapi haskell hsc2hs
我正在尝试编写一个模拟Windows上击键的Haskell程序.我试图调用keybd_event和SendInput,但都没有编译.不过,我可以用解释器来运行程序.当我在winable.h中包含对SendInput的绑定时尝试构建程序时,我收到错误:
cabal install
...
[1 of 2] Compiling WindowsKeys ( dist\build\WindowsKeys\WindowsKeys-tmp\WindowsKeys.hs, dist\build\WindowsKeys\WindowsKeys-tmp\WindowsKeys.o )
[2 of 2] Compiling Main ( src\Main.hs, dist\build\WindowsKeys\WindowsKeys-tmp\Main.o )
Linking dist\build\WindowsKeys\WindowsKeys.exe ...
dist\build\WindowsKeys\WindowsKeys-tmp\WindowsKeys.o:fake:(.text+0x35d): undefined reference to `SendInput'
collect2: ld returned 1 exit status
cabal: Error: some packages failed to install:
WindowsKeys-0.1.0.0 failed during the building phase. The exception was:
ExitFailure 1
Run Code Online (Sandbox Code Playgroud)
详细错误发生在http://pastebin.com/trg21N0x,但它似乎不再包含任何线索.我尝试使用时遇到类似的错误keybd_event.我写的hsc文件包含以下标题:
#include "windows.h"
#include "winuser.h"
#include "winable.h"
Run Code Online (Sandbox Code Playgroud)
这是C绑定:
foreign import ccall unsafe "winable.h SendInput"
c_SendInput :: UINT
-> Ptr Input
-> CInt
-> IO UINT
Run Code Online (Sandbox Code Playgroud)
我认为SendInput因为#if 而无法调用winuser.h:
#if (_WIN32_WINNT >= 0x0403)
WINUSERAPI UINT WINAPI SendInput(UINT,LPINPUT,int);
Run Code Online (Sandbox Code Playgroud)
当我添加绑定时_WIN32_WINNT,值为0x400.
我有Haskell平台的2012.4.0.0版.它附带了一个包含我所包含的标题的文件夹.我在计算机上找不到任何其他具有相同名称的标题.我使用的是Windows 7 Professional 6.1版.
谢谢!
这是WindowsKeys.cabal:
-- Initial WindowsKeys.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: WindowsKeys
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.8
extra-source-files: windows.h, winuser.h, winable.h
executable WindowsKeys
main-is: Main.hs
other-modules: WindowsKeys
build-depends: base ==4.5.*, Win32 ==2.2.*
hs-source-dirs: src
build-tools: hsc2hs
extra-libraries: user32
include-dirs: src
Run Code Online (Sandbox Code Playgroud)
当我注释掉键盘功能的绑定时,构建成功.
| 归档时间: |
|
| 查看次数: |
287 次 |
| 最近记录: |