我如何在Ruby中调用Windows DLL函数?

编程入门 行业动态 更新时间:2024-10-20 20:40:02
本文介绍了我如何在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函数?

本文发布于:2023-11-22 05:42:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616184.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   如何在   Windows   Ruby   DLL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!