1

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)"}
4

2 に答える 2

3

最新のDelphiforWMIは、Rodrigosコンポーネントです。

wmi-delphi-code-creator

object-pascal-wmi-class-generator

于 2011-10-26T18:33:48.373 に答える
1

MagWMIのMagentaSystemsにWMIにアクセスするための無料のDelphiコードがあります。WMIクエリを実行できるデモアプリを含む完全なソースが付属しています。現在のWebページ(上記のリンク)には、現在のWindows(およびDelphi)バージョンと互換性があると記載されています。

特に仮想化で機能するかどうかはわかりませんが、少なくともDelphiコードからWMIを使用できるようになります。(編集:デモはローカルコンピューターでのみ機能するものとして文書化されているため、デモをより理解しやすくするために渡す必要のあるパラメーターが少なくなっています。ただし、DelphiでWMIを使用する基本は示されているため、次のようになります。途中です。)

于 2011-10-26T18:04:56.210 に答える