def which_file(fname):
	"""prints paths for fname where fname can be found,
	in case of .dll loads it"""
	files = []
	path = win32api.GetEnvironmentVariable('PATH')
	# try paths as described in MSDN
	dirs = [os.getcwd(), win32api.GetSystemDirectory(), win32api.GetWindowsDirectory()] + path.split(';')
	dirs_norm = []
	dirs_l = []
	for d in dirs:
		dn = d.lower()
		if dn not in dirs_l:
			dirs_l.append(dn)
			dirs_norm.append(d)
	for d in dirs_norm:
		fname2 = os.path.join(d, fname)
		if os.path.exists(fname2):
			if fname2 not in files:
				files.append(fname2)
	if files:
		print('\n'.join([get_file_info(f) for f in files]))
	h = 0
	if fname.lower().endswith('.dll'):
		print('\ttrying to load "%s" ...' % (fname))
		try:
			h = win32api.LoadLibrary(fname)
			if h:
				dll_name = win32api.GetModuleFileName(h)
				print('\t%s loaded' % (dll_name))
		except:
			print('\tCannot load "%s" !!!' % (fname))
prints paths for fname where fname can be found,
	in case of .dll loads it
recipes/Python/576522_Searching_dll_exe_files/recipe-576522.py