Module: GMEM
- Defined in:
- lib/vr/sysmod.rb
Constant Summary collapse
- GlobalAlloc =
GlobalAlloc(method,size)
Win32API.new("kernel32","GlobalAlloc",["I","I"],"I")
- GlobalLock =
Win32API.new("kernel32","GlobalLock",["I"],"I")
- GlobalUnlock =
Win32API.new("kernel32","GlobalUnlock",["I"],"")
- GlobalFree =
Win32API.new("kernel32","GlobalFree",["I"],"I")
- GlobalSize =
Win32API.new("kernel32","GlobalSize",["I"],"I")
- GlobalFlags =
Win32API.new("kernel32","GlobalFlags",["I"],"I")
Class Method Summary collapse
- .Alloc(*arg) ⇒ Object
- .AllocStr(mode, text) ⇒ Object
- .Free(*arg) ⇒ Object
- .Get(hglb) ⇒ Object
- .Lock(*arg) ⇒ Object
- .Set(hglb, text, siz = nil) ⇒ Object
- .Size(*arg) ⇒ Object
- .Unlock(*arg) ⇒ Object
Class Method Details
.Alloc(*arg) ⇒ Object
109 |
# File 'lib/vr/sysmod.rb', line 109 def GMEM::Alloc(*arg) GlobalAlloc.call(*arg) end |
.AllocStr(mode, text) ⇒ Object
115 116 117 118 119 |
# File 'lib/vr/sysmod.rb', line 115 def GMEM::AllocStr(mode,text) mem = GlobalAlloc.call(mode,text.length+1) Set(mem,text,text.size+1) mem end |
.Free(*arg) ⇒ Object
112 |
# File 'lib/vr/sysmod.rb', line 112 def GMEM::Free(*arg) GlobalFree.call(*arg) end |
.Get(hglb) ⇒ Object
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/vr/sysmod.rb', line 127 def GMEM::Get(hglb) lp = GlobalLock.call(hglb) len = GlobalSize.call(hglb) #p format "%x %d, %x",hglb, lp, GlobalFlags.call(hglb) raise "Memory not accessible" if len==0 str = " " * (len+1) MEMCOPY::Mem2Str(str,lp,len) GlobalUnlock.call(hglb) str end |
.Lock(*arg) ⇒ Object
110 |
# File 'lib/vr/sysmod.rb', line 110 def GMEM::Lock(*arg) GlobalLock.call(*arg) end |
.Set(hglb, text, siz = nil) ⇒ Object
121 122 123 124 125 126 |
# File 'lib/vr/sysmod.rb', line 121 def GMEM::Set(hglb,text,siz=nil) len= if siz then siz.to_i else [size,Size(hglb)].min end lp = GlobalLock.call(hglb) MEMCOPY::Str2Mem(lp,text.to_s,len) GlobalUnlock.call(hglb) end |
.Size(*arg) ⇒ Object
113 |
# File 'lib/vr/sysmod.rb', line 113 def GMEM::Size(*arg) GlobalSize.call(*arg) end |
.Unlock(*arg) ⇒ Object
111 |
# File 'lib/vr/sysmod.rb', line 111 def GMEM::Unlock(*arg) GlobalUnlock.call(*arg) end |