Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

A couple useful Win32 API routines...

Brycej

Member

Nothing too special, but useful:

1) A routine to increase the priority of your game.
@GetCurrentProcess = Win32API.new('kernel32', 'GetCurrentProcess', [], 'i').call
@SetPriorityClass = Win32API.new('kernel32', 'SetPriorityClass', ['p', 'i'], 'i')
@SetPriorityClass.call(@GetCurrentProcess, 0x00000080)

2) A routine to reduce the fragmentation of the heap. You don't need to capture the return... I'm showing it just for completeness. If the function fails, you will default to the standard allocation scheme.
@GetProcessHeap = Win32API.new('kernel32', 'GetProcessHeap', [], 'i').call
@HeapSetInformation = Win32API.new('kernel32', 'HeapSetInformation', ['i', 'i', 'p', 'i'], 'i')
HeapInfo = 2
test = @HeapSetInformation.call(@GetProcessHeap, 0, HeapInfo, 2)

if (test == 0)
printf("HeapSetInfo failed!")
end

3) A routine to launch the joystick (aka: "Game controllers") control panel applet.
@ShellExec = Win32API.new('shell32', 'ShellExecuteA', ['i', 'p', 'p','p','p', 'i'], 'i')
@ShellExec.call(0, "open", "rundll32.exe", "shell32.dll,Control_RunDLL joy.cpl", 0, 1)

If there are routines you'd like... feel free to ask...

-Brycej
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top