VC8.0 から PowerShell の操作に失敗
C++(VC8.0)から COM 相互運用機能経由で PowerShell を操作するコードを
書こうとして挫折しました。素直に C++/CLI で DLL を作って、その DLL 経由で
操作するのがいいのでしょうかね
■ 挫折した際の手順
(1) PowerShell と Windows SDK の導入
(2) DLL のコピー
C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0\*.dll を
C:\WINDOWS\system32\windowspowershell\v1.0 へコピー
(3) COM のタイプライブラリを作成
regasm /codebase System.Management.Automation.dll /tlb を投入すると、
System.Management.Automation.tlb が生成され、レジストリに
タイプライブラリが登録される
(4) COM のタイプライブラリの中身を見る(空っぽでした。#import 後に出来る tlh ファイルも同様)
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: System.Management.Automation.tlb
[
uuid(30D45C1D-515D-3BAE-8F81-768D97FC0F68),
version(1.0),
helpstring("Microsoft Command-Line Shell Engine Core Assembly"),
custom(90883F05-3D28-11D2-8F17-00A0C9A6186D, System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
]
library System_Management_Automation
{
// TLib : // Forward declare all types defined in this typelib
};
(5) CLSID の確認
CLSID が見つかりませんでした。System.Collections.ArrayList の場合、以下にあります
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\System.Collections.ArrayList\CLSID