home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- __VERSION__ = '0.2'
- import os
- from win32com import storagecon
- from win32com.shell import shell, shellcon
- import pythoncom
-
- class x_winshell(Exception):
- pass
-
-
- def get_path(folder_id):
- return shell.SHGetPathFromIDList(shell.SHGetSpecialFolderLocation(0, folder_id))
-
-
- def desktop(common = 0):
- return get_path((shellcon.CSIDL_DESKTOP, shellcon.CSIDL_COMMON_DESKTOPDIRECTORY)[common])
-
-
- def common_desktop():
- return desktop(common = 1)
-
-
- def application_data(common = 0):
- return get_path((shellcon.CSIDL_APPDATA, shellcon.CSIDL_COMMON_APPDATA)[common])
-
-
- def favourites(common = 0):
- return get_path((shellcon.CSIDL_FAVORITES, shellcon.CSIDL_COMMON_FAVORITES)[common])
-
- bookmarks = favourites
-
- def start_menu(common = 0):
- return get_path((shellcon.CSIDL_STARTMENU, shellcon.CSIDL_COMMON_STARTMENU)[common])
-
-
- def programs(common = 0):
- return get_path((shellcon.CSIDL_PROGRAMS, shellcon.CSIDL_COMMON_PROGRAMS)[common])
-
-
- def startup(common = 0):
- return get_path((shellcon.CSIDL_STARTUP, shellcon.CSIDL_COMMON_STARTUP)[common])
-
-
- def personal_folder():
- return get_path(shellcon.CSIDL_PERSONAL)
-
- my_documents = personal_folder
-
- def recent():
- return get_path(shellcon.CSIDL_RECENT)
-
-
- def sendto():
- return get_path(shellcon.CSIDL_SENDTO)
-
-
- def _file_operation(operation, source_path, target_path = None, allow_undo = True, no_confirm = False, rename_on_collision = True, silent = False, hWnd = None):
- if not source_path:
- pass
- source_path = ''
- if not target_path:
- pass
- target_path = ''
- flags = 0
- if allow_undo:
- flags |= shellcon.FOF_ALLOWUNDO
-
- if no_confirm:
- flags |= shellcon.FOF_NOCONFIRMATION
-
- if rename_on_collision:
- flags |= shellcon.FOF_RENAMEONCOLLISION
-
- if silent:
- flags |= shellcon.FOF_SILENT
-
- if not hWnd:
- pass
- (result, n_aborted) = shell.SHFileOperation((0, operation, source_path, target_path, flags, None, None))
- if result != 0:
- raise x_winshell, result
- result != 0
- if n_aborted:
- raise x_winshell, '%d operations were aborted by the user' % n_aborted
- n_aborted
-
-
- def copy_file(source_path, target_path, allow_undo = True, no_confirm = False, rename_on_collision = True, silent = False, hWnd = None):
- _file_operation(shellcon.FO_COPY, source_path, target_path, allow_undo, no_confirm, rename_on_collision, silent, hWnd)
-
-
- def move_file(source_path, target_path, allow_undo = True, no_confirm = False, rename_on_collision = True, silent = False, hWnd = None):
- _file_operation(shellcon.FO_MOVE, source_path, target_path, allow_undo, no_confirm, rename_on_collision, silent, hWnd)
-
-
- def rename_file(source_path, target_path, allow_undo = True, no_confirm = False, rename_on_collision = True, silent = False, hWnd = None):
- _file_operation(shellcon.FO_RENAME, source_path, target_path, allow_undo, no_confirm, rename_on_collision, silent, hWnd)
-
-
- def delete_file(source_path, allow_undo = True, no_confirm = False, rename_on_collision = True, silent = False, hWnd = None):
- _file_operation(shellcon.FO_DELETE, source_path, None, allow_undo, no_confirm, rename_on_collision, silent, hWnd)
-
-
- def CreateShortcut(Path, Target, Arguments = '', StartIn = '', Icon = ('', 0), Description = ''):
- sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)
- sh.SetPath(Target)
- sh.SetDescription(Description)
- sh.SetArguments(Arguments)
- sh.SetWorkingDirectory(StartIn)
- sh.SetIconLocation(Icon[0], Icon[1])
- persist = sh.QueryInterface(pythoncom.IID_IPersistFile)
- persist.Save(Path, 1)
-
- FMTID_USER_DEFINED_PROPERTIES = '{F29F85E0-4FF9-1068-AB91-08002B27B3D9}'
- FMTID_CUSTOM_DEFINED_PROPERTIES = '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}'
- PIDSI_TITLE = 2
- PIDSI_SUBJECT = 3
- PIDSI_AUTHOR = 4
- PIDSI_CREATE_DTM = 12
- PIDSI_KEYWORDS = 5
- PIDSI_COMMENTS = 6
- PIDSI_TEMPLATE = 7
- PIDSI_LASTAUTHOR = 8
- PIDSI_REVNUMBER = 9
- PIDSI_EDITTIME = 10
- PIDSI_LASTPRINTED = 11
- PIDSI_LASTSAVE_DTM = 13
- PIDSI_PAGECOUNT = 14
- PIDSI_WORDCOUNT = 15
- PIDSI_CHARCOUNT = 16
- PIDSI_THUMBNAIL = 17
- PIDSI_APPNAME = 18
- PROPERTIES = (PIDSI_TITLE, PIDSI_SUBJECT, PIDSI_AUTHOR, PIDSI_CREATE_DTM, PIDSI_KEYWORDS, PIDSI_COMMENTS, PIDSI_TEMPLATE, PIDSI_LASTAUTHOR, PIDSI_EDITTIME, PIDSI_LASTPRINTED, PIDSI_LASTSAVE_DTM, PIDSI_PAGECOUNT, PIDSI_WORDCOUNT, PIDSI_CHARCOUNT, PIDSI_APPNAME)
-
- def structured_storage(filename):
- if not pythoncom.StgIsStorageFile(filename):
- return { }
- flags = storagecon.STGM_READ | storagecon.STGM_SHARE_EXCLUSIVE
- storage = pythoncom.StgOpenStorage(filename, None, flags)
-
- try:
- properties_storage = storage.QueryInterface(pythoncom.IID_IPropertySetStorage)
- except pythoncom.com_error:
- pythoncom.StgIsStorageFile(filename)
- pythoncom.StgIsStorageFile(filename)
- return { }
-
- property_sheet = properties_storage.Open(FMTID_USER_DEFINED_PROPERTIES)
-
- try:
- data = property_sheet.ReadMultiple(PROPERTIES)
- finally:
- property_sheet = None
-
- (title, subject, author, created_on, keywords, comments, template_used, updated_by, edited_on, printed_on, saved_on, n_pages, n_words, n_characters, application) = data
- result = { }
- if title:
- result['title'] = title
-
- if subject:
- result['subject'] = subject
-
- if author:
- result['author'] = author
-
- if created_on:
- result['created_on'] = created_on
-
- if keywords:
- result['keywords'] = keywords
-
- if comments:
- result['comments'] = comments
-
- if template_used:
- result['template_used'] = template_used
-
- if updated_by:
- result['updated_by'] = updated_by
-
- if edited_on:
- result['edited_on'] = edited_on
-
- if printed_on:
- result['printed_on'] = printed_on
-
- if saved_on:
- result['saved_on'] = saved_on
-
- if n_pages:
- result['n_pages'] = n_pages
-
- if n_words:
- result['n_words'] = n_words
-
- if n_characters:
- result['n_characters'] = n_characters
-
- if application:
- result['application'] = application
-
- return result
-
- if __name__ == '__main__':
-
- try:
- print 'Desktop =>', desktop()
- print 'Common Desktop =>', desktop(1)
- print 'Application Data =>', application_data()
- print 'Common Application Data =>', application_data(1)
- print 'Bookmarks =>', bookmarks()
- print 'Common Bookmarks =>', bookmarks(1)
- print 'Start Menu =>', start_menu()
- print 'Common Start Menu =>', start_menu(1)
- print 'Programs =>', programs()
- print 'Common Programs =>', programs(1)
- print 'Startup =>', startup()
- print 'Common Startup =>', startup(1)
- print 'My Documents =>', my_documents()
- print 'Recent =>', recent()
- print 'SendTo =>', sendto()
- finally:
- raw_input('Press enter...')
-
-
-