Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use string[] #65

Closed
seruum opened this issue Jan 7, 2021 · 2 comments
Closed

Can't use string[] #65

seruum opened this issue Jan 7, 2021 · 2 comments

Comments

@seruum
Copy link

seruum commented Jan 7, 2021

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?

@khchen
Copy link
Owner

khchen commented Jan 8, 2021

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

@seruum
Copy link
Author

seruum commented Jan 8, 2021

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.

@seruum seruum closed this as completed Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants