(self)
| 22 | |
| 23 | class ShellTester(win32com.test.util.TestCase): |
| 24 | def testShellLink(self): |
| 25 | desktop = str(shell.SHGetSpecialFolderPath(0, CSIDL_DESKTOP)) |
| 26 | num = 0 |
| 27 | shellLink = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink) |
| 28 | persistFile = shellLink.QueryInterface(pythoncom.IID_IPersistFile) |
| 29 | names = [os.path.join(desktop, n) for n in os.listdir(desktop)] |
| 30 | programs = str(shell.SHGetSpecialFolderPath(0, CSIDL_PROGRAMS)) |
| 31 | names.extend([os.path.join(programs, n) for n in os.listdir(programs)]) |
| 32 | for name in names: |
| 33 | try: |
| 34 | persistFile.Load(name,STGM_READ) |
| 35 | except pythoncom.com_error: |
| 36 | continue |
| 37 | # Resolve is slow - avoid it for our tests. |
| 38 | #shellLink.Resolve(0, shell.SLR_ANY_MATCH | shell.SLR_NO_UI) |
| 39 | fname, findData = shellLink.GetPath(0) |
| 40 | unc = shellLink.GetPath(shell.SLGP_UNCPRIORITY)[0] |
| 41 | num += 1 |
| 42 | if num == 0: |
| 43 | # This isn't a fatal error, but is unlikely. |
| 44 | print "Could not find any links on your desktop or programs dir, which is unusual" |
| 45 | |
| 46 | def testShellFolder(self): |
| 47 | sf = shell.SHGetDesktopFolder() |
nothing calls this directly
no test coverage detected