• R/O
  • SSH
  • HTTPS

sendtocmd: 提交


Commit MetaInfo

修訂47 (tree)
時間2007-08-16 11:20:50
作者bearmini

Log Message

インストール時に「管理者として実行」のショートカットも作成するようにした。(SendToCMD および SendToCygwin)

Change Summary

差異

--- doc/Todo.txt (revision 46)
+++ doc/Todo.txt (revision 47)
@@ -15,6 +15,8 @@
1515
1616 ・MessageBox というクラス名が Windows の define してる名前とかぶってるので回避する
1717
18+・文字列リテラルのところをリソースなどから読み込むようにする
19+
1820 ・Doxygen 対応
1921
2022 ・自動ビルド
--- doc/ReadMe.txt (revision 46)
+++ doc/ReadMe.txt (revision 47)
@@ -3,8 +3,8 @@
33 「コマンドプロンプトに送る」
44 「Cygwin に送る」
55 「PowerShell に送る」
6- ver.<%version string placeholder%>
7-
6+ ver.<%version string placeholder%>
7+
88 ご使用になる前に、必ずお読みください
99
1010
@@ -494,18 +494,29 @@
494494 ご感想などは、以下のメールアドレスまたは Web ページまでお気軽に
495495 お寄せください。
496496
497- bear.mini@gmail.com
498- http://bearmini.net/software/SendToCMD/
499- https://sourceforge.jp/projects/sendtocmd/
497+ Google groups(一般の方向けのサイト)
498+ http://groups.google.co.jp/group/sendtocmd
500499
501-
500+ SourceForge.jp(開発者向けのサイト)
501+ https://sourceforge.jp/projects/sendtocmd/
502+
503+ bearmini.net(私の個人サイトのソフト紹介ページ)
504+ http://bearmini.net/software/SendToCMD/
505+
506+ 電子メール
507+ bear.mini@gmail.com
508+
509+
502510 ■■■■■ 8. ライセンス ■■■■■
503511
504- ・本ソフトウェアは GPL v2 に基づいて配布されています。
512+ ・本ソフトウェアは GPL v3 に基づいて配布されています。
505513
506514
507515 ■■■■■ 9. 変更履歴 ■■■■■
508-
516+ 2007/08/16 ver 2.00 beta 2
517+ ・Vista でインストールするときは「管理者として実行」するための
518+ ショートカットも作るようにしました。
519+
509520 2007/05/11 ver 2.00 beta 1
510521 ・x64 でもビルドするようにしました。
511522 ただし動作確認はしていません。
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
--- src/Core/SendToCygwin.h (revision 46)
+++ src/Core/SendToCygwin.h (revision 47)
@@ -78,7 +78,6 @@
7878
7979 std::wstring getSendToCygwinExeFullPath();
8080 std::wstring getSendToCygwinExeDirectory();
81- std::wstring getLinkFileFullPath();
8281
8382 std::wstring convertDirectoryNameForCygwin(const std::wstring& folderName);
8483 void changeDirectoryInCygwin(const std::wstring& FolderName);
--- src/Core/SendToCMD.h (revision 46)
+++ src/Core/SendToCMD.h (revision 47)
@@ -78,7 +78,6 @@
7878
7979 std::wstring getSendToCmdExeFullPath();
8080 std::wstring getSendToCmdExeDirectory();
81- std::wstring getLinkFileFullPath();
8281
8382 void install();
8483 void uninstall();
--- src/Core/Path.h (revision 46)
+++ src/Core/Path.h (revision 47)
@@ -44,6 +44,7 @@
4444 static std::wstring AddBackslash(const std::wstring& path);
4545 static std::wstring RemoveTrailingBackslash(const std::wstring& path);
4646 static std::wstring Unquote(const std::wstring& path);
47+ static std::wstring Combine(const std::wstring& dir, const std::wstring& file);
4748
4849 static bool IsDirectory(const std::wstring& path);
4950 static bool IsUNC(const std::wstring& path);
--- src/Core/SendToCygwin.cpp (revision 46)
+++ src/Core/SendToCygwin.cpp (revision 47)
@@ -31,6 +31,7 @@
3131 #include "SettingRepository.h"
3232 #include "ShellApi.h"
3333 #include "Shortcut.h"
34+#include "SystemInfo.h"
3435
3536
3637 namespace bearmini
@@ -160,6 +161,8 @@
160161 ///
161162 /// レジストリから Cygwin のルートディレクトリを取得します。
162163 ///
164+ /// FIXME: HKEY をラップするクラスを作って、例外発生時のリソースリークを防ぐ
165+ ///
163166 std::wstring SendToCygwin::getCygwinRootDirectoryFromRegistry()
164167 {
165168 const std::wstring regkeyCygwinRoot = L"SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\/";
@@ -299,23 +302,6 @@
299302
300303
301304 ///
302- /// SendTo フォルダに置くための SendToCygwin.exe へのショートカットファイルのフルパスを取得します。
303- ///
304- /// @return ショートカットファイルのフルパス
305- ///
306- std::wstring SendToCygwin::getLinkFileFullPath()
307- {
308- const std::wstring linkFileName = L"Cygwin に送る.lnk";
309-
310- // リンクファイルのフルパスを作成
311- std::wstringstream linkFilePath;
312- linkFilePath << ShellApi::GetSendToFolderPath() << L"\\" << linkFileName;
313-
314- return linkFilePath.str();
315- }
316-
317-
318- ///
319305 /// コンソールのタイトルとして設定する文字列を取得します。
320306 ///
321307 std::wstring SendToCygwin::getConsoleTitle()
@@ -348,38 +334,28 @@
348334
349335
350336 ///
351- /// Cygwin 内で cd コマンドを使ってディレクトリを移動します。
352- ///
353- //void SendToCygwin::changeDirectoryInCygwin(const std::wstring& folderName)
354- //{
355- // // Cygwin 用にディレクトリ名を変換
356- // std::wstring folderNameForCygwin = convertDirectoryNameForCygwin(folderName);
357-
358- // // change directory コマンドを得る
359- // // ふつうは cd だが、alias したりほかのコマンドを使っていたり変なシェルを使っている人もいるかもしれないので
360- // std::wstring change_dir_command = SettingRepository::GetCygwinChangeDirCommand();
361-
362- // // cd コマンドで移動
363- // Console::Input(change_dir_command);
364- // Console::Input(L" \"");
365- // Console::Input(folderNameForCygwin);
366- // Console::Input(L"\"");
367- // //Console::InputVirtualKeyCode(VK_RETURN); // VK_RETURN じゃ ENTER は押されないみたいだ
368- // Console::Input(L"\n");
369- //}
370-
371-
372- ///
373337 /// インストールを行います。
374338 ///
375339 void SendToCygwin::install()
376340 {
377- // ショートカットを作成
378- const std::wstring linkFilePath = getLinkFileFullPath();
379- const std::wstring sendToCygwinExePath = getSendToCygwinExeFullPath();
380- const std::wstring sendToCygwinExeDir = getSendToCygwinExeDirectory();
381- const std::wstring description = L"ファイルやディレクトリを指定して Cygwin を起動します.";
382- Shortcut::Create(linkFilePath, sendToCygwinExePath, description, L"", sendToCygwinExeDir, L"");
341+ // ショートカットを作成(通常実行)
342+ {
343+ const std::wstring linkFilePath = Path::Combine(ShellApi::GetSendToFolderPath(), L"Cygwin に送る.lnk");
344+ const std::wstring sendToCygwinExePath = getSendToCygwinExeFullPath();
345+ const std::wstring sendToCygwinExeDir = getSendToCygwinExeDirectory();
346+ const std::wstring description = L"ファイルやディレクトリを指定して Cygwin を起動します.";
347+ Shortcut::Create(linkFilePath, sendToCygwinExePath, description, L"", sendToCygwinExeDir, L"");
348+ }
349+
350+ // ショートカットを作成(管理者として実行)
351+ if (SystemInfo::GetOsMajorVersion() >= SystemInfo::OsMajorVersion_Vista)
352+ {
353+ const std::wstring linkFilePath = Path::Combine(ShellApi::GetSendToFolderPath(), L"Cygwin に送る(管理者として実行...).lnk");
354+ const std::wstring sendToCygwinExePath = getSendToCygwinExeFullPath();
355+ const std::wstring sendToCygwinExeDir = getSendToCygwinExeDirectory();
356+ const std::wstring description = L"ファイルやディレクトリを指定して Cygwin を起動します.";
357+ Shortcut::Create(linkFilePath, sendToCygwinExePath, description, L"", sendToCygwinExeDir, L"", 0, 1, true);
358+ }
383359
384360 MessageBox::Show(this, L"インストールが完了しました.");
385361 }
@@ -391,9 +367,16 @@
391367 void SendToCygwin::uninstall()
392368 {
393369 // ショートカットファイルを削除
394- std::wstring linkFilePath = getLinkFileFullPath();
395- ::DeleteFileW(linkFilePath.c_str());
370+ {
371+ const std::wstring linkFilePath = Path::Combine(ShellApi::GetSendToFolderPath(), L"Cygwin に送る.lnk");
372+ ::DeleteFileW(linkFilePath.c_str());
373+ }
396374
375+ {
376+ const std::wstring linkFilePath = Path::Combine(ShellApi::GetSendToFolderPath(), L"Cygwin に送る(管理者として実行...).lnk");
377+ ::DeleteFileW(linkFilePath.c_str());
378+ }
379+
397380 MessageBox::Show(this, L"アンインストールが完了しました.\r\nご利用ありがとうございました.");
398381 }
399382
--- src/Core/SendToCMD.cpp (revision 46)
+++ src/Core/SendToCMD.cpp (revision 47)
@@ -21,9 +21,6 @@
2121
2222 #include "SendToCMD.h"
2323
24-// Windows headers
25-#include <shlwapi.h> // for PathXxxx()
26-#pragma comment(lib,"shlwapi.lib")
2724
2825 // private headers
2926 #include "Console.h"
@@ -114,7 +111,7 @@
114111 }
115112
116113 // UNC ディレクトリには移動できないのでチェック(args の先頭だけチェックすればユースケース上十分だろうと思われる)
117- if (::PathIsUNCW(args.front().c_str()))
114+ if (Path::IsUNC(args.front()))
118115 {
119116 throw std::exception("A UNC (path starts with '\\\\') is not supported. \r\n\r\nFiles or directories on a network cannot be sent to CMD.EXE.");
120117 }
@@ -237,23 +234,6 @@
237234
238235
239236 ///
240- /// SendTo フォルダに置くための SendToCMD.exe へのショートカットファイルのフルパスを取得します。
241- ///
242- /// @return ショートカットファイルのフルパス
243- ///
244- std::wstring SendToCMD::getLinkFileFullPath()
245- {
246- const std::wstring linkFileName = L"コマンドプロンプトに送る.lnk";
247-
248- // リンクファイルのフルパスを作成
249- std::wstringstream linkFilePath;
250- linkFilePath << ShellApi::GetSendToFolderPath() << L"\\" << linkFileName;
251-
252- return linkFilePath.str();
253- }
254-
255-
256- ///
257237 /// コンソールのタイトルとして設定する文字列を取得します。
258238 ///
259239 std::wstring SendToCMD::getConsoleTitle()
@@ -267,13 +247,24 @@
267247 ///
268248 void SendToCMD::install()
269249 {
270- // ショートカットを作成
271- const std::wstring linkFilePath = getLinkFileFullPath();
272- const std::wstring sendToCmdExePath = getSendToCmdExeFullPath();
273- const std::wstring sendToCmdExeDir = getSendToCmdExeDirectory();
274- const std::wstring description = L"ファイルやディレクトリを指定してコマンドプロンプトを起動します.";
275- Shortcut::Create(linkFilePath, sendToCmdExePath, description, L"", sendToCmdExeDir, L"");
250+ // ショートカットを作成(通常実行)
251+ {
252+ const std::wstring linkFilePath = Path::Combine(ShellApi::GetSendToFolderPath(), L"コマンドプロンプトに送る.lnk");
253+ const std::wstring sendToCmdExePath = getSendToCmdExeFullPath();
254+ const std::wstring sendToCmdExeDir = getSendToCmdExeDirectory();
255+ const std::wstring description = L"ファイルやディレクトリを指定してコマンドプロンプトを起動します.";
256+ Shortcut::Create(linkFilePath, sendToCmdExePath, description, L"", sendToCmdExeDir, L"");
257+ }
276258
259+ // ショートカットを作成(管理者として実行)
260+ {
261+ const std::wstring linkFilePath = Path::Combine(ShellApi::GetSendToFolderPath(), L"コマンドプロンプトに送る(管理者として実行...).lnk");
262+ const std::wstring sendToCmdExePath = getSendToCmdExeFullPath();
263+ const std::wstring sendToCmdExeDir = getSendToCmdExeDirectory();
264+ const std::wstring description = L"ファイルやディレクトリを指定してコマンドプロンプトを起動します.";
265+ Shortcut::Create(linkFilePath, sendToCmdExePath, description, L"", sendToCmdExeDir, L"", 0, 1, true);
266+ }
267+
277268 MessageBox::Show(this, L"インストールが完了しました.");
278269 }
279270
@@ -284,8 +275,14 @@
284275 void SendToCMD::uninstall()
285276 {
286277 // ショートカットファイルを削除
287- std::wstring linkFilePath = getLinkFileFullPath();
288- ::DeleteFileW(linkFilePath.c_str());
278+ {
279+ const std::wstring linkFilePath = Path::Combine(ShellApi::GetSendToFolderPath(), L"コマンドプロンプトに送る.lnk");
280+ ::DeleteFileW(linkFilePath.c_str());
281+ }
282+ {
283+ const std::wstring linkFilePath = Path::Combine(ShellApi::GetSendToFolderPath(), L"コマンドプロンプトに送る(管理者として実行...).lnk");
284+ ::DeleteFileW(linkFilePath.c_str());
285+ }
289286
290287 MessageBox::Show(this, L"アンインストールが完了しました.\r\nご利用ありがとうございました.");
291288 }
--- src/Core/Path.cpp (revision 46)
+++ src/Core/Path.cpp (revision 47)
@@ -254,6 +254,22 @@
254254
255255
256256 ///
257+ /// dir で指定されたディレクトリ名と file で指定されたファイル名を結合して、1つのパス文字列を作ります。
258+ ///
259+ /// @param[in] dir ディレクトリ名
260+ /// @param[in] file ファイル名
261+ ///
262+ /// @return 結合されたパス名
263+ ///
264+ std::wstring Path::Combine(const std::wstring& dir, const std::wstring& file)
265+ {
266+ wchar_t buf[_MAX_PATH + 1] = { 0 };
267+ ::PathCombineW(buf, dir.c_str(), file.c_str());
268+ return buf;
269+ }
270+
271+
272+ ///
257273 /// path で指定されたパス文字列がさしているものがディレクトリかファイルかを調べます。
258274 /// path で指定されたパスが、ファイルシステム上に実在するものでなければこの関数は例外を送出します。
259275 ///
Show on old repository browser