Mot
Mot

Reputation: 29590

Win32API: how to create a shortcut (.lnk file)

I'm a Java developer, so please excuse my ignorance.

I want to create a shortcut to an executable, e.g., in the user's autostart or send-to folder (I don't want an installer to do that, because the installer usually is run by an administrator). What API (C preferred) I could use for that task (maybe using JNA)? Thanks in advance.

Upvotes: 1

Views: 1382

Answers (2)

Garett
Garett

Reputation: 16838

As @Hans indicated, it requires COM (via ShellLinkObject or WScript.Shell). In Java you can call COM objects using a Java to COM bridge. There are a few available, ranging from free to commercial. A couple that I know of are:

Upvotes: 1

Hans Passant
Hans Passant

Reputation: 942187

It requires using COM, ShellLinkObject from shell32.dll. No idea what that takes in Java, but you'll find C# code in my answer in this thread.

Upvotes: 1

Related Questions