本文介绍了我如何在Ruby中调用Windows DLL函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用Ruby DLL中使用的功能。我想用C的低级别的访问,同时仍保留编写Ruby code的简单性。我如何做到这一点?
I want to access functions within a DLL using Ruby. I want to use the low-level access of C while still retaining the simplicity of writing Ruby code. How do I accomplish this?
推荐答案看一看 的Win32API STDLIB。这是一个相当简单的(但晦涩难懂)接口到Windows 32 API,或DLL。
Have a look at Win32API stdlib. It's a fairly easy (but arcane) interface to the Windows 32 API, or DLLs.
文档是这里,有的examples这里。为了给你一个味道:
Documentation is here, some examples here. To give you a taste:
require "Win32API" def get_computer_name name = " " * 128 size = "128" Win32API.new('kernel32', 'GetComputerName', ['P', 'P'], 'I').call(name, size) name.unpack("A*") end更多推荐
我如何在Ruby中调用Windows DLL函数?
发布评论