Latest recipes tagged "win32"http://code.activestate.com/recipes/tags/win32/new/2014-07-31T17:33:19-07:00ActiveState Code RecipesGet all installed Windows hotfixes (Perl)
2014-07-31T17:33:19-07:00Brett Carrollhttp://code.activestate.com/recipes/users/4174322/http://code.activestate.com/recipes/578917-get-all-installed-windows-hotfixes/
<p style="color: grey">
Perl
recipe 578917
by <a href="/recipes/users/4174322/">Brett Carroll</a>
(<a href="/recipes/tags/engineering/">engineering</a>, <a href="/recipes/tags/fix/">fix</a>, <a href="/recipes/tags/hotfix/">hotfix</a>, <a href="/recipes/tags/hotfixes/">hotfixes</a>, <a href="/recipes/tags/ole/">ole</a>, <a href="/recipes/tags/perl/">perl</a>, <a href="/recipes/tags/quick/">quick</a>, <a href="/recipes/tags/win32/">win32</a>, <a href="/recipes/tags/windows/">windows</a>, <a href="/recipes/tags/wmi/">wmi</a>).
</p>
<p>This script uses WMI (via Win32::OLE) to retrieve and print out a comma separated list of all installed Windows hotfixes.</p>
Reimplementation of rmtree supporting Windows reparse points (Python)
2014-03-08T21:17:41-08:00Charles Grunwaldhttp://code.activestate.com/recipes/users/4175823/http://code.activestate.com/recipes/578849-reimplementation-of-rmtree-supporting-windows-repa/
<p style="color: grey">
Python
recipe 578849
by <a href="/recipes/users/4175823/">Charles Grunwald</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/directories/">directories</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/remove/">remove</a>, <a href="/recipes/tags/win32/">win32</a>).
Revision 3.
</p>
<p>Ctypes-based implementation of shutil.rmtree that correctly handles Windows reparse point folders. (symbolic links, junctions, etc)</p>
Get memory usage of Windows processes using GetProcessMemoryInfo (via ctypes) (Python)
2013-04-25T01:26:19-07:00Ben Hoythttp://code.activestate.com/recipes/users/4170919/http://code.activestate.com/recipes/578513-get-memory-usage-of-windows-processes-using-getpro/
<p style="color: grey">
Python
recipe 578513
by <a href="/recipes/users/4170919/">Ben Hoyt</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/process/">process</a>, <a href="/recipes/tags/win32/">win32</a>, <a href="/recipes/tags/windows/">windows</a>).
</p>
<p>These functions call the Win32 function GetProcessMemoryInfo() using ctypes to get the memory usage of the current process. Works on both 32-bit and 64-bit Windows and Python 2.6+ (including Python 3.x).</p>
Treat the Win32 Registry like a Python dict -- pure python (Python)
2012-10-20T13:54:02-07:00Grizzly Nyohttp://code.activestate.com/recipes/users/4183996/http://code.activestate.com/recipes/578296-treat-the-win32-registry-like-a-python-dict-pure-p/
<p style="color: grey">
Python
recipe 578296
by <a href="/recipes/users/4183996/">Grizzly Nyo</a>
(<a href="/recipes/tags/registery/">registery</a>, <a href="/recipes/tags/sysadmin/">sysadmin</a>, <a href="/recipes/tags/win32/">win32</a>).
</p>
<p>This class wraps most of the win32api functions for accessing a registry. It will read and write all win32 registry types, and will de/serialize python objects to registry keys when a string or integer representation is not possible.</p>
<p>This is an update of <a href="http://code.activestate.com/recipes/573466/">recipe 573466</a>, which is an update of 551761, which is in turn an update of 174627, folding in the enhancements listed in the discussion there to allow registry value types to be read and written within the dictionary metaphor if required. It doesn't change how it worked before, it adds a new capability, and shouldn't break existing code using the 551761 version.</p>
<p>Altered to use _winreg to avoid dependency on PyWin32 (not part of Python).</p>
Win32 named mutex class for system-wide mutex (Python)
2011-07-15T21:12:40-07:00Ben Hoythttp://code.activestate.com/recipes/users/4170919/http://code.activestate.com/recipes/577794-win32-named-mutex-class-for-system-wide-mutex/
<p style="color: grey">
Python
recipe 577794
by <a href="/recipes/users/4170919/">Ben Hoyt</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/lock/">lock</a>, <a href="/recipes/tags/mutex/">mutex</a>, <a href="/recipes/tags/process/">process</a>, <a href="/recipes/tags/threading/">threading</a>, <a href="/recipes/tags/win32/">win32</a>, <a href="/recipes/tags/windows/">windows</a>).
</p>
<p>NamedMutex is a class for using Windows (Win32) named mutexes for system-wide locks. For example, we use these to lock system-wide log files that multiple processes can write to.</p>
DDE Client (Python)
2011-04-14T16:33:19-07:00David Naylorhttp://code.activestate.com/recipes/users/4177661/http://code.activestate.com/recipes/577654-dde-client/
<p style="color: grey">
Python
recipe 577654
by <a href="/recipes/users/4177661/">David Naylor</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/dde/">dde</a>, <a href="/recipes/tags/win32/">win32</a>).
</p>
<p>A DDE Client using ctypes for Windows. Unlike the pywin32 implementation this code supports advice requests. </p>
Commandline Macro Expander (Python)
2010-11-15T03:27:16-08:00Phil Risthttp://code.activestate.com/recipes/users/4171119/http://code.activestate.com/recipes/577463-commandline-macro-expander/
<p style="color: grey">
Python
recipe 577463
by <a href="/recipes/users/4171119/">Phil Rist</a>
(<a href="/recipes/tags/console/">console</a>, <a href="/recipes/tags/expander/">expander</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/win32/">win32</a>).
</p>
<p>This program is designed to be executed from a console window on a
Win32 platform. It expands user entered commands. Three styles of
commands are accepted 'x comp myfile.c', 'x #!test myfile.exe test.dat'
and 'x {print} myfile.c' to extract, expand and excute commands
saved in a menu file, an arbitrary file or associated with a file
type in the Win32 registry.</p>
A Buttonbar program with color (Python)
2010-11-16T07:02:50-08:00Phil Risthttp://code.activestate.com/recipes/users/4171119/http://code.activestate.com/recipes/577462-a-buttonbar-program-with-color/
<p style="color: grey">
Python
recipe 577462
by <a href="/recipes/users/4171119/">Phil Rist</a>
(<a href="/recipes/tags/buttonbar/">buttonbar</a>, <a href="/recipes/tags/command/">command</a>, <a href="/recipes/tags/execution/">execution</a>, <a href="/recipes/tags/win32/">win32</a>).
Revision 2.
</p>
<p>An improved buttonbar program. Allows user to execute command by clicking button. <br />
Designed to be executed from a file association on a Win32 platform. Replaces
<a href="http://code.activestate.com/recipes/577038/">recipe 577038</a>. Useful for commands requiring multiple related files.</p>
Run command in Win32 Registry (Python)
2010-10-25T05:14:49-07:00Phil Risthttp://code.activestate.com/recipes/users/4171119/http://code.activestate.com/recipes/577441-run-command-in-win32-registry/
<p style="color: grey">
Python
recipe 577441
by <a href="/recipes/users/4171119/">Phil Rist</a>
(<a href="/recipes/tags/command_execution/">command_execution</a>, <a href="/recipes/tags/win32/">win32</a>).
Revision 2.
</p>
<p>Each file type has several commands saved in the registry and associated with the
file type. These commands appear in the context menu for files of that file type.
It seemed wasteful to replicate these commands with QEditor and Crimson Editor.
DoCommand extracts the command from the registry, replaces macros and '%1' and '%*'
strings and executes the command similar to the Do.py program.</p>
An extension to Do.py Win32 Command submitter (Python)
2011-01-19T17:51:13-08:00Phil Risthttp://code.activestate.com/recipes/users/4171119/http://code.activestate.com/recipes/577440-an-extension-to-dopy-win32-command-submitter/
<p style="color: grey">
Python
recipe 577440
by <a href="/recipes/users/4171119/">Phil Rist</a>
(<a href="/recipes/tags/comand/">comand</a>, <a href="/recipes/tags/win32/">win32</a>).
Revision 2.
</p>
<p>This program expands upon my Do.py program (Recipe: 577439). Instead of doing one expansion
for the entire comand, it performs an expansion on each argument. It uses the Do.py program
preserving macro definitions.</p>
Simple command submitter for Win32 (Python)
2010-10-25T01:59:49-07:00Phil Risthttp://code.activestate.com/recipes/users/4171119/http://code.activestate.com/recipes/577439-simple-command-submitter-for-win32/
<p style="color: grey">
Python
recipe 577439
by <a href="/recipes/users/4171119/">Phil Rist</a>
(<a href="/recipes/tags/command/">command</a>, <a href="/recipes/tags/expanding/">expanding</a>, <a href="/recipes/tags/win32/">win32</a>).
</p>
<p>This program is a simple Win32 command submitter. It uses a set of macros similar
to those used by the QEditor program, strings such as '{b}'. The macros are replaced
with text from a specified file path. Options to change the working directory and
selected environment variables are provided. Two examples are provided in the code. <br />
The program does not collect output or provide input. It does one call to the expand
routine. It can not recognize parameters containing white space. Do2 which follows
does. Module is used by Do2 and ButtonBarV1Ex which follow.</p>
Support and warranty information using WMI (Python)
2011-03-17T22:07:43-07:00Michael Grünewaldhttp://code.activestate.com/recipes/users/4172244/http://code.activestate.com/recipes/577123-support-and-warranty-information-using-wmi/
<p style="color: grey">
Python
recipe 577123
by <a href="/recipes/users/4172244/">Michael Grünewald</a>
(<a href="/recipes/tags/thinkpad/">thinkpad</a>, <a href="/recipes/tags/win32/">win32</a>, <a href="/recipes/tags/wmi/">wmi</a>).
Revision 2.
</p>
<p>Shows the product code and serial number of a Thinkpad (of any computer with those information actually) and opens the Lenovo support and warranty pages for that system. It might work with other Lenovo computers too.</p>
Thinkpad Turtle (Python)
2010-03-26T20:04:05-07:00Michael Grünewaldhttp://code.activestate.com/recipes/users/4172244/http://code.activestate.com/recipes/576985-thinkpad-turtle/
<p style="color: grey">
Python
recipe 576985
by <a href="/recipes/users/4172244/">Michael Grünewald</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/thinkpad/">thinkpad</a>, <a href="/recipes/tags/win32/">win32</a>, <a href="/recipes/tags/windows/">windows</a>).
Revision 4.
</p>
<p>A small program utilizing the <code>ctypes</code> and <code>turtle</code> modules. You can <em>drive</em> the little turtle by turning your Thinkpad (which must have APS).</p>
<p><em>Requirements:</em></p>
<p>You need a newer Thinkpad (T41, T42, T43, T6x, R5x, R6x or any newer) and need to have the Active Protection System drivers (now called Lenovo Airbag Protection) installed.</p>
simple samefile() for windows (local drive case only) (Python)
2009-09-09T02:26:35-07:00Denis Barmenkovhttp://code.activestate.com/recipes/users/57155/http://code.activestate.com/recipes/576886-simple-samefile-for-windows-local-drive-case-only/
<p style="color: grey">
Python
recipe 576886
by <a href="/recipes/users/57155/">Denis Barmenkov</a>
(<a href="/recipes/tags/os_path_samefile/">os_path_samefile</a>, <a href="/recipes/tags/samefile/">samefile</a>, <a href="/recipes/tags/win32/">win32</a>, <a href="/recipes/tags/windows/">windows</a>).
Revision 4.
</p>
<p>A simple replacement of the os.path.samefile() function not existing on the Windows platform.
MAC/Unix supported in standard way :).</p>
Shutdown your PC by using ctypes (Win32 Platform) (Python)
2009-08-03T10:05:38-07:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/576865-shutdown-your-pc-by-using-ctypes-win32-platform/
<p style="color: grey">
Python
recipe 576865
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/reboot/">reboot</a>, <a href="/recipes/tags/shutdown/">shutdown</a>, <a href="/recipes/tags/system_programming/">system_programming</a>, <a href="/recipes/tags/win32/">win32</a>).
</p>
<p>It is true that by using win32 extension python modules, such as win32api, win32con, and win32security, we can easily shutdown the computer with a few steps. However, sometimes your python's runtime environment does not provide win32com module (because it is not a build-in module), we may have to shutdown the pc on our own.</p>
<p>By using ctypes, we are still able to shutdown or reboot the PC easily.</p>
Run screensaver from Python (Python)
2009-07-03T10:30:58-07:00Jordan Thorntonhttp://code.activestate.com/recipes/users/4170973/http://code.activestate.com/recipes/576828-run-screensaver-from-python/
<p style="color: grey">
Python
recipe 576828
by <a href="/recipes/users/4170973/">Jordan Thornton</a>
(<a href="/recipes/tags/run/">run</a>, <a href="/recipes/tags/saver/">saver</a>, <a href="/recipes/tags/screen/">screen</a>, <a href="/recipes/tags/screensaver/">screensaver</a>, <a href="/recipes/tags/win32/">win32</a>, <a href="/recipes/tags/win32com/">win32com</a>, <a href="/recipes/tags/win32com_client/">win32com_client</a>, <a href="/recipes/tags/windows/">windows</a>).
</p>
<p>Simple script that will allow you to locate and run the set screensaver from python, if available.</p>
Control CPU Usage by using ctypes (Win32 Platform) (Python)
2009-01-26T09:32:34-08:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/576634-control-cpu-usage-by-using-ctypes-win32-platform/
<p style="color: grey">
Python
recipe 576634
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/cpu_usage/">cpu_usage</a>, <a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/system_programming/">system_programming</a>, <a href="/recipes/tags/win32/">win32</a>).
Revision 3.
</p>
<p>This program will make your cpu work at a given cpu usage. It should be also able to work on machines with multi-processors. The program has been tested on Windows xp sp2 with python of version 2.5.4.</p>
<p>The implementation is based on the fact that it will adjust the ratio of being busy over being idle in the main process to approach the target cpu usage rate. </p>
Get CPU Usage by using ctypes (Win32 Platform) (Python)
2009-01-26T06:43:38-08:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/576631-get-cpu-usage-by-using-ctypes-win32-platform/
<p style="color: grey">
Python
recipe 576631
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/cpu_usage/">cpu_usage</a>, <a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/system_programming/">system_programming</a>, <a href="/recipes/tags/win32/">win32</a>).
Revision 2.
</p>
<p>The following code has been tested at Windows XP sp2 with Python of version 2.5.4.</p>