ネタ元
x86でexe作れば32bit版の、
x64でexe作れば64bit版の、regasm呼び出せる
C#
using System.Runtime.InteropServices;
using System.Text;
class Program
{
static void Main(string[] args)
{
// RegAsm のパスを取得
string path = System.IO.Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "RegAsm.exe");
// パスをコンソールに出力
Console.WriteLine("[" + path + "]");
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = path;
// 渡されたコマンドライン引数をそのまま渡す
StringBuilder buff = new StringBuilder(128);
foreach(string arg in args)
{
buff.Append(arg + " ");
}
p.StartInfo.Arguments = buff.ToString();
// 出力を取得できるようにする
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = false;
// ウィンドウを表示しない
p.StartInfo.CreateNoWindow = true;
// 起動
p.Start();
// 出力を取得
string results = p.StandardOutput.ReadToEnd();
// プロセス終了まで待機する
p.WaitForExit();
p.Close();
// 出力された結果を表示
Console.WriteLine(results);
}
}vb.net
Imports System.Runtime.InteropServices
Imports System.Text
Module Program
Sub Main()
'RegAsm のパスを取得
Dim path As String = IO.Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "RegAsm.exe")
'パスをコンソールに出力
Console.WriteLine("[" & path & "]")
Dim p As New System.Diagnostics.Process()
p.StartInfo.FileName = path
'渡されたコマンドライン引数をそのまま渡す
Dim args As New StringBuilder(128)
For Each arg As String In My.Application.CommandLineArgs
args.Append(arg & Space(1))
Next
p.StartInfo.Arguments = args.ToString
'出力を取得できるようにする
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.RedirectStandardInput = False
'ウィンドウを表示しない
p.StartInfo.CreateNoWindow = True
'起動
p.Start()
'出力を取得
Dim results As String = p.StandardOutput.ReadToEnd()
'プロセス終了まで待機する
p.WaitForExit()
p.Close()
'出力された結果を表示
Console.WriteLine(results)
End Sub
End Module