是否可以在 Python 中访问 GetLongPathName() Win32 API? [英] Is it possible to access the GetLongPathName() Win32 API in Python?

查看:35
本文介绍了是否可以在 Python 中访问 GetLongPathName() Win32 API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将 8.3 约定中的路径转换为完整路径.在 Perl 中,我可以使用 Win32::GetLongPathName() 正如 如何使用 Perl 从 8.3 DOS 路径获得完整的 Win32 路径? 但是,我需要在 Python 中完成.

I need to convert paths in 8.3 convention to full path. In Perl, I can use Win32::GetLongPathName() 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.

推荐答案

使用 Python 标准中提供的 ctypes,无需使用 pywin32 API.像这样:

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

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

这篇关于是否可以在 Python 中访问 GetLongPathName() Win32 API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