Seite 1 von 1

Symbol einer Verknüpfung, die aus einer DLL stammt

Veröffentlicht: 17. April 2026 - 14:24 Uhr
von Stan
Hallo,

wäre es möglich, den Setup-Hilfsfunktionen für die Erstellung von Verknüpfungen ein Argument hinzuzufügen, mit dem der Benutzer ein DLL-Symbol und dessen Index auswählen kann? Zum Beispiel: `

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

Dadurch wäre ein Symbol wie dieses möglich : https://renenyffenegger.ch/development/ ... es-100.png (es ist nicht die neueste Version, aber Sie verstehen das Prinzip :D).

Vielen Dank im Voraus!

Schönen Tag noch.

Stan

Betreff: Symbol einer Verknüpfung aus einer DLL

Veröffentlicht: 17. April 2026 - 14:54 Uhr
von dcardon
Hallo Stan,

ich denke, das ist etwas zu spezifisch, um es direkt in die Funktion `create_desktop_shortcut` zu integrieren.

Warum fügen wir nicht eine Funktion zum Extrahieren von Symbolen zu den Setup-Helfern für `update_package` hinzu? :-)

Wir haben das bereits mit einer kundenspezifischen Lösung in einem internen Paket umgesetzt. Ich prüfe, ob sich das verallgemeinern lässt.

Viele Grüße,

Denis

Betreff: Symbol einer Verknüpfung aus einer DLL

Veröffentlicht: 17. April 2026 - 15:45 Uhr
von Stan
Guten Morgen,

Vielen Dank für Ihre Antwort.
Nach eingehender Recherche im setuphelpers-Code stellte ich fest, dass er eigentlich recht einfach ist (oder zumindest nehme ich das an).

Wenn wir uns die Funktion zum Erstellen von Verknüpfungen ansehen (https://www.wapt.fr/apidoc/wapt-2.6/win ... e_shortcut)
Wir finden zwei Stellen (in den letzten 3 Zeilen, die ich kommentiert habe) in Bezug auf diesen Index; es fehlt wohl nur noch das Argument.

Code: Alle auswählen

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 
Alles, was dazu nötig wäre, wäre Folgendes (?):

Code: Alle auswählen

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), '') 
Dank im Voraus !