EmEditor ホーム - EmEditor ヘルプ - EmEditor マクロ リファレンス - チュートリアル

ショートカットを作成する

ショートカットを作成するには、WshShell オブジェクトの CreateShortcut メソッドを利用することができます。

この例では、開いているファイルへのショートカットをデスクトップに作成します。

[JavaScript]

if( document.FullName == "" ) {
    alert( "The file is untitled." );
}
else {
    WshShell = new ActiveXObject( "WScript.Shell" );
    strDesktop = WshShell.SpecialFolders("Desktop");
    oShellLink = WshShell.CreateShortcut(strDesktop + "\\Shortcut to My File.lnk");
    oShellLink.TargetPath = document.FullName;
    oShellLink.WindowStyle = 1;
    oShellLink.Description = "Shortcut to My File";
    oShellLink.WorkingDirectory = strDesktop;
    oShellLink.Save();
}

[VBScript]

If document.FullName = "" Then
    alert "The file is untitled."
Else
    Set WshShell = CreateObject( "WScript.Shell" )
    strDesktop = WshShell.SpecialFolders("Desktop")
    set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut to My File.lnk")
    oShellLink.TargetPath = document.FullName
    oShellLink.WindowStyle = 1
    oShellLink.Description = "Shortcut to My File"
    oShellLink.WorkingDirectory = strDesktop
    oShellLink.Save
End If

参考

Microsoft MSDN ライブラリ: CreateShortcut メソッド

このページのフィードバックを送信

Copyright © 2003-2007 by Emurasoft, Inc.