新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Ruby模塊Win32API直接呼叫win32API
Ruby語言功能非常強大。我們在這里為大家介紹的Ruby模塊Win32API是Ruby語言中的一個附加庫。它就可以幫助我們直接呼叫Win32API。#t#

參數(shù)1 字符串 呼叫dll名稱
參數(shù)2 字符串 dll中dllexport的名稱
參數(shù)3 字符串數(shù)組 表示每個參數(shù)的類型 L代表Long P代表Point I代表Int V代表Void (在實際使用的時候HResult和各種Handle都是Long,字符串是P)
參數(shù)4 字符串 表示返回值類型同上
Ruby模塊Win32API代碼示例:
- require "dl/win32"
- FindWindow = Win32API.new
'user32.dll', 'FindWindow', %w(L P), 'L' - SetWindowText = Win32API.new
'user32.dll', 'SetWindowText',
%W(L P), 'I' - if ARGV.length == 0 then
- puts "使用說明:"
- puts "一個參數(shù)時,是根據(jù)窗體標題查看窗體ID"
- puts "兩個參數(shù)時,是根據(jù)參數(shù)1的標題查
找窗體,然后更改為參數(shù)2的標題" - elsif ARGV.length > 0 then
- win = FindWindow.call(0,ARGV.shift)
- puts win
- if win != 0 then
- bSet = SetWindowText.call(win,
ARGV.shift) - if bSet == 1 then
- puts "Success!"
- else
- puts "Fail!"
- end
- end
- end
以上就是Ruby模塊Win32API在應(yīng)用中的方法介紹。
當前文章:Ruby模塊Win32API直接呼叫win32API
標題路徑:http://m.5511xx.com/article/dpjpccj.html


咨詢
建站咨詢
