【问题标题】:Is this possible to get a SHARE .lnk target?这有可能获得 SHARE .lnk 目标吗?
【发布时间】:2016-09-26 07:17:50
【问题描述】:

我正在使用一些 Windows WebServers 在一个企业中开发一个 php 项目。我的问题是我不知道如何使用 PHP 读取 SHARE .lnk 快捷方式的目标。

我可以读取 .lnk 快照的目标,如下所示:'C:\Users\LoL'。

但我无法获得这样的 .lnk 快照的目标:'\\server\share\dir'。

你知道任何可以让我读取这个目标的 php 函数吗?

提前谢谢你!

【问题讨论】:

    标签: php windows shortcut network-shares


    【解决方案1】:

    我找到了解决自己问题的方法。

    我发现读取具有类似“\server\share”这样的目标的共享 .lnk 快捷方式的最佳解决方案是 COM 对象。 p>

    从 PHP 5.4.5 开始,COM 和 DOTNET 不再内置于 php 核心中。您必须在 php.ini 中添加 COM 支持:

    [COM_DOT_NET]
    extension=php_com_dotnet.dll
    

    要在 PHP 中读取共享 .lnk 快捷方式的目标,您必须使用以下说明:

    <?php
    
        // create the object
        $wsh = new COM('WScript.Shell');
    
        // $wsh->CreateShortcut method READS, if the file already exists. 
        $lnk=$wsh->CreateShortcut('ShortcutPath.lnk');
    
        // show the target
        echo $lnk->TargetPath,"\n";
    ?>
    

    希望对你有帮助。

    我告诉你一些对我有帮助的资源:

    【讨论】:

      猜你喜欢
      • 2013-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多