(Code compatible ASCII et Unicode)
Code : Tout sélectionner
Interface IUniformResourceLocator Extends IUnknown
SetURL(a.s, b.l)
GetURL(a.i)
InvokeCommand(a.i)
EndInterface
#CLSCTX_INPROC_SERVER = 1
Procedure.l CreateShortcutToURL(pszURL.s, pszLinkFile.s)
Protected *IUniformResourceLocator, hRes.l, Res.l=0
Protected pURL.IUniformResourceLocator
Protected pPF.IPersistFile
CompilerIf #PB_Compiler_Unicode = 1
*IUniformResourceLocator = ?IID_IUniformResourceLocatorW
CompilerElse
*IUniformResourceLocator = ?IID_IUniformResourceLocatorA
CompilerEndIf
Debug *IUniformResourceLocator
;// Create an IUniformResourceLocator object
If CoCreateInstance_(?CLSID_InternetShortcut, #Null, #CLSCTX_INPROC_SERVER, *IUniformResourceLocator, @pURL) >= #S_OK
If pURL\SetURL(pszURL, 0) >= #S_OK
If pURL\QueryInterface (?IID_IPersistFile, @pPF) >= #S_OK
;// Save the shortcut via the IPersistFile::Save member function.
If pPF\Save(pszLinkFile, #True) >= #S_OK
Res = 1
EndIf
;// Release the pointer To IPersistFile.
pPF\Release ()
EndIf
EndIf
;// Release the pointer To IUniformResourceLocator
pURL\Release ()
EndIf
ProcedureReturn Res
EndProcedure
DataSection
;CLSID_InternetShortcut 0xFBF23B40, 0xE3F0, 0x101B, 0x84, 0x88, 0x00, 0xAA, 0x00, 0x3E, 0x56, 0xF8
CLSID_InternetShortcut:
Data.l $FBF23B40
Data.w $E3F0, $101B
Data.b $84, $88, $00, $AA, $00, $3E, $56, $F8
;IID_IUniformResourceLocatorW 0xCABB0DA0, 0xDA57, 0x11CF, 0x99, 0x74, 0x00, 0x20, 0xAF, 0xD7, 0x97, 0x62
IID_IUniformResourceLocatorW:
Data.l $CABB0DA0
Data.w $DA57,$11CF
Data.b $99,$74,$00,$20,$AF,$D7,$97,$62
;IID_IUniformResourceLocatorA 0xFBF23B80, 0xE3F0, 0x101B, 0x84, 0x88, 0x00, 0xAA, 0x00, 0x3E, 0x56, 0xF8
IID_IUniformResourceLocatorA:
Data.l $FBF23B80
Data.w $E3F0,$101B
Data.b $84,$88,$00,$AA,$00,$3E,$56,$F8
;IID_IPersistFile 0000010b-0000-0000-C000-000000000046
IID_IPersistFile:
Data.l $0000010b
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection
CoInitialize_(0)
Debug CreateShortcutToURL("http://support.microsoft.com","C:\Users\Nico\Desktop\mssupport.url")
CoUninitialize_()
Code : Tout sélectionner
Interface IUniformResourceLocator Extends IUnknown
SetURL(a.s, b.l)
GetURL(a.i)
InvokeCommand(a.i)
EndInterface
#CLSCTX_INPROC_SERVER = 1
Procedure.s GetURLToShortcut(LinkUrl.s)
Protected *IUniformResourceLocator
Protected pURL.IUniformResourceLocator
Protected *pszURL, Url.s
CompilerIf #PB_Compiler_Unicode = 1
*IUniformResourceLocator = ?IID_IUniformResourceLocatorW
CompilerElse
*IUniformResourceLocator = ?IID_IUniformResourceLocatorA
CompilerEndIf
If CoCreateInstance_(?CLSID_InternetShortcut, #Null, #CLSCTX_INPROC_SERVER, *IUniformResourceLocator, @pURL) >= #S_OK
If pURL\QueryInterface(?IID_IPersistFile, @LinkFile.IPersistFile) >= #S_OK
If LinkFile\Load(LinkUrl, 0)>= #S_OK
If pURL\GetURL(@*pszURL) >= #S_OK
If *pszURL <> 0
Url = PeekS(*pszURL)
CoTaskMemAlloc_(*pszURL)
EndIf
EndIf
EndIf
LinkFile\Release()
EndIf
pURL\Release()
EndIf
ProcedureReturn Url
EndProcedure
DataSection
;CLSID_InternetShortcut 0xFBF23B40, 0xE3F0, 0x101B, 0x84, 0x88, 0x00, 0xAA, 0x00, 0x3E, 0x56, 0xF8
CLSID_InternetShortcut:
Data.l $FBF23B40
Data.w $E3F0, $101B
Data.b $84, $88, $00, $AA, $00, $3E, $56, $F8
;IID_IUniformResourceLocatorW 0xCABB0DA0, 0xDA57, 0x11CF, 0x99, 0x74, 0x00, 0x20, 0xAF, 0xD7, 0x97, 0x62
IID_IUniformResourceLocatorW:
Data.l $CABB0DA0
Data.w $DA57,$11CF
Data.b $99,$74,$00,$20,$AF,$D7,$97,$62
;IID_IUniformResourceLocatorA 0xFBF23B80, 0xE3F0, 0x101B, 0x84, 0x88, 0x00, 0xAA, 0x00, 0x3E, 0x56, 0xF8
IID_IUniformResourceLocatorA:
Data.l $FBF23B80
Data.w $E3F0,$101B
Data.b $84,$88,$00,$AA,$00,$3E,$56,$F8
;IID_IPersistFile 0000010b-0000-0000-C000-000000000046
IID_IPersistFile:
Data.l $0000010b
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection
CoInitialize_(0)
Debug GetURLToShortcut("C:\Users\Nico\Desktop\test.url")
CoUninitialize_()