はじめまして。DelphiでSystemRestorePointを列記するプログラムを
書こうと思っているのですが、WMIを使わないと無理なようで、VBで
のサンプルプログラムを見つけたのですが、これをDelphiに直そうに
も、どこから手を付けてよいのかわかりません。
どのように書けばよいのか、お教え願えませんでしょうか。
Public Sub ListPoints() 'Adds all Restore Points to a ListView
Dim o As Object
Dim sr As Object
Dim yr As String, mo As String, dy As String
Dim lvItem As ListItem
'Get all points and add them to "o"
Set o = GetObject("winmgmts:root/default").InstancesOf("SystemRestore")
'Scroll through "o"
For Each sr In o
'Adds a point to a ListView with the Restore Point ID as a Key
Set lvItem = ListView2.ListItems.Add(, "P" & sr.SequenceNumber, sr.Description)
'Make a date
yr = Mid$(sr.CreationTime, 1, 4)
mo = Mid$(sr.CreationTime, 5, 2)
dy = Mid$(sr.CreationTime, 7, 2)
lvItem.SubItems(1) = mo & "/" & dy & "/" & yr
Next sr
End Sub
Microsoft から Scripting Control を入手してインストールすれば、
こんな感じでイケル。
var
sr: OLEVAriant;
begin
ScriptControl1.Language := 'VBScript';
sr := ScriptControl1.Eval('GetObject("winmgmts:\\.\root\default:SystemRestore")');
........
ツイート | ![]() |