X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2FBFolderPage.py;h=9623394d1d423227e6dd09524876fceb5fc4de41;hb=c6e223c861ba70c2695598b2c998fc0edc48f018;hp=6af6a651808475a05485295b4703f3da49d03dd5;hpb=b0882263114dd5cc268ce701d5e48cc94ee9bf79;p=bertos.git diff --git a/wizard/BFolderPage.py b/wizard/BFolderPage.py index 6af6a651..9623394d 100644 --- a/wizard/BFolderPage.py +++ b/wizard/BFolderPage.py @@ -136,10 +136,15 @@ class BFolderPage(BWizardPage): if stored_folder != "": self._destination_folder = stored_folder elif os.name == "nt": - from win32com.shell import shell, shellcon - self._destination_folder = shell.SHGetFolderPath(0, shellcon.CSIDL_PERSONAL, 0, 0) - del shell - del shellcon + def _winGetSpecialFolder(csidl): + from ctypes import windll, create_unicode_buffer + MAX_PATH = 4096 + buf = create_unicode_buffer(MAX_PATH) + if not windll.shell32.SHGetSpecialFolderPathW(0, buf, csidl, False): + raise WindowsError("cannot get special folder location") + return buf.value + CSIDL_PERSONAL = 5 + self._destination_folder = _winGetSpecialFolder(CSIDL_PERSONAL) else: self._destination_folder = os.path.expanduser("~") self.pageContent.directoryEdit.setText(self._destination_folder)