[Win32] Retrieve icon for file type?

Mike Fletcher mfletch at tpresence.com
Wed Apr 26 11:21:20 EDT 2000


I'm attempting to use the Windows registry to retrieve (and convert to a
PNG/JPEG) the Windows icons for given files (so that a Windows-based server
can display file-type-specific icons).  I do not seem to be able to find the
function shellapi.ExtractIcon (
http://msdn.microsoft.com/library/psdk/winui/icons_7h2m.htm ) in the Win32
extensions.

Is there an easy way to get at the Shell icons from Python?

def query ( extension):
	''' get icon for the given extension '''
	try:
		path = win32api.RegQueryValue(
			HKEY_CLASSES_ROOT,
			extension,
		)
		filedata = win32api.RegQueryValue(
			HKEY_CLASSES_ROOT,
			'%s\\DefaultIcon'%(path),
		)
		# how do I load the icon data?
		# ExtractIcon?
	except win32api.error:
		return None

__________________________________
 Mike C. Fletcher
 Designer, VR Plumber
 http://members.home.com/mcfletch




More information about the Python-list mailing list