[Win32utils-devel] A generalized struct implementation for windows-api

Berger, Daniel Daniel.Berger at qwest.com
Thu Apr 24 10:13:37 EDT 2008

After yet another win32-process bug, I've decided that we need some form
of generalized struct handling for use with the windows-api library
instead of packing and unpacking data structures manually.
We currently do stuff like this:
proc_info = 0.chr * 16 # sizeof(PROCESS_INFORMATION)
Process.create(... proc_info ...)
I would like a way to generalize the creation of these structures.
Something like this:
require 'win32/struct'
   :hProcess    => HANDLE,
   :hThread     => HANDLE,
   :dwProcessId => DWORD,
   :dwThreadId  => DWORD

And, with that in place, we could then write:
Process.create(... proc_info ...)

The struct would automatically handle the packing/unpacking behind the
scenes based on the data type that was declared in the constructor.
It's easier to read and easier to maintain, IMO. And, we could predefine
a bunch of the most common structures in advance so that users wouldn't
have to do this themselves. They would be immediately available.

This could probably be an addon to the windows-api library already out

What do you think?



This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.

More information about the win32utils-devel mailing list