[python-win32] Using win32 Function GetMenuItemInfo
fguzman_slotown at yahoo.com
Sat Aug 21 01:11:39 CEST 2004
I tried using the built-in buffer function:
>>> buff = 'MyString'
>>> buff = buffer(buff)
>>> win32gui.GetMenuItemInfo(131917, 0, 57600, buff)
and received the following error:
>>> TypeError: buffer is read-only
According to the documentation on buffer(), the
function only exists for backward compatability. I
can't find any other built-in buffer function. How are
buffers created with modern python?
Thanks for all the help
--- "Weber, Henrik" <henrik.weber at sdm.de> wrote:
> > Caution: I'm as newbeeish as they come, read at
> > own risk :-)
> > I'm trying to use the win32 function
> > How do I set up the fourth argument in this
> > The documentation says the fourth argument should
> > "A string or buffer in the format of a
> > structure."
> > I don't know what this means. Here's what I've
> > to no avail:
> > buff = 'MyString'
> > win32gui.GetMenuItemInfo(131917, 0, 57600, buff)
> > This gives me the following error message:
> > TypeError: Cannot use string as modifiable buffer
> Well, in Python strings are immutable, so you cannot
> use a string if you want to write something into it.
> Also, if it wants a MENUITEMINFO structure, you need
> to supply something that has the size of that
> structure. You could use a buffer (create with the
> buffer built-in function) or maybe an array. After
> calling GetMenuItemInfo you can unpack the result
> with the struct module.
> You can find a description of the structure at
> If you are trying to extract a string from a menu
> item, see what the description says about the
> dwTypeData member. You'll have to play around with
> pointers a bit. Maybe the ctypes module can help you
> out there.
> Have fun!
> Python-win32 mailing list
> Python-win32 at python.org
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
More information about the Python-win32