Hyper-vで実行されているすべてのVMのステータスを取得できるコンポーネントまたはクラスはありますか?すべてのVMとその状態(停止、実行中、一時停止など)を一覧表示できるようにしたい。
マイクロソフトにはWMIメソッドがあることは知っていますが、取得したサンプルはすべて.Net用であり、Delphi用のものはありません。これらのクラスをDelphiに変換できるはずですが、Delphi用にすでに何かを使用できればもっと簡単です。
編集
C#のサンプルがあります:
/
/ define the information we want to query - in this case, just grab all properties of the object
ObjectQuery queryObj = new ObjectQuery("SELECT * FROM Msvm_ComputerSystem");
// object for storing WMI connection options
// pass the "user", "password" and "domain" from command-line
// don't hard-code these into the application!
ConnectionOptions connOpts = new ConnectionOptions();
connOpts.Username = user;
connOpts.Authority = "ntlmdomain:" + domain;
connOpts.Password = password;
// management scope object
ManagementScope manScope = new ManagementScope(@"\\RemoteSystem\root\virtualization", connOpts);
// connect and set up our search
ManagementObjectSearcher vmSearcher = new ManagementObjectSearcher(manScope, queryObj);
ManagementObjectCollection vmCollection = vmSearcher.Get();
// loop through the VMs
foreach (ManagementObject vm in vmCollection)
{
// display VM details
Console.WriteLine("\nName: {0}\nStatus: {1}\nDescription: {2}\n",
vm["ElementName"].ToString(),
vm["EnabledState"].ToString(),
vm["Description"].ToString());
}
これをVisualStudioで実行して、Delphiに変換できるように機能するかどうかを確認しました。しかし、ユーザー名、ドメイン、パスワードを変更しても、次のエラーが発生します。
{"The RPC server is not available. (HRESULT: 0x800706BA)"}