DoboWiki
Top
> .NETプログラミング研究/41 をテンプレートにして作成
.NETプログラミング研究/41 をテンプレートにして作成
開始行:
#title(.NETプログラミング研究 第41号)
#navi(.NETプログラミング研究)
#contents
*.NETプログラミング研究 第41号 [#zaaeee85]
**.NET Tips [#q861c369]
***OS起動時にプログラムを自動的に実行する / OS起動時に一...
#column(注意){{
この記事の最新版は「[[OS起動時にプログラムを自動的に実行...
}}
これは、.NETの知識というより、Windowsに関する知識というこ...
OS起動時に指定したプログラムを自動的に実行されるようにす...
OS起動時に起動させるプログラムが登録されているキーには、...
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVers...
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersi...
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVers...
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersi...
これらのキーの内、HKEY_LOCAL_MACHINEとHKEY_CURRENT_USERの...
よって通常はRunキーを使用し、RunOnceキーは現在使用中で削...
なお、Runキーについて詳しくは、以下のマイクロソフトサポー...
-[[マイクロソフト サポート技術情報 - 314866 | Windows XP ...
-[[マイクロソフト サポート技術情報 - 137367 | レジストリ...
-[[マイクロソフト サポート技術情報 - 179365 | [INFO] Run...
-[[マイクロソフト サポート技術情報 - 232487 | RunOnceEx ...
以下に、HKEY_CURRENT_USERのRunキーにアプリケーションの実...
#code(vbnet){{
''' <summary>
''' CurrentUserのRunにアプリケーションの実行ファイルパス...
''' </summary>
Public Shared Sub SetCurrentVersionRun()
'Runキーを開く
Dim regkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.CurrentUser.OpenSubKey( _
"Software\Microsoft\Windows\CurrentVersion\Run", ...
'値の名前に製品名、値のデータに実行ファイルのパスを指...
regkey.SetValue( _
Application.ProductName, Application.ExecutablePa...
'閉じる
regkey.Close()
End Sub
}}
#code(csharp){{
/// <summary>
/// CurrentUserのRunにアプリケーションの実行ファイルパス...
/// </summary>
public static void SetCurrentVersionRun()
{
//Runキーを開く
Microsoft.Win32.RegistryKey regkey =
Microsoft.Win32.Registry.CurrentUser.OpenSubKey(
@"Software\Microsoft\Windows\CurrentVersion\Run",...
//値の名前に製品名、値のデータに実行ファイルのパスを...
regkey.SetValue(Application.ProductName, Application....
//閉じる
regkey.Close();
}
}}
***プログラムをファイルの拡張子に関連付ける [#n02666fa]
#column(注意){{
この記事の最新版は「[[プログラムをファイルの拡張子に関連...
}}
これもWindowsのレジストリの知識です。
拡張子に関する情報は、レジストリのHKEY_CLASSES_ROOTキー以...
HKEY_CLASSES_ROOT\.000\shell\open\command
というキーに、名前がなく、データが"myapp.exe %1"の値を作...
これが最も簡単な方法ですが、実際にこのように関連付けを行...
HKEY_CLASSES_ROOT\.000
というキーを作成し、ここに名前がなく、データに適当な文字...
HKEY_CLASSES_ROOT\MyApplication\shell\open\command
というキーに、名前がなく、データがコマンドラインとなる値...
以上は最低限の設定で、さらにアイコンの設定等も必要により...
-[[Jet Page - Windows レジストリ 解剖記>http://homepage2....
なお関連付けによりプログラムが実行された時、プログラムで...
-[[DOBON.NET .NET Tips - 起動時のコマンドライン引数を取得...
以下に拡張子への関連付けを行うサンプルを示します。ここで...
#code(vbnet){{
'関連付ける拡張子
Dim extension As String = ".000"
'実行するコマンドライン
Dim commandline As String = """" + Application.Executable...
+ """ %1"
'ファイルタイプ名
Dim fileType As String = Application.ProductName
'説明(必要なし)
Dim description As String = "MyApplication File"
'動詞
Dim verb As String = "open"
'動詞の説明(エクスプローラのコンテキストメニューに表示さ...
'(必要なし)
Dim verb_description As String = "MyApplicationで開く(&O)"
'アイコンのパスとインデックス
Dim iconPath As String = Application.ExecutablePath
Dim iconIndex As Integer = 0
'ファイルタイプを登録
Dim regkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(ext...
regkey.SetValue("", fileType)
regkey.Close()
'ファイルタイプとその説明を登録
Dim shellkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(fil...
shellkey.SetValue("", description)
'動詞とその説明を登録
shellkey = shellkey.CreateSubKey("shell\" + verb)
shellkey.SetValue("", verb_description)
'コマンドラインを登録
shellkey = shellkey.CreateSubKey("command")
shellkey.SetValue("", commandline)
shellkey.Close()
'アイコンの登録
Dim iconkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey( _
fileType + "\DefaultIcon")
iconkey.SetValue("", iconPath + "," + iconIndex.ToString())
iconkey.Close()
}}
#code(csharp){{
//関連付ける拡張子
string extension = ".000";
//実行するコマンドライン
string commandline = "\"" + Application.ExecutablePath + ...
//ファイルタイプ名
string fileType = Application.ProductName;
//説明(必要なし)
string description = "MyApplication File";
//動詞
string verb = "open";
//動詞の説明(エクスプローラのコンテキストメニューに表示...
//(必要なし)
string verb_description = "MyApplicationで開く(&O)";
//アイコンのパスとインデックス
string iconPath =Application.ExecutablePath;
int iconIndex = 0;
//ファイルタイプを登録
Microsoft.Win32.RegistryKey regkey =
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
extension);
regkey.SetValue("", fileType);
regkey.Close();
//ファイルタイプとその説明を登録
Microsoft.Win32.RegistryKey shellkey =
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
fileType);
shellkey.SetValue("", description);
//動詞とその説明を登録
shellkey = shellkey.CreateSubKey("shell\\" + verb);
shellkey.SetValue("", verb_description);
//コマンドラインを登録
shellkey = shellkey.CreateSubKey("command");
shellkey.SetValue("", commandline);
shellkey.Close();
//アイコンの登録
Microsoft.Win32.RegistryKey iconkey =
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
fileType + "\\DefaultIcon");
iconkey.SetValue("", iconPath + "," + iconIndex.ToString(...
iconkey.Close();
}}
また、関連付けを削除するには、次のように対象となるすべて...
#code(vbnet){{
'拡張子
Dim extension As String = ".000"
'ファイルタイプ名
Dim fileType As String = Application.ProductName
'レジストリキーを削除
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(ext...
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(fil...
}}
#code(csharp){{
//拡張子
string extension = ".000";
//ファイルタイプ名
string fileType = Application.ProductName;
//レジストリキーを削除
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(ext...
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(fil...
}}
***エクスプローラでフォルダやドライブを右クリックしたとき...
#column(注意){{
この記事の最新版は「[[エクスプローラでフォルダやドライブ...
}}
エクスプローラでフォルダやドライブを右クリックしたときに...
実はこれを行うには、フォルダやドライブに関連付けを行えば...
「プログラムをファイルの拡張子に関連付ける」では、拡張子...
この3つ以外にも特別な意味を持つキーがいくつかあります。例...
-[[MSDN - Creating Shell Extension Handlers>http://msdn.m...
フォルダへの関連付けにより、エクスプローラでフォルダを右...
#code(vbnet){{
'実行するコマンドライン
Dim commandline As String = _
"""" + Application.ExecutablePath + """ %1"
'説明(エクスプローラのコンテキストメニューに表示される)
Dim description As String = "MyApplicationで開く"
'フォルダへの関連付けを行う
Dim regkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey( _
"Folder\shell\" + description + "\command")
regkey.SetValue("", commandline)
regkey.Close()
}}
#code(csharp){{
//実行するコマンドライン
string commandline = "\"" + Application.ExecutablePath + ...
//説明(エクスプローラのコンテキストメニューに表示される)
string description = "MyApplicationで開く";
//フォルダへの関連付けを行う
Microsoft.Win32.RegistryKey regkey =
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
"Folder\\shell\\" + description + "\\command");
regkey.SetValue("", commandline);
regkey.Close();
}}
***エクスプローラの新規作成メニューに項目を追加する [#p33...
#column(注意){{
この記事の最新版は「[[エクスプローラの新規作成メニューに...
}}
エクスプローラでフォルダを選び、メニューの「ファイル - 新...
しつこいようですが、これまた、Windowsとレジストリの知識で...
-[[@IT:Windows TIPS -- Tips:エクスプローラの[新規作成...
まずは拡張子への関連付けが必要ですので、「プログラムをフ...
「新規作成」メニューにより作成されるファイルには2種類(注...
サイズ0のファイルを作成する場合は簡単で、レジストリの
HKEY_CLASSES_ROOT\(拡張子)\ShellNew
というキーに名前が"NullFile"でデータが""の値を作成するだ...
テンプレートファイルを使用する場合は、新規作成により作成...
"NullFile"と"FileName"の両方を指定することはできませんが...
以下にサンプルを示します。まずは、「新規作成」メニューに...
#code(vbnet){{
'拡張子
Dim extension As String = ".000"
'「新規作成」により、空のファイルを作成
Dim regkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey( _
extension + "\ShellNew")
regkey.SetValue("NullFile", "")
regkey.Close()
}}
#code(csharp){{
//拡張子
string extension = ".000";
//「新規作成」により、空のファイルを作成
Microsoft.Win32.RegistryKey regkey =
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
extension + "\\ShellNew");
regkey.SetValue("NullFile", "");
regkey.Close();
}}
次にテンプレートファイルを使用した例を示します。
#code(vbnet){{
'拡張子
Dim extension As String = ".000"
'テンプレートファイル名
Dim templateName As String = "myapp.000"
'テンプレートファイルのパス
Dim templatePath As String = _
System.Environment.GetFolderPath( _
Environment.SpecialFolder.Templates) + "\" + template...
'テンプレートの中身
Dim templateText As String = "DOBON.NET"
'テンプレートファイルを作成する
Dim sw = New StreamWriter(templatePath)
sw.Write(templateText)
sw.Close()
'「新規作成」により、テンプレートファイルを作成
Dim regkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey( _
extension + "\ShellNew")
regkey.SetValue("FileName", templateName)
regkey.Close()
}}
#code(csharp){{
//拡張子
string extension = ".000";
//テンプレートファイル名
string templateName = "myapp.000";
//テンプレートファイルのパス
string templatePath =
System.Environment.GetFolderPath(
Environment.SpecialFolder.Templates) +
"\\" + templateName;
//テンプレートの中身
string templateText = "DOBON.NET";
//テンプレートファイルを作成する
System.IO.StreamWriter sw = new StreamWriter(templatePath);
sw.Write(templateText);
sw.Close();
//「新規作成」により、テンプレートファイルを作成
Microsoft.Win32.RegistryKey regkey =
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
extension + "\\ShellNew");
regkey.SetValue("FileName", templateName);
regkey.Close();
}}
(注1)@IT:Windows TIPSでは2種類しか紹介されていません...
名前が"Command"でデータがコマンドラインの値を作成すると、...
また、"Data"を名前とする値の場合、データにバイナリ値を指...
**コメント [#w8c7eb37]
#comment
//これより下は編集しないでください
#pageinfo([[:Category/.NET]],2004-09-14 (火) 06:00:00,DOB...
終了行:
#title(.NETプログラミング研究 第41号)
#navi(.NETプログラミング研究)
#contents
*.NETプログラミング研究 第41号 [#zaaeee85]
**.NET Tips [#q861c369]
***OS起動時にプログラムを自動的に実行する / OS起動時に一...
#column(注意){{
この記事の最新版は「[[OS起動時にプログラムを自動的に実行...
}}
これは、.NETの知識というより、Windowsに関する知識というこ...
OS起動時に指定したプログラムを自動的に実行されるようにす...
OS起動時に起動させるプログラムが登録されているキーには、...
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVers...
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersi...
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVers...
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersi...
これらのキーの内、HKEY_LOCAL_MACHINEとHKEY_CURRENT_USERの...
よって通常はRunキーを使用し、RunOnceキーは現在使用中で削...
なお、Runキーについて詳しくは、以下のマイクロソフトサポー...
-[[マイクロソフト サポート技術情報 - 314866 | Windows XP ...
-[[マイクロソフト サポート技術情報 - 137367 | レジストリ...
-[[マイクロソフト サポート技術情報 - 179365 | [INFO] Run...
-[[マイクロソフト サポート技術情報 - 232487 | RunOnceEx ...
以下に、HKEY_CURRENT_USERのRunキーにアプリケーションの実...
#code(vbnet){{
''' <summary>
''' CurrentUserのRunにアプリケーションの実行ファイルパス...
''' </summary>
Public Shared Sub SetCurrentVersionRun()
'Runキーを開く
Dim regkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.CurrentUser.OpenSubKey( _
"Software\Microsoft\Windows\CurrentVersion\Run", ...
'値の名前に製品名、値のデータに実行ファイルのパスを指...
regkey.SetValue( _
Application.ProductName, Application.ExecutablePa...
'閉じる
regkey.Close()
End Sub
}}
#code(csharp){{
/// <summary>
/// CurrentUserのRunにアプリケーションの実行ファイルパス...
/// </summary>
public static void SetCurrentVersionRun()
{
//Runキーを開く
Microsoft.Win32.RegistryKey regkey =
Microsoft.Win32.Registry.CurrentUser.OpenSubKey(
@"Software\Microsoft\Windows\CurrentVersion\Run",...
//値の名前に製品名、値のデータに実行ファイルのパスを...
regkey.SetValue(Application.ProductName, Application....
//閉じる
regkey.Close();
}
}}
***プログラムをファイルの拡張子に関連付ける [#n02666fa]
#column(注意){{
この記事の最新版は「[[プログラムをファイルの拡張子に関連...
}}
これもWindowsのレジストリの知識です。
拡張子に関する情報は、レジストリのHKEY_CLASSES_ROOTキー以...
HKEY_CLASSES_ROOT\.000\shell\open\command
というキーに、名前がなく、データが"myapp.exe %1"の値を作...
これが最も簡単な方法ですが、実際にこのように関連付けを行...
HKEY_CLASSES_ROOT\.000
というキーを作成し、ここに名前がなく、データに適当な文字...
HKEY_CLASSES_ROOT\MyApplication\shell\open\command
というキーに、名前がなく、データがコマンドラインとなる値...
以上は最低限の設定で、さらにアイコンの設定等も必要により...
-[[Jet Page - Windows レジストリ 解剖記>http://homepage2....
なお関連付けによりプログラムが実行された時、プログラムで...
-[[DOBON.NET .NET Tips - 起動時のコマンドライン引数を取得...
以下に拡張子への関連付けを行うサンプルを示します。ここで...
#code(vbnet){{
'関連付ける拡張子
Dim extension As String = ".000"
'実行するコマンドライン
Dim commandline As String = """" + Application.Executable...
+ """ %1"
'ファイルタイプ名
Dim fileType As String = Application.ProductName
'説明(必要なし)
Dim description As String = "MyApplication File"
'動詞
Dim verb As String = "open"
'動詞の説明(エクスプローラのコンテキストメニューに表示さ...
'(必要なし)
Dim verb_description As String = "MyApplicationで開く(&O)"
'アイコンのパスとインデックス
Dim iconPath As String = Application.ExecutablePath
Dim iconIndex As Integer = 0
'ファイルタイプを登録
Dim regkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(ext...
regkey.SetValue("", fileType)
regkey.Close()
'ファイルタイプとその説明を登録
Dim shellkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(fil...
shellkey.SetValue("", description)
'動詞とその説明を登録
shellkey = shellkey.CreateSubKey("shell\" + verb)
shellkey.SetValue("", verb_description)
'コマンドラインを登録
shellkey = shellkey.CreateSubKey("command")
shellkey.SetValue("", commandline)
shellkey.Close()
'アイコンの登録
Dim iconkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey( _
fileType + "\DefaultIcon")
iconkey.SetValue("", iconPath + "," + iconIndex.ToString())
iconkey.Close()
}}
#code(csharp){{
//関連付ける拡張子
string extension = ".000";
//実行するコマンドライン
string commandline = "\"" + Application.ExecutablePath + ...
//ファイルタイプ名
string fileType = Application.ProductName;
//説明(必要なし)
string description = "MyApplication File";
//動詞
string verb = "open";
//動詞の説明(エクスプローラのコンテキストメニューに表示...
//(必要なし)
string verb_description = "MyApplicationで開く(&O)";
//アイコンのパスとインデックス
string iconPath =Application.ExecutablePath;
int iconIndex = 0;
//ファイルタイプを登録
Microsoft.Win32.RegistryKey regkey =
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
extension);
regkey.SetValue("", fileType);
regkey.Close();
//ファイルタイプとその説明を登録
Microsoft.Win32.RegistryKey shellkey =
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
fileType);
shellkey.SetValue("", description);
//動詞とその説明を登録
shellkey = shellkey.CreateSubKey("shell\\" + verb);
shellkey.SetValue("", verb_description);
//コマンドラインを登録
shellkey = shellkey.CreateSubKey("command");
shellkey.SetValue("", commandline);
shellkey.Close();
//アイコンの登録
Microsoft.Win32.RegistryKey iconkey =
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
fileType + "\\DefaultIcon");
iconkey.SetValue("", iconPath + "," + iconIndex.ToString(...
iconkey.Close();
}}
また、関連付けを削除するには、次のように対象となるすべて...
#code(vbnet){{
'拡張子
Dim extension As String = ".000"
'ファイルタイプ名
Dim fileType As String = Application.ProductName
'レジストリキーを削除
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(ext...
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(fil...
}}
#code(csharp){{
//拡張子
string extension = ".000";
//ファイルタイプ名
string fileType = Application.ProductName;
//レジストリキーを削除
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(ext...
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(fil...
}}
***エクスプローラでフォルダやドライブを右クリックしたとき...
#column(注意){{
この記事の最新版は「[[エクスプローラでフォルダやドライブ...
}}
エクスプローラでフォルダやドライブを右クリックしたときに...
実はこれを行うには、フォルダやドライブに関連付けを行えば...
「プログラムをファイルの拡張子に関連付ける」では、拡張子...
この3つ以外にも特別な意味を持つキーがいくつかあります。例...
-[[MSDN - Creating Shell Extension Handlers>http://msdn.m...
フォルダへの関連付けにより、エクスプローラでフォルダを右...
#code(vbnet){{
'実行するコマンドライン
Dim commandline As String = _
"""" + Application.ExecutablePath + """ %1"
'説明(エクスプローラのコンテキストメニューに表示される)
Dim description As String = "MyApplicationで開く"
'フォルダへの関連付けを行う
Dim regkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey( _
"Folder\shell\" + description + "\command")
regkey.SetValue("", commandline)
regkey.Close()
}}
#code(csharp){{
//実行するコマンドライン
string commandline = "\"" + Application.ExecutablePath + ...
//説明(エクスプローラのコンテキストメニューに表示される)
string description = "MyApplicationで開く";
//フォルダへの関連付けを行う
Microsoft.Win32.RegistryKey regkey =
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
"Folder\\shell\\" + description + "\\command");
regkey.SetValue("", commandline);
regkey.Close();
}}
***エクスプローラの新規作成メニューに項目を追加する [#p33...
#column(注意){{
この記事の最新版は「[[エクスプローラの新規作成メニューに...
}}
エクスプローラでフォルダを選び、メニューの「ファイル - 新...
しつこいようですが、これまた、Windowsとレジストリの知識で...
-[[@IT:Windows TIPS -- Tips:エクスプローラの[新規作成...
まずは拡張子への関連付けが必要ですので、「プログラムをフ...
「新規作成」メニューにより作成されるファイルには2種類(注...
サイズ0のファイルを作成する場合は簡単で、レジストリの
HKEY_CLASSES_ROOT\(拡張子)\ShellNew
というキーに名前が"NullFile"でデータが""の値を作成するだ...
テンプレートファイルを使用する場合は、新規作成により作成...
"NullFile"と"FileName"の両方を指定することはできませんが...
以下にサンプルを示します。まずは、「新規作成」メニューに...
#code(vbnet){{
'拡張子
Dim extension As String = ".000"
'「新規作成」により、空のファイルを作成
Dim regkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey( _
extension + "\ShellNew")
regkey.SetValue("NullFile", "")
regkey.Close()
}}
#code(csharp){{
//拡張子
string extension = ".000";
//「新規作成」により、空のファイルを作成
Microsoft.Win32.RegistryKey regkey =
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
extension + "\\ShellNew");
regkey.SetValue("NullFile", "");
regkey.Close();
}}
次にテンプレートファイルを使用した例を示します。
#code(vbnet){{
'拡張子
Dim extension As String = ".000"
'テンプレートファイル名
Dim templateName As String = "myapp.000"
'テンプレートファイルのパス
Dim templatePath As String = _
System.Environment.GetFolderPath( _
Environment.SpecialFolder.Templates) + "\" + template...
'テンプレートの中身
Dim templateText As String = "DOBON.NET"
'テンプレートファイルを作成する
Dim sw = New StreamWriter(templatePath)
sw.Write(templateText)
sw.Close()
'「新規作成」により、テンプレートファイルを作成
Dim regkey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey( _
extension + "\ShellNew")
regkey.SetValue("FileName", templateName)
regkey.Close()
}}
#code(csharp){{
//拡張子
string extension = ".000";
//テンプレートファイル名
string templateName = "myapp.000";
//テンプレートファイルのパス
string templatePath =
System.Environment.GetFolderPath(
Environment.SpecialFolder.Templates) +
"\\" + templateName;
//テンプレートの中身
string templateText = "DOBON.NET";
//テンプレートファイルを作成する
System.IO.StreamWriter sw = new StreamWriter(templatePath);
sw.Write(templateText);
sw.Close();
//「新規作成」により、テンプレートファイルを作成
Microsoft.Win32.RegistryKey regkey =
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
extension + "\\ShellNew");
regkey.SetValue("FileName", templateName);
regkey.Close();
}}
(注1)@IT:Windows TIPSでは2種類しか紹介されていません...
名前が"Command"でデータがコマンドラインの値を作成すると、...
また、"Data"を名前とする値の場合、データにバイナリ値を指...
**コメント [#w8c7eb37]
#comment
//これより下は編集しないでください
#pageinfo([[:Category/.NET]],2004-09-14 (火) 06:00:00,DOB...
ページ名:
▲
▼
[
トップ
] [
新規
|
子ページ作成
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]