Beispiel #1
0
 def getversion(self):
     file_name = self.getpath()
     info = win32api.GetFileVersionInfo(file_name, os.sep)
     print(info)
     ms = info['FileVersionMS']
     ls = info['FileVersionLS']
     version = '%d.%d.%d.%d' % (win32api.HIWORD(ms), win32api.LOWORD(ms),
                                win32api.HIWORD(ls), win32api.LOWORD(ls))
     print(version)
     return version
Beispiel #2
0
def getFileVersion(file_name):
    try:
        info = win32api.GetFileVersionInfo(file_name, os.sep)
        ms = info['FileVersionMS']
        ls = info['FileVersionLS']
        version = '%d.%d.%d.%04d' % (win32api.HIWORD(ms), win32api.LOWORD(ms),
                                     win32api.HIWORD(ls), win32api.LOWORD(ls))
        return version
    except:
        print '文件类型不对!'
Beispiel #3
0
def getFileVersion(filepath):
    if os.path.splitext(filepath)[1] not in extlist:
        return None
    else:
        info = win32api.GetFileVersionInfo(filepath, os.sep)
        ms = info['FileVersionMS']
        ls = info['FileVersionLS']
        version = '%d.%d.%d.%04d' % (win32api.HIWORD(ms), win32api.LOWORD(ms),
                                     win32api.HIWORD(ls), win32api.LOWORD(ls))
        return version
Beispiel #4
0
def get_file_version_info(path):
    """Retrieve version information for the specified file.
    """
    info = win32api.GetFileVersionInfo(path, "\\")
    ms = info["FileVersionMS"]
    ls = info["FileVersionLS"]
    major, minor = win32api.HIWORD(ms), win32api.LOWORD(ms)
    release, build = win32api.HIWORD(ls), win32api.LOWORD(ls)
    VersionInfo = namedtuple("VersionInfo",
                             ("major", "minor", "release", "build"))
    return VersionInfo(major, minor, release, build)
Beispiel #5
0
    def OnShowPos(self, hwnd, msg, wparam, lparam):
        ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SEARCHTEXT)
        s = str(win32api.HIWORD(wparam)) + ', ' + str(win32api.LOWORD(wparam))
        s += "   "
        s += str(win32api.HIWORD(lparam)) + ', ' + str(win32api.LOWORD(lparam))
        win32gui.SetWindowText(ctrl, s)

        ctrl2 = win32gui.GetDlgItem(self.hwnd, IDC_STATUS)
        s = str(win32api.HIWORD(lparam) -
                win32api.HIWORD(wparam)) + ', ' + str(
                    win32api.LOWORD(lparam) - win32api.LOWORD(wparam))
        win32gui.SetWindowText(ctrl2, s)
Beispiel #6
0
def get_file_version(filename):
    if os.path.isfile(filename):
        info = win32api.GetFileVersionInfo(filename, "\\")
        ms = info["ProductVersionMS"]
        ls = info["ProductVersionLS"]
        return (
            win32api.HIWORD(ms),
            win32api.LOWORD(ms),
            win32api.HIWORD(ls),
            win32api.LOWORD(ls),
        )
    return None
def p_GetFileVersionOLD(fname):  # Reviewed

    info = win32api.GetFileVersionInfo(
        fname, os.sep
    )  # GetFileVersionInfo(Filename, SubBlock) SubBloc= \\ for VS_FIXEDFILEINFO
    ms = info['FileVersionMS']
    ls = info['FileVersionLS']
    return [
        str(win32api.HIWORD(ms)),
        str(win32api.LOWORD(ms)),
        str(win32api.HIWORD(ls)),
        str(win32api.LOWORD(ls))
    ]
def get_file_version(file_):
    try:
        info = win32api.GetFileVersionInfo(file_, '\\')
        ms = info['FileVersionMS']
        ls = info['FileVersionLS']
        return '.'.join(
            str(s) for s in [
                win32api.HIWORD(ms),
                win32api.LOWORD(ms),
                win32api.HIWORD(ls),
                win32api.LOWORD(ls)
            ])
    except com.pywintypes.error:  # pylint: disable=no-member
        return 'no versioninfo present'
Beispiel #9
0
def get_version_number(path: pathlib.Path):
    """Retrieve the version number of a binary file.

  Args:
      path (pathlib.Path): The path to the file

  Returns:
      list: Windows version number
  """
    info = win32api.GetFileVersionInfo(str(path), "\\")
    ms = info['FileVersionMS']
    ls = info['FileVersionLS']
    return win32api.HIWORD(ms), win32api.LOWORD(ms), win32api.HIWORD(
        ls), win32api.LOWORD(ls)
