Jump to content

caught in translation...

Recommended Posts

i know nothing of C++ but was wondering what the translation of this would look like... for refences to C++ to autoit (Would be a Awesome Help File) :)

void CreateClass(IWbemServices *pSvc)
  IWbemClassObject *pNewClass = 0;
  IWbemContext *pCtx = 0;
  IWbemCallResult *pResult = 0;

  // Get a class definition. 
  // ============================
  HRESULT hRes = pSvc->GetObject(0, 0, pCtx, &pNewClass, &pResult);

  // Create the class name.
  // ============================
  V_VT(&v) = VT_BSTR;
  V_BSTR(&v) = SysAllocString(L"Example");
  BSTR Class = SysAllocString(L"__CLASS");
  pNewClass->Put(Class, 0, &v, 0);

  // Create the key property. 
  // ============================
  BSTR KeyProp = SysAllocString(L"Index");
  pNewClass->Put(KeyProp, 0, NULL, CIM_STRING);

  // Attach Key qualifier to mark the "Index" property as the key.
  // ============================
  IWbemQualifierSet *pQual = 0;
  pNewClass->GetPropertyQualifierSet(KeyProp, &pQual);

  V_VT(&v) = VT_BOOL;
  BSTR Key = SysAllocString(L"Key");

  pQual->Put(Key, &v, 0);   // Flavors not required for Key 

  // No longer need the qualifier set for "Index"

  // Create other properties.
  // ============================
  V_VT(&v) = VT_BSTR;
  V_BSTR(&v) = SysAllocString(L"<default>");
  BSTR OtherProp = SysAllocString(L"OtherInfo");
  pNewClass->Put(OtherProp, 0, &v, CIM_STRING);

  OtherProp = SysAllocString(L"IntVal");
  pNewClass->Put(OtherProp, 0, NULL, CIM_SINT32); // NULL is default
  // Register the class with WMI
  // ============================
  hRes = pSvc->PutClass(pNewClass, 0, pCtx, &pResult);
http://www.myclanhosting.com/defiasVisit Join and contribute to a soon to be leader in Custumized tools development in [C# .Net 1.1 ~ 2.0/C/C++/MFC/AutoIt3/Masm32]
Link to post
Share on other sites

Loosely translated since I'm not familiar with those COM interfaces:

class MyClass
    MyClass() : m_iIndex(0) { }
    MyClass(const int index) : m_iIndex(index) { }

    void SetIndex(const int index)
        m_iIndex = index;
    const int GetIndex() const
        return m_iIndex;
    int m_iIndex;

You can add a similar getter/setter for the "OtherProp" property. Note that "properties" are not something inherent to C++ objects. At least, they are not called properties. They are referred to as data members. This one has a data member of an int and provides a function to access that value and a function to set that value. In COM, which is what that code is utilizing, properties are more akin to meta-data for the "object". A meta-data-like approach isn't implemented in the same way in C++ as compared to COM. You're really comparing cars to doorknobs asking for much of a translation here.

Link to post
Share on other sites

Loosely translated since I'm not familiar with those COM interfaces:

O.K. And here is my "simplified" transalation to AutoIT.

func _Ret($val)
  return $val

@WSCPorts: I hope this helps.



__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...