khchen / winim

Windows API, COM, and CLR Module for Nim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't use string[]

seruum opened this issue · comments

I was trying to collect information from win32_NTLogEvent. Everything is working except for InsertionStrings. This is described as a string array (string[]), but I can't seem to figure out how convert it to a seq[strings]. I tried following the example in issue #63 because it looked to be similar, but couldn't get it to work.

Is there an example of how to do this?

commented

Use fromVariant[COMArray1D]:

import winim/com

var wmi = GetObject("winmgmts://.")
for i in wmi.ExecQuery("SELECT * FROM Win32_NTlogEvent"):
  for j in fromVariant[COMArray1D](i.InsertionStrings):
    echo j

  break

Thank you for the clarification. I didn't see to use fromVariant directly like that. And likely never would have on my own.
This worked perfectly.
And, I appreciate this library. It has kept me from resorting to VB or powershell from small tasks.
Thanks again.