Beispiel #10
0
def getFileVersion(filepath):
    filesuf = os.path.splitext(filepath)[1]
    if filesuf not in extlist:
        return ''
    try:
        info = win32api.GetFileVersionInfo(filepath, os.sep)
        ms = info['FileVersionMS']
        ls = info['FileVersionLS']
        version = '%d.%d.%d.%04d' % (win32api.HIWORD(ms), win32api.LOWORD(ms),
                                     win32api.HIWORD(ls), win32api.LOWORD(ls))
        return version
    except:
        print "get %s version error" % filepath
        return ''
Beispiel #11
0
def get_version_number(filename):
    """
    Get the file version as string.
    From https://stackoverflow.com/questions/580924/python-windows-file-version-attribute

    When there is no version return "0.0.0.0"
    """
    try:
        info = win32api.GetFileVersionInfo(filename, "\\")
        ms = info['FileVersionMS']
        ls = info['FileVersionLS']
        return (win32api.HIWORD(ms), win32api.LOWORD(ms), win32api.HIWORD(ls),
                win32api.LOWORD(ls))
    except:
        return (0, 0, 0, 0)
Beispiel #12
0
def _getFileVersion(filePath):
    info = win32api.GetFileVersionInfo(filePath, os.sep)
    ms = info['FileVersionMS']
    ls = info['FileVersionLS']
    version = '%d.%d.%d' % (win32api.HIWORD(ms), win32api.LOWORD(ms),
                            win32api.HIWORD(ls))
    return version
Beispiel #13
0
    def on_hotkey(self, hwnd, message, wparam, lparam):
        """
        ホットキー押下時のコールバック関数本体.
        押下されたホットキーに対応するコールバック関数を呼び出す.

        @param wparam ホットキーの識別子
        @param lparam 下位WORDはmodifier, 上位WORDはキーコード
        """
        pushee_index = wparam
        pushee_modifier = win32api.LOWORD(lparam)
        pushee_key = win32api.HIWORD(lparam)

        hotkey_config_list = self._map.values()

        for hotkey_config in hotkey_config_list:
            index = hotkey_config.get_index()
            if index != pushee_index:
                continue

            callback = hotkey_config.get_callback()
            if not(callable(callback)):
                # 正しいコールバック関数が入ってないとここに来る.
                # これはプログラマのミス.
                raise RuntimeError(
                    "Callback function is not callable./" +
                    "type of callback object:" + type(callback) + "/" +
                    "pushee_index:" + pushee_index
                )

            callback_params = hotkey_config.get_parameters()
            callback(callback_params)
    def on_hittest(self, hwnd, message, wparam, lparam):
        border_width = 8
        left, top, right, bottom = win32gui.GetWindowRect(hwnd)
        x = win32api.LOWORD(lparam)
        y = win32api.HIWORD(lparam)

        is_left = x >= left and x < left + border_width
        is_top = y >= top and y < top + border_width
        is_right = x < right and x >= right - border_width
        is_bottom = y < bottom and y >= bottom - border_width

        if is_left:
            if is_top:
                return win32con.HTTOPLEFT
            if is_bottom:
                return win32con.HTBOTTOMLEFT

            return win32con.HTLEFT

        if is_right:
            if is_top:
                return win32con.HTTOPRIGHT
            if is_bottom:
                return win32con.HTBOTTOMRIGHT

            return win32con.HTRIGHT

        if is_top:
            return win32con.HTTOP
        if is_bottom:
            return win32con.HTBOTTOM

        # HTCAPTION: draggable
        # HTNOWHERE: not draggable
        return win32con.HTCAPTION
Beispiel #15
0
def get_fileversion(filename):
	import win32api
	info = win32api.GetFileVersionInfo(filename, os.sep)
	ms = info['FileVersionMS']
	ls = info['FileVersionLS']
	version = '%d.%d.%d.%d' % (win32api.HIWORD(ms), win32api.LOWORD(ms), win32api.HIWORD(ls), win32api.LOWORD(ls))
	return version
Beispiel #16
0
    def OnMouseMove(self, msg):
        flags = wparam = msg[2]
        lparam = msg[3]
        if self.IsFloating() or not self.bTracking:
            return 1

        # Convert unsigned 16 bit to signed 32 bit.
        x = win32api.LOWORD(lparam)
        if x & 32768:
            x = x | -65536
        y = win32api.HIWORD(lparam)
        if y & 32768:
            y = y | -65536
        pt = x, y
        cpt = CenterPoint(self.rectTracker)
        pt = self.ClientToWnd(pt)
        if self.IsHorz():
            if cpt[1] != pt[1]:
                self.OnInvertTracker(self.rectTracker)
                self.rectTracker = OffsetRect(self.rectTracker,
                                              (0, pt[1] - cpt[1]))
                self.OnInvertTracker(self.rectTracker)
        else:
            if cpt[0] != pt[0]:
                self.OnInvertTracker(self.rectTracker)
                self.rectTracker = OffsetRect(self.rectTracker,
                                              (pt[0] - cpt[0], 0))
                self.OnInvertTracker(self.rectTracker)

        return 0  # Dont pass it on.
 def OnCommand(self, wparam, lparam):
     id = win32api.LOWORD(wparam)
     code = win32api.HIWORD(wparam)
     if id == self.button_id:
         self.DoBrowse()
     elif code == win32con.EN_CHANGE:
         self.UpdateValue_FromControl()
