Guest User

Read from and write to .ini snippet

a guest
Apr 20th, 2011
183
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Utility
  2.   #############
  3.   # DLL STUFF #
  4.   #############
  5.   READ_INI         = Win32API.new('kernel32',  'GetPrivateProfileStringA',
  6.                                   %w(p p p p l p), 'l')
  7.   WRITE_INI        = Win32API.new('kernel32',  'WritePrivateProfileStringA',
  8.                                   %w(p p p p), 'l')
  9.   ##
  10.   # Read from system ini
  11.   #
  12.   def self.read_ini(key_name, app_name = 'Game', filename = 'Game.ini',
  13.                     buffer_size = 256, default = '')
  14.     buffer = "\0" * buffer_size
  15.     READ_INI.call(app_name, key_name, default, buffer, buffer_size - 1,
  16.                   ".\\" + filename)
  17.     return buffer.delete("\0")
  18.   end
  19.  
  20.   ##
  21.   # Write to system ini
  22.   #
  23.   def self.write_ini(key_name, value, app_name = 'Game', filename = 'Game.ini')
  24.     return WRITE_INI.call(app_name, key_name, value.to_s, ".\\" + filename)
  25.   end
  26. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×