My code processes all the files in a folder on a Windows box. I want to offer the user (who happens to also be me) the option to select the folder to be processed, using the standard File Chooser dialog.
我的代码处理Windows框中文件夹中的所有文件。我想使用标准的“文件选择器”对话框为用户(恰好也是我)提供选择要处理的文件夹的选项。
I am trying to use the GetOpenFileName function to make this happen. (I am actually calling it from Python via pywin32, but that shouldn't be relevant.)
我试图使用GetOpenFileName函数来实现这一点。 (我实际上是通过pywin32从Python调用它,但这不应该是相关的。)
I can get it to select a particular file, but I can't see any options to let the user select a folder instead.
我可以让它选择一个特定的文件,但我看不到让用户选择文件夹的任何选项。
Is there a flag combination I haven't understood, am I calling the wrong function entirely or is there another idiom for doing this?
有没有我不理解的旗帜组合,我是完全调用了错误的函数还是有另外一个成语呢?
2 个解决方案
#1
4
Unfortunately, I think you're calling the wrong function entirely. It's been a while since I've done Win32 gui stuff.. but I seem to recall that there was a different way of bringing up a "select directory" box. It wasn't a straight Win32 function, but was some shell API function that required a whole heap of code to do the simplest thing.
不幸的是,我认为你完全是在调用错误的函数。我已经做了一段时间,因为我已经完成了Win32 gui的东西..但我似乎记得有一种不同的方式来打开“选择目录”框。它不是一个直接的Win32函数,而是一些shell API函数,它需要一大堆代码才能完成最简单的操作。
Update: A bit of google reveals the SHBrowseForFolder function.
更新:一些谷歌揭示了SHBrowseForFolder功能。
Update two: And here is an example for Python.
更新二:这是Python的一个例子。
#2
2
As Greg mentions, the function you want is a shell function. The specific function you need is SHBrowseForFolder
, which is pretty messy to call. There's also PyWin32 documentation for it which mentions the browse_for_folder.py
sample.
正如Greg所提到的,你想要的功能是一个shell函数。你需要的具体功能是SHBrowseForFolder,调用非常麻烦。还有PyWin32文档,其中提到了browse_for_folder.py示例。
#1
4
Unfortunately, I think you're calling the wrong function entirely. It's been a while since I've done Win32 gui stuff.. but I seem to recall that there was a different way of bringing up a "select directory" box. It wasn't a straight Win32 function, but was some shell API function that required a whole heap of code to do the simplest thing.
不幸的是,我认为你完全是在调用错误的函数。我已经做了一段时间,因为我已经完成了Win32 gui的东西..但我似乎记得有一种不同的方式来打开“选择目录”框。它不是一个直接的Win32函数,而是一些shell API函数,它需要一大堆代码才能完成最简单的操作。
Update: A bit of google reveals the SHBrowseForFolder function.
更新:一些谷歌揭示了SHBrowseForFolder功能。
Update two: And here is an example for Python.
更新二:这是Python的一个例子。
#2
2
As Greg mentions, the function you want is a shell function. The specific function you need is SHBrowseForFolder
, which is pretty messy to call. There's also PyWin32 documentation for it which mentions the browse_for_folder.py
sample.
正如Greg所提到的,你想要的功能是一个shell函数。你需要的具体功能是SHBrowseForFolder,调用非常麻烦。还有PyWin32文档,其中提到了browse_for_folder.py示例。