Re: How come this is different?

Rob Gaddi <[email protected]> Fri, 9 Dec 2016 15:26:03 -0800
Newsgroups gmane.comp.python.ctypes
Message-ID <[email protected]>
That's not it, Python is perfectly happy with 0x0400 as a literal.

Michael, is the code you've provided below all copied and pasted from your actual code, or did you retype any of it?  Is it all in fact at the 0-indent level and in the same file?  Likewise is that error report copied and pasted, or are you just paraphrasing?

On Fri, 9 Dec 2016 15:33:12 -0700
"David A. Van Arnem" <[email protected]> wrote:

> Hi Michael,
> 
> I believe Python doesn't accept a hex representation like "0x0400".  In 
> situations where I've needed a hex value like that, I've used something 
> like:
> 
> PROCESS_QUERY_INFORMATION = int("400", 16)
> 
> This creates an integer from the string "400" in base 16 (hex).
> 
> David
> 
> On 12/09/2016 03:25 PM, Michael C wrote:
> > Hi all:
> >
> >        I am trying to write my own memory scanner, but I have encountered a
> > few problem. Apparently, directly specifying "
> > PROCESS_QUERY_INFORMATION|PROCESS_VM_READ" is not ok, since the interpreter
> > returns "NameError: name 'PROCESS_QUERY_INFORMATION' is not defined"
> >
> > so I should do what I did here, to define it for myself first? is this
> > correct?
> >
> > Thanks
> >
> > Code:
> >
> > import ctypes
> >
> > kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
> >
> > PROCESS_QUERY_INFORMATION = 0x0400
> > PROCESS_VM_READ = 0x0010
> >
> > ph = kernel32.OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,False,
> > 20224)
> >
> > print(ph)
> >
> >
> >
> > ------------------------------------------------------------------------------
> > Developer Access Program for Intel Xeon Phi Processors
> > Access to Intel Xeon Phi processor-based developer platforms.
> > With one year of Intel Parallel Studio XE.
> > Training and support from Colfax.
> > Order your platform today.http://sdm.link/xeonphi
> >
> >
> >
> > _______________________________________________
> > ctypes-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/ctypes-users
> >
> 


-- 
Rob Gaddi, Highland Technology
18 Otis St.
San Francisco, CA 94103
415-551-1700

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi