Error setting input parameter in instance of CIM class/WMI
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Error setting input parameter in instance of CIM class/WMI

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    19

    Lightbulb Error setting input parameter in instance of CIM class/WMI

    Hello.

    I am using C++ to write code to create a network 'team' on a machine having an intel proset network adapter. I am using the IANet_TeamOfAdapter CIM class as mentioned in their WMI scripting guide ( http://downloadmirror.intel.com/9405..._Reference.pdf ).

    To be specific I am unable to set the TeamingMode property of this class. It requires a UINT32 type variable. Hence I first tried with using a variant whose vt type was VT_UI4 but to no avail. I then also tried with VT_UINT but it didnt work as well. I am getting a "WBEM_E_TYPE_MISMATCH" error. Does anyone has any experience with this? How did you go about solving this??

    Another problem that I am facing is this:
    I need to create a variant of type VT_ARRAY thereby holding an array of BSTRs (corresponding to the path of the physical adapters) which I am doing like so:

    Step1:
    CPP / C++ / C Code:
    Code:
    //get the path of the physical adapter which we are going to bind a team on
    _bstr_t PhysicalAdapterPath;
    /*
    Here I get the path using the __PATH variable of the current physical 
    adapter instance and I update PhysicalAdapterPath with it.
    Ive verifed that the correct path was indeed stored using WMI object
    browser. I later use this variable to create a variant holding an array
    of BSTRS which corresponds to this path. 
    */
    Step2:
    CPP / C++ / C Code:
    Code:
    //create a safearray with the physical adapter path
    CComSafeArray<BSTR> PhysicalAdapterPaths;
    //create a 1D safe array with 1 element and lowest index as 0
    PhysicalAdapterPaths.Create(1,0); 
    PhysicalAdapterPaths.Add(PhysicalAdapterPath);
    wprintf(L"Retrieved Adapter Path is \"&#37;s\"\n", \\
    static_cast<wchar_t*>(PhysicalAdapterPaths.GetAt(0)));
    The above wide char printf does not show the content that PhysicalAdapterPath holds. Which means that either the array was not populated properly from PhysicalAdapterPaths or I do not how to get/print/check the content of that location i.e. the BSTR at the 0th index of that array of BSTRS..I even tried to print the contents of the memory location where the array is supposed to start from...specifically I tried printing the memory contents of memory pointed to by parray.. msdn mentions that this variable within a variant gives the "dimentions, size and in-memory location of the array". I strongly think that by merely printing the content of memory starting from 'parray' is the wrong way to print the contents of the array. So..does anyone know how to check the contents of a safearray manually?? Using a debugger like windbg??

    any input would be appreciated....even if you haven't come across this specific issue, anything related and how you went about resolving it would be helpful
    Last edited by aijazbaig1; September 29th, 2011 at 01:21 AM.
    Best Regards,
    Aijaz Baig.

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,642

    Re: Error setting input parameter in instance of CIM class/WMI

    The
    Code:
    PhysicalAdapterPaths.Create(1,0); creates the first entry in the CComSafeArray so
    PhysicalAdapterPaths.Add(PhysicalAdapterPath); makes
    PhysicalAdapterPaths.GetAt(0) return an empty string
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

  3. #3
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    19

    Re: Error setting input parameter in instance of CIM class/WMI

    Quote Originally Posted by S_M_A View Post
    The
    Code:
    PhysicalAdapterPaths.Create(1,0); creates the first entry in the CComSafeArray so
    PhysicalAdapterPaths.Add(PhysicalAdapterPath); makes
    PhysicalAdapterPaths.GetAt(0) return an empty string
    I don't quite understand...could you be a little more elaborate...

    thanks
    Best Regards,
    Aijaz Baig.

  4. #4
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,642

    Re: Error setting input parameter in instance of CIM class/WMI

    I don't know if rephrasing it helps but... your operations on PhysicalAdapterPaths makes it being an array with two entries. The first one is just nothing and the second one is PhysicalAdapterPath. I.e. GetAt(1) will return what you want but that's only because you've populated PhysicalAdapterPaths in the wrong way.

    Running this in the debugger reveals all details. Set a breakpoint at the wprintf statement. When the breakpoint is hit you just need to hover the mouse over the variables to view their content (or use the auto/watch windows).
    Last edited by S_M_A; September 28th, 2011 at 02:16 PM.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

  5. #5
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    19

    Lightbulb Re: Error setting input parameter in instance of CIM class/WMI

    Hello S_M_A.

    Firstly. Im sorry if I sound naive at times, but im a complete noob when it comes to COM. Nevertheless, I think I will have to take ur points one at a time.

    I used the following reference link to create the safearray using this CComSafeArray wrapper class. I used the second definition of this create method with the ulcount and the lBound parameters. This, I entered as 1 and 0 respectively meaning that I need an array with a single element and I want my SAFEARRAY to start from an index of 0.

    Then while adding the data to this newly created safearray, I used the following reference. Within this, I am using the third definition with a constant reference to an object of type T (which in my case is a BSTR). I didn't bother with the bcopy flag since it is TRUE by default and that is what I need since I want to create a new copy and then add it to this array.

    Do you think I should use FALSE here?? Plus you said Ive added the wrong way. Did you mean to say the BSTR has been added to index 1 as opposed to index 0?

    But the definition of the Add method from the link above tells me that it is appended to the existing array object. Now if the new element has indeed been added to index 1 as opposed to index 0, then it means there is something already present at index 0. If it is indeed the case then there could something wrong with the way I have created my array in the first place. But as I have written above, I fail to see where could I have gone wrong while creating the array, since I am following the reference to the letter.

    Thanks for your time S_M_A..and Im keen to hear from you about this.
    Last edited by aijazbaig1; September 29th, 2011 at 01:17 AM.
    Best Regards,
    Aijaz Baig.

  6. #6
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,642

    Re: Error setting input parameter in instance of CIM class/WMI

    I'm neither really a COM guy nor have I used CComSafeArray before so I just pasted your code into an existing project and ran it in the debugger. After that I read this http://msdn.microsoft.com/en-us/libr...(v=VS.80).aspx and that (of course) conforms with the result. The call to Create makes the array being 1 in length and holding an empty element. Calling Add http://msdn.microsoft.com/en-US/libr...(v=VS.80).aspx eh... adds another element thus making the array 2 in length.

    So, if you know how many elements you need you can call Create once and then use SetAt in a loop to populate the array. If you don't know, remove the call to Create and use Add instead.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center