[python-win32] Calling random Windows function?
timr at probo.com
Fri Oct 23 20:53:50 CEST 2009
> On Fri, Oct 23, 2009, Christopher Nilsson wrote:
>> But, wow... Just starting with windows programming, and jumping right
>> into the semi-documented territory. Brave. :)
> Well, I have three things going for me:
> * I've been programming in Python for more than a decade
Yes, your name is famous in the Python community. As we say, "your
reputation precedes you." However, Christopher's comment is not without
merit, and is worthy of a little explanation.
The Windows NT family is really an operating system within an operating
system. The kernel is a more-or-less generic operating system of its
own; user programs run within a "subsystem" running on top of that
kernel. In the original implementation, this distinction was extremely
pure. There was a Win32 subsystem, an OS/2 subsystem, and a Posix
subsystem, all exclusively in user mode. Programs written for those
subsystems used their own APIs, and the subsystem translated them into
"native" calls for the kernel. That purity has been tarnished a bit
(mostly for performance reasons), so that some Win32 concepts have been
forced down in the kernel, but the basic idea is still present.
All of the APIs starting with Nt and Zw, including
NtQuerySystemInformation, are "native" calls. They are not Win32
calls. They are intended for use in the kernel, although many are
exposed to user-mode as well. The native API looks somewhat different
from the Win32 API, and is not nearly as well documented. There are
many useful things to be done with those APIs, but there are many sharp
edges as well. Mind the gap.
> * I have code in C++ that does exactly what I want (I'm rewriting it in
> Python because for some strange reason AVG thinks the executable is a
> virus and we also have some other problems running it on 64-bit Vista,
> and I figure that using Python will work better), and I just need to
> translate all the Windows calls
It is quite possible that AVG is generically objecting to the use of
native APIs. If so, I fear you will reach the same frustration with
your Python translation.
> Oh, wait, I have four things going for me:
> * The wonderful Python community
> Oh, wait, I have [stops Spanish Inquisition re-run here]
NO ONE expects the Spanish Inquisition.
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the python-win32