Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>PyWin32 is the way to go - but how to use it? One approach is to begin with a concrete problem you're having and attempting to solve it. PyWin32 provides bindings for the Win32 API functions for which there are many, and you really have to pick a specific goal first.</p> <p>In my Python 2.5 installation (ActiveState on Windows) the win32 package has a Demos folder packed with sample code of various parts of the library. </p> <p>For example, here's CopyFileEx.py:</p> <pre><code>import win32file, win32api import os def ProgressRoutine(TotalFileSize, TotalBytesTransferred, StreamSize, StreamBytesTransferred, StreamNumber, CallbackReason, SourceFile, DestinationFile, Data): print Data print TotalFileSize, TotalBytesTransferred, StreamSize, StreamBytesTransferred, StreamNumber, CallbackReason, SourceFile, DestinationFile ##if TotalBytesTransferred &gt; 100000: ## return win32file.PROGRESS_STOP return win32file.PROGRESS_CONTINUE temp_dir=win32api.GetTempPath() fsrc=win32api.GetTempFileName(temp_dir,'cfe')[0] fdst=win32api.GetTempFileName(temp_dir,'cfe')[0] print fsrc, fdst f=open(fsrc,'w') f.write('xxxxxxxxxxxxxxxx\n'*32768) f.close() ## add a couple of extra data streams f=open(fsrc+':stream_y','w') f.write('yyyyyyyyyyyyyyyy\n'*32768) f.close() f=open(fsrc+':stream_z','w') f.write('zzzzzzzzzzzzzzzz\n'*32768) f.close() operation_desc='Copying '+fsrc+' to '+fdst win32file.CopyFileEx(fsrc, fdst, ProgressRoutine, operation_desc, False, win32file.COPY_FILE_RESTARTABLE) </code></pre> <p>It shows how to use the CopyFileEx function with a few others (such as GetTempPath and GetTempFileName). From this example you can get a "general feel" of how to work with this library. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload