Flash保存游戏链接的快捷方式到桌面

 1 /** 
 2          * 桌面保存快捷方式
 3          */
 4         public static function addDesktopUrl(strTitle:String, strUrl:String, onFinish:Function = null,onError:Function = null):void
 5         {
 6             try
 7             {
 8                 var kSaveFile:FileReference = new FileReference();                
 9                 var strFileContent:String = "[InternetShortcut]" + "\n";
10                 strFileContent +=  "URL=" + strUrl+"\n";
11                 strFileContent +=  "IconFile=" +"\n";
12                 strFileContent +=  "IconIndex=0" +"\n";
13                 if(onFinish!=null){
14                     kSaveFile.addEventListener(Event.COMPLETE, onFinish);    
15                 }
16                 if(onError!=null){
17                     kSaveFile.addEventListener(IOErrorEvent.IO_ERROR, onError);
18                 }
19                 kSaveFile.save(strFileContent, strTitle + ".url");                
20             }
21             catch (e:Error) 
22             {
23             }
24         }

 这里用了一个字符串来动态的生成桌面快捷方式

 如果把一个桌面快捷方式拖到文本框中,可以看到,这个快捷方式是可以用文本框打开的。打开后看到的内容就是类似上面的字符串生成的格式。

原文地址:https://www.cnblogs.com/hisiqi/p/2869750.html