| 
 
| 赞 | 0 |  
| VIP | 0 |  
| 好人卡 | 17 |  
| 积分 | 1 |  
| 经验 | 6957 |  
| 最后登录 | 2013-5-13 |  
| 在线时间 | 237 小时 |  
 Lv1.梦旅人 
	梦石0 星屑50 在线时间237 小时注册时间2011-7-28帖子81 | 
| 今天试着用API写了一下修改图标的程序,代码如下: 谁能告诉我第5行的参数怎么写啊~~复制代码#修改程序ico方法
file_name = "Graphics/Pictures/ico32.ico"
@get_ico = Win32API.new("user32", "LoadCursorFromFile", 'l', 'l')
@sendmessage = Win32API.new("user32", "SendMessage", 'lllp', 'l')
icon = @get_ico.call() #这里不知道怎么写啊
@sendmessage.call(get_hWnd, 0x0080, nil, icon)
获取句柄的代码:
 LoadCursorFromFile的函数原型:HCURSOR LoadCursorFromFile(LPCTSTR IpFileName)复制代码# ■ Kernel
#------------------------------------------------------------------------------
#  该模块中定义了可供所有类使用的方法。Object 类中包含了该模块。
#==============================================================================
module Kernel
  #--------------------------------------------------------------------------
  # ● 需要的 Windows API 函数
  #--------------------------------------------------------------------------
  GetWindowThreadProcessId = Win32API.new("user32", "GetWindowThreadProcessId", "LP", "L")
  GetWindow = Win32API.new("user32", "GetWindow", "LL", "L")
  GetClassName = Win32API.new("user32", "GetClassName", "LPL", "L")
  GetCurrentThreadId = Win32API.new("kernel32", "GetCurrentThreadId", "V", "L")
  GetForegroundWindow = Win32API.new("user32", "GetForegroundWindow", "V", "L")
  #--------------------------------------------------------------------------
  # ● 获取窗口句柄
  #--------------------------------------------------------------------------
  def get_hWnd
    # 获取调用线程(RM 的主线程)的进程标识
    threadID = GetCurrentThreadId.call
    # 获取 Z 次序中最靠前的窗口
    hWnd = GetWindow.call(GetForegroundWindow.call, 0)
    # 枚举所有窗口
    while hWnd != 0
      # 如果创建该窗口的线程标识匹配本线程标识
      if threadID == GetWindowThreadProcessId.call(hWnd, 0)
        # 分配一个 11 个字节的缓冲区
        className = " " * 11
        # 获取该窗口的类名
        GetClassName.call(hWnd, className, 12)
        # 如果匹配 RGSS Player 则跳出循环
        break if className == "RGSS Player"
      end
      # 获取下一个窗口
      hWnd = GetWindow.call(hWnd, 2)
    end
    return hWnd
  end
end
 | 
 |