当前位置: 首页>>代码示例>>PHP>>正文


PHP COM::CreateShortcut方法代码示例

本文整理汇总了PHP中COM::CreateShortcut方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::CreateShortcut方法的具体用法?PHP COM::CreateShortcut怎么用?PHP COM::CreateShortcut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在COM的用法示例。


在下文中一共展示了COM::CreateShortcut方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: relocateShortcut

 private static function relocateShortcut()
 {
     $WshShell = new COM('WScript.Shell');
     $desktop = $WshShell->SpecialFolders('Desktop');
     $startmenu = $WshShell->SpecialFolders('Programs');
     $startmenu .= DIRECTORY_SEPARATOR . 'XAMPP for Windows';
     $links = array();
     $links[realpath($desktop . DIRECTORY_SEPARATOR . 'XAMPP Control Panel.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'Description' => 'XAMPP Control Panel');
     $links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Control Panel.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp-control.exe', 'Description' => 'XAMPP Control Panel');
     $links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Setup.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_setup.bat', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_cli.exe', 'Description' => 'XAMPP Setup');
     $links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Shell.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_shell.bat', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_cli.exe', 'Description' => 'XAMPP Shell');
     $links[realpath($startmenu . DIRECTORY_SEPARATOR . 'XAMPP Uninstall.lnk')] = array('TargetPath' => self::$xampppath . DIRECTORY_SEPARATOR . 'uninstall_xampp.bat', 'WorkingDirectory' => self::$xampppath, 'WindowStyle' => 1, 'IconLocation' => self::$xampppath . DIRECTORY_SEPARATOR . 'xampp_cli.exe', 'Description' => 'XAMPP Uninstall');
     foreach ($links as $shortcut => $value) {
         if (is_int($shortcut)) {
             continue;
         }
         $oldfileperm = fileperms($shortcut);
         if (!chmod($shortcut, 0666) && !is_writable($shortcut)) {
             throw new XAMPPException('File \'' . $shortcut . '\' is not writable.');
         }
         $ShellLink = $WshShell->CreateShortcut($shortcut);
         $ShellLink->TargetPath = $value['TargetPath'];
         $ShellLink->WorkingDirectory = $value['WorkingDirectory'];
         $ShellLink->WindowStyle = $value['WindowStyle'];
         $ShellLink->IconLocation = $value['IconLocation'];
         $ShellLink->Description = $value['Description'];
         $ShellLink->Save();
         $ShellLink = null;
         chmod($shortcut, $oldfileperm);
     }
     $WshShell = null;
     return;
 }
开发者ID:TheSkyNet,项目名称:railoapacheportable,代码行数:33,代码来源:package__xampp.php

示例2: relocateShortcut

 private static function relocateShortcut()
 {
     $WshShell = new COM('WScript.Shell', null, CP_UTF8);
     $FSO = new COM('Scripting.FileSystemObject', null, CP_UTF8);
     $desktop = $WshShell->SpecialFolders('Desktop');
     $startmenu = $WshShell->SpecialFolders('Programs');
     $startmenu = $FSO->BuildPath($startmenu, utf8_encode('XAMPP for Windows'));
     $xampppath = utf8_encode(self::$xampppath);
     $links = array();
     $links[$FSO->BuildPath($desktop, utf8_encode('XAMPP Control Panel.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'Description' => utf8_encode('XAMPP Control Panel'));
     $links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Control Panel.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp-control.exe')), 'Description' => utf8_encode('XAMPP Control Panel'));
     $links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Setup.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp_setup.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Setup'));
     $links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Shell.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('xampp_shell.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Shell'));
     $links[$FSO->BuildPath($startmenu, utf8_encode('XAMPP Uninstall.lnk'))] = array('TargetPath' => $FSO->BuildPath($xampppath, utf8_encode('uninstall_xampp.bat')), 'WorkingDirectory' => $xampppath, 'WindowStyle' => 1, 'IconLocation' => $FSO->BuildPath($xampppath, utf8_encode('xampp_cli.exe')), 'Description' => utf8_encode('XAMPP Uninstall'));
     foreach ($links as $shortcut => $value) {
         if (!$FSO->FileExists($shortcut)) {
             continue;
         }
         try {
             $shortcut_file = $FSO->GetFile($shortcut);
             $oldfileperm = $shortcut_file->attributes;
             if (($oldfileperm & 1) == 1) {
                 $shortcut_file->attributes += -1;
             }
         } catch (Exception $e) {
             throw new XAMPPException('File \'' . utf8_decode($shortcut) . '\' is not writable.');
         }
         $ShellLink = $WshShell->CreateShortcut($shortcut);
         $ShellLink->TargetPath = $value['TargetPath'];
         $ShellLink->WorkingDirectory = $value['WorkingDirectory'];
         $ShellLink->WindowStyle = $value['WindowStyle'];
         $ShellLink->IconLocation = $value['IconLocation'];
         $ShellLink->Description = $value['Description'];
         $ShellLink->Save();
         $ShellLink = null;
         $shortcut_file->attributes = $oldfileperm;
         $shortcut_file = null;
     }
     $FSO = null;
     $WshShell = null;
     return;
 }
开发者ID:join1603,项目名称:wme2a,代码行数:42,代码来源:package__xampp.php

示例3: COM

<?php

$wsh = new COM('WScript.Shell') or die;
$shortcut = $wsh->CreateShortcut(dirname(__FILE__) . '/test.lnk');
$shortcut->TargetPath = 'shortcut.php';
$shortcut->Save();
$wsh = null;
开发者ID:coderhelps,项目名称:try_samples,代码行数:7,代码来源:shortcut.php


注:本文中的COM::CreateShortcut方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。