Icona di un collegamento proveniente da una DLL

Condividi qui la tua esperienza e i tuoi pensieri su WAPT / Vieni qui e parla della tua esperienza con Wapt, della tua opinione e dei tuoi desideri
Regole del forum
Regole del forum della community
* Supporto in inglese su www.reddit.com/r/wapt
* Il supporto della community in francese è disponibile su questo forum
* Si prega di anteporre [RISOLTO] al titolo dell'argomento se è stato risolto.
* Si prega di non modificare un argomento contrassegnato con [RISOLTO]. Aprire un nuovo argomento facendo riferimento a quello precedente.
* Specificare la versione di WAPT installata (1.8.2 / 2.0 / 2.1 / 2.2 / ecc.) e l'edizione Enterprise / Discovery.
* Specificare il sistema operativo del server (Linux / Windows) e la versione (Debian Stretch/Buster - CentOS 7 - Windows Server 2012/2016/2019).
* Specificare il sistema operativo della macchina di amministrazione/creazione dei pacchetti (Windows 7 / 10)
. * Come in qualsiasi forum della community, il supporto è fornito volontariamente dai membri. Se hai bisogno di supporto commerciale, puoi contattare il reparto vendite di Tranquil IT al numero 02.40.97.57.55
Risposta
stan
Messaggi: 36
Registrazione: 26 maggio 2025 - 22:16

17 aprile 2026 - 14:24

Ciao,

sarebbe possibile aggiungere un argomento alle funzioni di setuphelper per la creazione di collegamenti, che permetta all'utente di scegliere l'icona di una DLL e il suo indice? Ad esempio: `

create_desktop_shortcut(label="Test", target="ms-settings:network-airplanemode", icon_dll="C:\Windows\System32\imageres.dll", index_dll=100)`

Questo permetterebbe di ottenere un'icona come questa : https://renenyffenegger.ch/development/ ... es-100.png (non è l'ultima versione, ma l'idea è chiara :D).

Grazie in anticipo!

Buona giornata.

Stan
Sinceramente,

Stan

-

Informazioni:

Codice: Seleziona tutto

OS Administration : Windows 11 25H2
OS Server : Debian 12
WAPT Version : 2.6.1.17813
VSCode Version : 1.116.0
Avatar utente
dcardon
Esperto WAPT
Messaggi: 1970
Registrazione: 18 giugno 2014 - 09:58
Ubicazione: Saint Sébastien sur Loire
Contatto:

17 aprile 2026 - 14:54

Ciao Stan,

credo che questa richiesta sia un po' troppo specifica per essere integrata direttamente nella funzione `create_desktop_shortcut`.

Tuttavia, perché non aggiungere una funzione di estrazione delle icone agli helper di configurazione per `update_package`? :-)

Lo abbiamo già fatto con una soluzione personalizzata in un pacchetto interno per un cliente. Vedrò se è qualcosa che si può generalizzare.

Cordiali saluti,

Denis
Denis Cardon - Tranquil IT
Condividi le tue esperienze su WAPT! Inviaci gli URL dei tuoi blog e articoli nella "La tua opinione del forum e li pubblicheremo sul di WAPT
stan
Messaggi: 36
Registrazione: 26 maggio 2025 - 22:16

17 aprile 2026 - 15:45

Buongiorno,

Grazie per la sua risposta.
Dopo aver esaminato il codice di setuphelpers, ho notato che in realtà era piuttosto semplice (o almeno così suppongo).

