Nelly Nelly - 13 days ago 6
Python Question

Is it possible to access the GetLongPathName() Win32 API in Python?

I need to convert paths in 8.3 convention to full path.
In Perl, I can use

as pointed out in How do I get full Win32 path from 8.3 DOS path with Perl? But, I need to do it in Python.

Answer

Use ctypes which is available in the Python standard without the need of using the pywin32 API. Like this:

from ctypes import *

buf = create_unicode_buffer(260)
GetLongPathName = windll.kernel32.GetLongPathNameW
rv = GetLongPathName(path, buf, 260)
print buf.value

From http://mail.python.org/pipermail/python-win32/2008-January/006642.html

Comments