以前にこの質問をしたことがありますが、レジストリから Teamviewer ID を取得し、ボタンがクリックされたときにメッセージ ボックスに表示しようとしていますが、そのボタンをクリックすると空白のメッセージ ボックスが表示され、この問題を解決するのに役立ちます。
Teamviewer ID を取得するための私のコードは以下のとおりです。
public static string CollectTeamviewerId()
{
var versions = new[] { "4", "5", "5.1", "6", "7", "8" }.Reverse().ToList();
foreach (var path in new[] { "SOFTWARE\\TeamViewer", "SOFTWARE\\Wow6432Node\\TeamViewer" })
{
if (Registry.LocalMachine.OpenSubKey(path) != null)
{
foreach (var version in versions)
{
var subKey = string.Format("{0}\\Version{1}", path, version);
if (Registry.LocalMachine.OpenSubKey(subKey) != null)
{
var clientID = Registry.LocalMachine.OpenSubKey(subKey).GetValue("ClientID");
if (clientID != null)
{
return clientID as string;
}
}
}
}
}
そしてボタンのために;
private void button4_Click(object sender, EventArgs e)
{
MessageBox.Show(LogDataFactory.CollectTeamviewerId());
}