Beispiel #18
0
    def WndProc(hwnd, message, wParam, lParam):
        if message == win32con.WM_SIZE:
            # Resize the ATL window as the size of the main window is changed
            if BrowserView.instance != None:
                hwnd = BrowserView.instance.atlhwnd
                width = win32api.LOWORD(lParam)
                height = win32api.HIWORD(lParam)
                _user32.SetWindowPos(hwnd, win32con.HWND_TOP, 0, 0, width,
                                     height, win32con.SWP_SHOWWINDOW)
                _user32.ShowWindow(c_int(hwnd), c_int(win32con.SW_SHOW))
                _user32.UpdateWindow(c_int(hwnd))
            return 0

        elif message == win32con.WM_ERASEBKGND:
            # Prevent flickering when resizing
            return 0

        elif message == win32con.WM_CREATE:
            pass  #document = BrowserView.instance.browser.Document.QueryInterface(ICustomDoc).SetUIHandler()

        elif message == win32con.WM_DESTROY:
            _user32.PostQuitMessage(0)
            return 0

        return windll.user32.DefWindowProcW(c_int(hwnd), c_int(message),
                                            c_int(wParam), c_int(lParam))
Beispiel #19
0
 def OnCommand(cls, hwnd, msg, wparam, lparam):
     instance = win32NotifyIcon.instances.get(hwnd)
     cb = getattr(instance, "command_callback", None)
     log("OnCommand%s instance=%s, callback=%s", (hwnd, msg, wparam, lparam), instance, cb)
     if cb:
         cid = win32api.LOWORD(wparam)
         cb(hwnd, cid)
    def OnCommand(self, hwnd, msg, wparam, lparam):
        FolderSelector_Parent.OnCommand(self, hwnd, msg, wparam, lparam)
        id = win32api.LOWORD(wparam)
        id_name = self._GetIDName(id)
        code = win32api.HIWORD(wparam)

        if code == win32con.BN_CLICKED:
            if id in (win32con.IDOK, win32con.IDCANCEL) and self.in_label_edit:
                cancel = id == win32con.IDCANCEL
                win32gui.SendMessage(self.list, commctrl.TVM_ENDEDITLABELNOW,
                                     cancel, 0)
                return
            # Button clicks
            if id == win32con.IDOK:
                if not self._CheckSelectionsValid(True):
                    return
                self.selected_ids, self.checkbox_state = self.GetSelectedIDs()
                win32gui.EndDialog(hwnd, id)
            elif id == win32con.IDCANCEL:
                win32gui.EndDialog(hwnd, id)
            elif id_name == "IDC_BUT_CLEARALL":
                for info, spec in self._YieldCheckedChildren():
                    self.UnselectItem(info)
            elif id_name == "IDC_BUT_NEW":
                # Force a new entry in the tree at our location, and begin
                # editing.
                # Add the new item to the tree.
                h = win32gui.SendMessage(self.list, commctrl.TVM_GETNEXTITEM,
                                         commctrl.TVGN_CARET,
                                         commctrl.TVI_ROOT)
                parent_item = self._GetTVItem(h)
                if parent_item[6] == 0:
                    # eeek - parent has no existig children - say we have one
                    # so we can be expanded.
                    update_item, extra = PackTVITEM(h, None, None, None, None,
                                                    None, 1, None)
                    win32gui.SendMessage(self.list, commctrl.TVM_SETITEM, 0,
                                         update_item)

                item_id = self._MakeItemParam(None)
                temp_spec = FolderSpec(None, "New folder")
                hnew = self._InsertFolder(h, temp_spec, None,
                                          commctrl.TVI_FIRST)

                win32gui.SendMessage(self.list, commctrl.TVM_ENSUREVISIBLE, 0,
                                     hnew)
                win32gui.SendMessage(self.list, commctrl.TVM_SELECTITEM,
                                     commctrl.TVGN_CARET, hnew)

                # Allow label editing
                s = win32api.GetWindowLong(self.list, win32con.GWL_STYLE)
                s |= commctrl.TVS_EDITLABELS
                win32api.SetWindowLong(self.list, win32con.GWL_STYLE, s)

                win32gui.SetFocus(self.list)
                self.in_label_edit = True
                win32gui.SendMessage(self.list, commctrl.TVM_EDITLABEL, 0,
                                     hnew)

        self._UpdateStatus()
