6

ボタンの仕組みが気になります。「Clone in Windows」ボタンをクリックすると、自分のマシンでローカル アプリケーション (GitHub) を開くことを認識する方法を説明できますか。

4

2 に答える 2

4

GitExtensionのこのパッチを見てください:それはHKCRにそのアクションを登録します

  <Component Id="Protocol.github_windows" Guid="*">
    <RegistryKey Key="github-windows" Root="HKCR">
      <RegistryValue Value="URL: Github for Windows Protocol" Type="string" />
      <RegistryValue Name="URL Protocol" Value="" Type="string" />
    </RegistryKey>
    <RegistryKey Key="github-windows\DefaultIcon" Root="HKCR">
      <RegistryValue Value="[INSTALLDIR]GitExtensions.exe" Type="string" />
    </RegistryKey>
    <RegistryKey Root="HKCR" Key="github-windows\shell"/>
    <RegistryKey Root="HKCR" Key="github-windows\shell\open"/>
    <RegistryKey Root="HKCR" Key="github-windows\shell\open\command">
      <RegistryValue Value="&quot;[INSTALLDIR]GitExtensions.exe&quot; %1" Type="string" />
    </RegistryKey>
  </Component>

そしてそれは追加します:

if (args[1].StartsWith("git://"))
{
    args = new string[]{args[0], "clone", args[1]};
}
if (args[1].StartsWith("github-windows://openRepo/"))
{
     args = new string[]{args[0], "clone", args[1].Replace("github-windows://openRepo/", "")};
}

GitHub for Windowsも、同様のアプローチを採用します。

于 2012-11-20T10:37:39.663 に答える
0

TortoiseGit アプリケーションでも非常によく似ています。

これは、TortoiseGitのgithub-windows プロトコル ハンドラです。

newCmd.Format(_T("/command:clone /url:\"%s\" /hasurlhandler"), (LPCTSTR)url);

登録ハンドラにレジストリ キーを追加します。

<RegistryValue Root="HKLM" Key="Software\Classes\github-windows\shell\open\command" Value="&quot;[INSTALLDIR]bin\TortoiseGitProc.exe&quot; /urlhandler:&quot;%1&quot;" Type="string" />
于 2015-12-03T22:06:15.373 に答える