Python implements the method for calculating the resource icon crc value, pythoncrc

Source: Internet
Author: User
Tags crc32

Python implements the method for calculating the resource icon crc value, pythoncrc

This article describes how to use python to calculate the resource icon crc value. The specific method is as follows:

The key to implementing this function is to parse the resource information, find the icon data, and then calculate the crc of the data.

The specific implementation code is as follows:

  def _get_iconcrc(self, file_path):     """     Generates the crc32 hash of the icon of the file.     @return: str, the str value of the file's icon     """     iconData = ""      mype = pefile.PE(file_path)     if hasattr(mype, "DIRECTORY_ENTRY_RESOURCE"):       resIcons = filter(lambda x: x.id==pefile.RESOURCE_TYPE['RT_ICON'], mype.DIRECTORY_ENTRY_RESOURCE.entries)       if len(resIcons)>0:         resIcons = resIcons[0]         if hasattr(resIcons, "directory"):           for resId in resIcons.directory.entries:             if hasattr(resId, 'directory'):               for resLang in resId.directory.entries:                 iconData += mype.get_data(resLang.data.struct.OffsetToData, resLang.data.struct.Size)          if not iconData:       print "not iconData"       return None     else:       return self._crc32(iconData) 

I hope this article will help you with Python programming.


How does python calculate the value of crc32?

Binascii. crc32
 
Python implementation click the taskbar icon pop-up window

Hello, python visualization has several packages:
Tk
Wxpython
You can find some examples online.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.