Beispiel #21
0
 def get_version(self):
     #{
     try:
         #{
         import win32api
         info = win32api.GetFileVersionInfo(self.filename, "\\")
         ms = info["FileVersionMS"]
         ls = info["FileVersionLS"]
         #Return version.
         return win32api.HIWORD(ms), win32api.LOWORD(ms), win32api.HIWORD(
             ls), win32api.LOWORD(ls)
     #}
     except:
         #{
         #No version specified or not windows.
         return 0, 0, 0, 0
Beispiel #22
0
 def OnCommand(cls, hwnd, msg, wparam, lparam):
     cc = cls.command_callbacks.get(hwnd)
     log("OnCommand(%s,%s,%s,%s) command callback=%s", hwnd, msg, wparam,
         lparam, cc)
     if cc:
         cid = win32api.LOWORD(wparam)
         cc(hwnd, cid)
Beispiel #23
0
def GetFileVersion(file_name):
    '''获取指定文件的版本号, 以list[x,x,x,x]形式返回'''
    try:
        info = win32api.GetFileVersionInfo(file_name, os.sep)
        ms = info['FileVersionMS']
        ls = info['FileVersionLS']
        version = [
            win32api.HIWORD(ms),
            win32api.LOWORD(ms),
            win32api.HIWORD(ls),
            win32api.LOWORD(ls)
        ]
        return version
    except Exception:
        print(traceback.format_exc())
    return [0, 0, 0, 0]
Beispiel #24
0
 def OnSize(self, hwnd, msg, wparam, lparam):
     # print "OnSize", self.hwnd_child, win32api.LOWORD(lparam),
     # win32api.HIWORD(lparam)
     if self.hwnd_child is not None:
         x = win32api.LOWORD(lparam)
         y = win32api.HIWORD(lparam)
         win32gui.MoveWindow(self.hwnd_child, 0, 0, x, y, False)
    def OnCommand(self, hwnd, msg, wparam, lparam):
        id = win32api.LOWORD(wparam)
        if id == IDC_BUTTON_SEARCH:
            self.ClearListItems()

            def fill_slowly(q, hwnd):
                import time

                for i in range(20):
                    q.put(("whatever", str(i + 1), "Search result " + str(i)))
                    win32gui.PostMessage(hwnd, WM_SEARCH_RESULT, 0, 0)
                    time.sleep(0.25)
                win32gui.PostMessage(hwnd, WM_SEARCH_FINISHED, 0, 0)

            import threading

            self.result_queue = queue.Queue()
            thread = threading.Thread(target=fill_slowly,
                                      args=(self.result_queue, self.hwnd))
            thread.start()
        elif id == IDC_BUTTON_DISPLAY:
            print("Display button selected")
            sel = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETNEXTITEM,
                                       -1, commctrl.LVNI_SELECTED)
            print("The selected item is", sel + 1)
Beispiel #26
0
 def OnCommand(self, hwnd, msg, wparam, lparam):
     id = win32api.LOWORD(wparam)
     if id == TrayThermostat.Exit:
         log.debug("Quitting")
         win32gui.DestroyWindow(self.hwnd)
     else:
         log.debug("Setting mode - %i", id)
         self.__mode = id
Beispiel #27
0
 def OnCommand(self, hwnd, msg, wparam, lparam):
     id = win32api.LOWORD(wparam)
     if id == 1023:
         self.open()
     elif id == 1024:
         win32gui.DestroyWindow(self.hwnd)
     else:
         print("Unknown command -", id)
Beispiel #28
0
 def OnCommand(self, wparam, lparam):
     code = win32api.HIWORD(wparam)
     id = win32api.LOWORD(wparam)
     if code == win32con.BN_CLICKED:
         text=win32gui.GetDlgItemText(self.window.hwnd, self.control_id)
         conn = self.func()
         conn.setitem('protocol', text)
         p=conn.getitem('protocol')
Beispiel #29
0
 def nativeEventFilter(self, eventType, message):
     if eventType == 'windows_generic_MSG':
         msg = ctypes.wintypes.MSG.from_address(message.__int__())
         if msg.message == win32con.WM_HOTKEY:
             keycode = win32api.HIWORD(msg.lParam)
             modifiers = win32api.LOWORD(msg.lParam)
             self.activeHotkey(keycode, modifiers)
     return False, 0
Beispiel #30
0
 def OnSize(self, hwnd, msg, wparam, lparam):
     """If the dialog box is resized, force a corresponding resize
     of the controls
     """
     w = win32api.LOWORD(lparam)
     h = win32api.HIWORD(lparam)
     self._resize(w, h)
     return 0