是否可以使用Python访问GetLongPathName()Win32 API?
问题内容:
我需要将8.3约定中的路径转换为完整路径。在Perl中,可以使用如何从Perl的8.3
DOS路径获取完整的Win32路径中Win32::GetLongPathName()
指出的方式使用。但是,我需要在Python中执行此操作。
问题答案:
使用ctypes
python标准中可用的方法,而无需使用pywin32
API
。像这样:
from ctypes import *
buf = create_unicode_buffer(260)
GetLongPathName = windll.kernel32.GetLongPathNameW
rv = GetLongPathName(path, buf, 260)
print buf.value
来自http://mail.python.org/pipermail/python-
win32/2008-January/006642.html