Atitit.创建快捷方式 windows快捷方式的原理

来源:互联网 发布:bigbang胜利知乎 编辑:程序博客网 时间:2024/06/06 08:40

Atitit.创建快捷方式 windows快捷方式的原理

 

 

1Windows中有2种快捷方式的文件:1

2Jshortcut2

2.1. 提示新不上jshortcut.dll2

2.2. 使用win api实现3

2.3. 使用WshShell  com实现3

2.4. Win没提供cli格式的方法3

34

4Attilax的总结4

5Ref4

6Winapi code4

7--end6

 

1. Windows中有2种快捷方式的文件:

1、快捷方式文件是二进制文件;

2、Internet快捷方式文件,格式和INI文件一样,扩展名为 .URL。

 

作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙,  EMAIL:1466519819@qq.com

转载请注明来源: http://blog.csdn.net/attilax

 

 

 

在此学习一下Internet快捷方式文件。

 

Internet快捷方式的文件格式如下: 

[DEFAULT]

BASEURL=

 

[InternetShortcut]

URL=

WorkingDirectory=

ShowCommand=

IconIndex=

IconFile=

Modified=

HotKey=

 

其中

· BASEURL、URL和WorkingDirectory这3项的含义是不言而明的。

· ShowCommand规定Internet Explorer启动后窗口的初始状态:7表示最小化,3表示最大化;如果没有ShowCommand这一项的话则表示正常大小。

· IconFile和IconIndex用来为Internet快捷方式指定图标;如果你不想指定图标,Windows会使用缺省的Internet快捷方式图标。

· HotKey指定一个整数值;HotKey的值及其含义见附录。

 

2. Jshortcut

 

JShortcut - A Java Native Interface (JNI) to …

翻译此页

This page contains information, documentation, and downloads for JShortcutJShortcut isa Java package with a native library that allows a Java application to create ...

 

 

GitHub - jimmc jshortcut  Java JNI interface to access Windows shortcuts.htm

 

http://alumnus.caltech.edu/~jimmc/jshortcut/download/index.html

Jim McBeathhttp://www.alumni.caltech.edu/~jimmc

 

 

2.1. 提示新不上jshortcut.dll

Bg na feodg jshortcut.jar yda d dir hto...zo ok le ..

 

Se,yeu tips  31bit d ,mafe ....give up..le..

Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\workspace 空格\AtiPlatf\WEB-INF\lib_dll\jshortcut.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform

at java.lang.ClassLoader$NativeLibrary.load(Native Method)

at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1937)

at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1822)

at java.lang.Runtime.load0(Runtime.java:809)

at java.lang.System.load(System.java:1086)

at net.jimmc.jshortcut.JShellLink.<clinit>(JShellLink.java:100)

at com.attilax.util.ShortCut.createShortCut(ShortCut.java:31)

at com.attilax.util.ShortCut.main(ShortCut.java:17)

 

 

2.2. 使用win api实现

 

 

用指定的类标识符创建一个Com对象,用指定的类标识符创建一个未初始化的对象。当在本机中只创建一个对象时,可以调用CoCreateInstance;在远程系统中创建一个对象时,可以调用CoCreateInstanceEx;创建多个同一CLSID的对象时可以参考CoGetClassObject 函数。

2.3. 使用WshShell  com实现

Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\学习天地.lnk")

 

2.4. Win没提供cli格式的方法

 

3.  

4. Attilax的总结

使用ini格式的url算兰..

5. Ref

java创建快捷方式(作者 ice古雨) - - ITeye技术网站.htm

()创建快捷方式到桌面的脚本命令_singularpoint_新浪博客.htm

Internet快捷方式-vivieu-ChinaUnix博客.htm

命令行创建快捷方式-vivieu-ChinaUnix博客.htm

CoCreateInstance_百度百科.htm

CoCreateInstance具体内部实现 - IT民工 博客频道 - CSDN.NET.htm

 

6. Winapi code

 

  hr = CoCreateInstance(CLSID_ShellLink, NULL,
       CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pisl);

   IPersistFile* pIPF;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//这里是我们要创建快捷方式的原始文件地址
   pisl->SetPath("c:\\windows\\notepad.exe");
   hr = pisl->QueryInterface(IID_IPersistFile, (void**)&pIPF);
   if (SUCCEEDED(hr))
   {

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//这里是我们要创建快捷方式的目标地址


    pIPF->Save(L"c:\记事本.lnk", FALSE);
    pIPF->Release();

 

 

h = CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,

IID_IShellLink, (PVOID*)&shellLink );

if (FAILED(h)) {

errStr = "Failed to create IShellLink";

goto err;

}

 

h = shellLink->QueryInterface(IID_IPersistFile, (PVOID*)&persistFile);

if (FAILED(h)) {

errStr = "Failed to get IPersistFile";

goto err;

}

 

 

7. --end

0 0
原创粉丝点击