Se guardiamo alla funzione di creazione di scorciatoie (https://www.wapt.fr/apidoc/wapt-2.6/win ... e_shortcut)
Troviamo due punti (nelle ultime 3 righe che ho commentato) in relazione a questo indice, tutto ciò che mancherebbe sarebbe aggiungere l'argomento, suppongo.

Codice: Seleziona tutto

def create_shortcut(path, target='', arguments='', wDir='', icon=''):
    r"""Create a windows shortcut

    Args:
        path (str) : As what file should the shortcut be created?
        target (str): What command should the desktop use?
        arguments (str): What arguments should be supplied to the command?
        wdir (str) : working directory. What folder should the command start in?
        icon (str or list) : filename or (filename, index) (only for file sc)
                              What icon should be used for the shortcut

    Returns:
        None

    >>> create_shortcut(r'c:\\tmp\\test.lnk',target='c:\\wapt\\waptconsole.exe')
    """
    ext = os.path.splitext(path)[1].lower()
    if ext == '.url':
        with open(path, 'w') as shortcut:
            shortcut.write('[InternetShortcut]\n')
            shortcut.write('URL=%s\n' % target)
            shortcut.write('IconFile="%s"\n' % icon)
            shortcut.write('IconIndex=0\n') # ICI
    else:
        winshell.CreateShortcut(path, target, arguments, wDir, (icon, 0), '')# ET ICI 
Tutto ciò che servirebbe è questo (?):

Codice: Seleziona tutto

def create_shortcut(path, target='', arguments='', wDir='', icon='', index_icon=''):
    r"""Create a windows shortcut

    Args:
        path (str) : As what file should the shortcut be created?
        target (str): What command should the desktop use?
        arguments (str): What arguments should be supplied to the command?
        wdir (str) : working directory. What folder should the command start in?
        icon (str or list) : filename or (filename, index) (only for file sc)
                              What icon should be used for the shortcut

    Returns:
        None

    >>> create_shortcut(r'c:\\tmp\\test.lnk',target='c:\\wapt\\waptconsole.exe')
    """
    ext = os.path.splitext(path)[1].lower()
    index_icon = index_icon if os.path.splitext(icon)[1].lower() == '.dll' else 0 
    if ext == '.url':
        with open(path, 'w') as shortcut:
            shortcut.write('[InternetShortcut]\n')
            shortcut.write('URL=%s\n' % target)
            shortcut.write('IconFile="%s"\n' % icon)
            shortcut.write('IconIndex="%s"\n' % index_icon)
    else:
        winshell.CreateShortcut(path, target, arguments, wDir, (icon, index_icon), '') 
Grazie in anticipo !
Sinceramente,

Stan

-

Informazioni:

Codice: Seleziona tutto

OS Administration : Windows 11 25H2
OS Server : Debian 12
WAPT Version : 2.6.1.17813
VSCode Version : 1.116.0
stan
Messaggi: 36
Registrazione: 26 maggio 2025 - 22:16

26 giugno 2026 - 12:16

Buongiorno,

Grazie per aver preso in considerazione la mia richiesta viewtopic.php?t=4642

Potreste gentilmente prendere in considerazione anche questa possibilità?

Ho provato a implementare questa funzione in un pacchetto WAPT, utilizzando quello di setuphelpers, e funziona correttamente con l'indice.

https://www.wapt.fr/apidoc/wapt-2.6/win ... e_shortcut

Codice: Seleziona tutto

def create_isolation_shortcut(path, target='', wdir='', icon='', index=0):
    ext = os.path.splitext(path)[1].lower()
    if ext == '.url':
        with open(path, 'w') as shortcut:
            shortcut.write('[InternetShortcut]\n')
            shortcut.write('URL=%s\n' % target)
            shortcut.write('IconFile=%s\n' % icon)
            shortcut.write('IconIndex=%d\n' % index)
    else:
        winshell.CreateShortcut(path, target, wdir, (icon, index), '')

create_isolation_shortcut(path=os.path.join(user_desktop(), "✈ ISOLEMENT D'URGENCE.url"), target="ms-settings:network-airplanemode", icon="C:\\Windows\\System32\\imageres.dll", index=100)
E ho ottenuto l'icona che volevo, quella con l'indice 100 (https://i.imgur.com/d1k5nQ8.png)

Grazie in anticipo ! :D
Sinceramente,

Stan

-

Informazioni:

Codice: Seleziona tutto

OS Administration : Windows 11 25H2
OS Server : Debian 12
WAPT Version : 2.6.1.17813
VSCode Version : 1.116.0
Risposta