require 'win32/api' require 'cstruct/win32struct' include Win32 WS_VISIBLE = 0x10000000 WS_CAPTION = 0x00C00000 WS_SYSMENU = 0x00080000 WS_MINIMIZEBOX = 0x00020000 WS_MAXIMIZEBOX = 0x00010000 WS_THICKFRAME = 0x00040000 WS_OVERLAPPED = 0x00000000 WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX) WM_CREATE = 0x0001 WM_DESTROY = 0x0002 WM_PAINT = 0x000F WM_CLOSE = 0x0010 WM_COMMAND = 0x0111 CS_VREDRAW = 0x0001 CS_HREDRAW = 0x0002 COLOR_WINDOW = 5 CW_USEDEFAULT = -2147483648 #0x80000000 SW_SHOW = 5 SW_SHOWDEFAULT = 10 Memset = API.new('memset', 'PLL', 'L', 'msvcrt') LocalAlloc = API.new('LocalAlloc', 'LL', 'L', 'kernel32') GetModuleHandle = API.new('GetModuleHandle', 'P', 'L', 'kernel32') RegisterClass = API.new('RegisterClass', 'P', 'L', 'user32') RegisterClassEx = API.new('RegisterClassEx', 'P', 'L', 'user32') CloseWindow = API.new('CloseWindow', 'L', 'B', 'user32') CreateWindowEx = API.new('CreateWindowEx', 'LPPLIIIILLLL', 'L', 'user32') ShowWindow = API.new('ShowWindow', 'LL', 'B', 'user32') UpdateWindow = API.new('UpdateWindow', 'L', 'B', 'user32') BeginPaint = API.new('BeginPaint', 'LP', 'L', 'user32') EndPaint = API.new('EndPaint', 'LP', 'L', 'user32') PostQuitMessage = API.new('PostQuitMessage', 'I', 'V', 'user32') DefWindowProc = API.new('DefWindowProc', 'LLLL', 'L', 'user32') GetMessage = API.new('GetMessage', 'PLII', 'L', 'user32') DispatchMessage = API.new('DispatchMessage', 'P', 'L', 'user32') TranslateMessage = API.new('TranslateMessage', 'P', 'B', 'user32') TextOut = API.new('TextOut', 'LLLPL', 'B', 'gdi32' ); class POINT 0) TranslateMessage.call(msg.data) DispatchMessage.call(msg.data) end end def main instance = GetModuleHandle.call(0) WinMain instance, SW_SHOW end main