How do I cast a variable of WMI class Win32_ProcessStartup to a Variant

2007-02-25 02:30:21 AM
I have customized the create method of Win32_Process by a series of
functions. And for the most part is works. The create function is defined
Create(string CommandLine, string CurrentDirectory,
Win32_ProcessStartup ProcessStartupInformation, uint32
For the most part I use a series of Variants for the arguments of which I
then pass to a custom function call ExecuteTheMethod(className, methodName,
Arguments, Var). ExecuteTheMethod contains code to GetMethod,
SpawnInstance, extract the arguments and the variant data and put them into
the Create function and so on. That much works.
My only problem is that I don't know how to use the Win32_ProcessStartup
class which is the ProcessStartupInformation argument in the create
function. The class is defines as:
class Win32_ProcessStartup : Win32_MethodParameterClass
uint32 CreateFlags;
string EnvironmentVariables[];
uint16 ErrorMode;
uint32 FillAttribute;
uint32 PriorityClass;
uint16 ShowWindow;
string Title;
string WinstationDesktop;
uint32 X;
uint32 XCountChars;
uint32 XSize;
uint32 Y;
uint32 YCountChars;
uint32 YSize;
I've got the other variables down pat, but I because I don't know how use
Win32_ProcessStartup to say set the ShowWindow, my process starts but does
not appear on the target screen. It just shows up in 'task manager'.
Right now I pass a '0' into the Variant that represents
ProcessStartupInformation to get it going. Something like:
Variant varValue;
varValue = 0;
Var[0].vt = VT_BSTR; Var[0] = Variant(CommandLine);
Var[1].vt = VT_BSTR; Var[1] = Variant(CurrentDirectory);
Var[2].vt = VT_UNKNOWN; Var[2] = varValue; <------------HERE
Var[3].vt = VT_I4; Var[3].uintVal = ProcessId;
BSTR methodName = SysAllocString(L"Create");
retcode = ExecuteTheMethod(className, methodName, Arguments, Var);
How do I set ProcessStartupInformation as a Variant so I can pass it to my
function ExecuteTheMethod?