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

痞子三分冷 提交于 2020-01-16 06:12:18

问题


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.


回答1:


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:

  • Java2COM
  • JACOB
  • JCOM



回答2:


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.



来源:https://stackoverflow.com/questions/3995097/win32api-how-to-create-a-shortcut-lnk-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!