win32file module functions seem to fail very simple test case.

Kossay Omary kossay at comcast.net
Sat May 3 15:32:59 EDT 2003


I am almost sure that this is a problem with my configuration or
 my use of the functions. I just do not know how to debug this.

I am running the following code on WindowsXP with Python2.2 ,
after I execfile('...') the following code, I get a message from 
windows that the application pythonw was aborted and it asks
me if I want to send an error log to microsoft.

The code (you need to create the dummy file C:\existing_file):
Please help. These are my first steps with windows file handling.

import win32file

def closeFile(handle):
    handle.Close()

def openFile(filename):
    # returns a handle to the Windows file
    return win32file.CreateFile(filename.upper(), win32file.GENERIC_READ, \
                                0, None, win32file.OPEN_EXISTING, 0, None)

def readChar(handle):
    err = 0
    char = None
    err, char = win32file.ReadFile(handle, 1, None)
    return char

if __name__ == '__main__':
    # this will now fail
    #handle = openFile('C:\\MyFiles\\Python\\Modem\\ttt')
    handle = openFile('C:\\existing_file')
    print readChar(handle)
    closeFile(handle)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20030503/c4ea2a5f/attachment.html>


More information about the Python-list mailing list