Home

Ivo wrote:
> Richard Townsend wrote:
>> If I have a windows shortcut to a URL, is there a way to get the URL
>> in a Python app?
>>
>> I found some code that uses pythoncom to resolve shortcuts to local
>> files, but I haven't found any examples for URLs.
>>
>> The PyWin32 help mentions the PyIUniformResourceLocator Object, but I
>> couldn't find an example of how to use it.
>>
> do you mean a *.lnk file or a *.url file?

for a link (*.lnk) file:


from win32com.shell import shell
import pythoncom
import os, sys

class PyShortcut(object):
def __init__(self):
self._base = pythoncom.CoCreateInstance(shell.CLSID_ShellLink,
None,

pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink)

def load(self, filename):

self._base.QueryInterface(pythoncom.IID_IPersistFile).Load(f ilename)

def save(self, filename):

self._base.QueryInterface(pythoncom.IID_IPersistFile).Save(f ilename, 0)

def __getattr__(self, name):
if name != "_base":
return getattr(self._base, name)


if __name__=="__main__":
lnk = PyShortcut()
lnk.load("path to your shortcut file including the .lnk extention
even if you don't see it in windows")
print "Location:", lnk.GetPath(shell.SLGP_RAWPATH)[0]

previous
next

Re: Object Management
Re: help with vector<vector<double>>
Re: how to implement sum of bits using template metaprogramming
scope, modyfing outside object from inside the method
Re: python 2.5 problems
konferencje
łóżka nowoczesne
audiobooki
Tanie książki
Sprzęt RTV i foto