英語で読む

次の方法で共有


Retrieves the IDispatch interface for the methods and properties associated with the currently running script.

Microsoft® Windows® Script Interfaces
IActiveScript::GetScriptDispatch
 Language Reference
Previous
Next

  HRESULT GetScriptDispatch(
    LPCOLESTR pstrItemName  // address of item name
    IDispatch **ppdisp      // receives IDispatch pointer
);

  • Returns one of the following values:

    Return Value Meaning S_OK Success. E_INVALIDARG An argument was invalid. E_POINTER An invalid pointer was specified. E_UNEXPECTED The call was not expected (for example, the scripting engine has not yet been loaded or initialized). S_FALSE The scripting engine does not support a dispatch object; the ppdisp parameter is set to NULL.
  • pstrItemName
    [in] Address of a buffer that contains the name of the item for which the caller needs the associated dispatch object. If this parameter is NULL, the dispatch object contains as its members all of the global methods and properties defined by the script. Through the IDispatch interface and the associated ITypeInfo interface, the host can invoke script methods or view and modify script variables.
  • ppdisp
    [out] Address of a variable that receives a pointer to the object associated with the script's global methods and properties. If the scripting engine does not support such an object, NULL is returned.

Because methods and properties can be added by calling the IActiveScriptParse interface, the IDispatch interface returned by this method can dynamically support new methods and properties. Similarly, the IDispatch::GetTypeInfo method should return a new, unique ITypeInfo interface when methods and properties are added. Note, however, that language engines must not change the IDispatch interface in a way that is incompatible with any previous ITypeInfo interface returned. That implies, for example, that DISPIDs will never be reused.