| Server IP : 123.56.80.60 / Your IP : 216.73.216.78 Web Server : Apache/2.4.54 (Win32) OpenSSL/1.1.1s PHP/7.4.33 mod_fcgid/2.3.10-dev System : Windows NT iZhx3sob14hnz7Z 10.0 build 14393 (Windows Server 2016) i586 User : SYSTEM ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Program Files/python/Lib/site-packages/win32comext/shell/demos/ |
Upload File : |
import pythoncom
from win32com.shell import shell, shellcon
import win32api, os
class InternetShortcut:
def __init__( self ):
self._base = pythoncom.CoCreateInstance(
shell.CLSID_InternetShortcut, None,
pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IUniformResourceLocator
)
def load( self, filename ):
# Get an IPersist interface
# which allows save/restore of object to/from files
self._base.QueryInterface( pythoncom.IID_IPersistFile ).Load( filename )
def save( self, filename ):
self._base.QueryInterface( pythoncom.IID_IPersistFile ).Save( filename, 1 )
def __getattr__( self, name ):
if name != "_base":
return getattr( self._base, name )
temp_dir=win32api.GetTempPath()
linkname=win32api.GetTempFileName(temp_dir, 'ish')[0]
print('Link:',linkname)
os.remove(linkname)
linkname+='.url'
ish=InternetShortcut()
ish.SetURL('https://github.com/mhammond/pywin32')
ish.save(linkname)
## IUniformResourceLocator also give access to IPropertySetStorage
pss=ish.QueryInterface(pythoncom.IID_IPropertySetStorage)
ps=pss.Open(shell.FMTID_InternetSite)
property_ids=[(k,v) for k,v in shellcon.__dict__.items() if k.startswith('PID_INTSITE_')]
for pname, pval in property_ids:
print(pname, ps.ReadMultiple((pval,))[0])
ps=pss.Open(shell.FMTID_Intshcut)
property_ids=[(k,v) for k,v in shellcon.__dict__.items() if k.startswith('PID_IS_')]
for pname, pval in property_ids:
print(pname, ps.ReadMultiple((pval,))[0])
new_sh=InternetShortcut()
new_sh.load(linkname)
new_sh.InvokeCommand('Open')