PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/AutoHotkey.docset/Contents/Resources/Documents/commands/ComObjType.htm

https://gitlab.com/ahkscript/Autohotkey.docset
HTML | 95 lines | 79 code | 16 blank | 0 comment | 0 complexity | 263e60db08853229842740e5981ecdcc MD5 | raw file
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>ComObjType()</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <link href="../static/theme.css" rel="stylesheet" type="text/css" />
  8. <script src="../static/content.js" type="text/javascript"></script>
  9. </head>
  10. <body>
  11. <h1>ComObjType() <span class="ver">[v1.0.91+]</span></h1>
  12. <p>Retrieves type information from a COM object.</p>
  13. <pre class="Syntax">VarType := ComObjType(ComObject)
  14. Name := ComObjType(ComObject, "Name")
  15. IID := ComObjType(ComObject, "IID")</pre>
  16. <h3>Parameters</h3>
  17. <dl>
  18. <dt>ComObject</dt>
  19. <dd><p>A wrapper object containing a COM object or typed value.</p></dd>
  20. <dt>VarType</dt>
  21. <dd><p>An integer indicating the type of value. See below.</p></dd>
  22. <dt>Name</dt>
  23. <dd><p>An interface type name.</p></dd>
  24. <dt>IID</dt>
  25. <dd><p>A globally unique identifier (GUID) representing the interface type.</p></dd>
  26. </dl>
  27. <h3>Return Value</h3>
  28. <p>If the second parameter is omitted, the variant type of the value contained by the wrapper object is returned.</p>
  29. <p>If the second parameter is "Name" or "IID" and the wrapper object contains a COM object (variant type VT_DISPATCH), the COM object's type name or the identifier of its primary interface is returned.</p>
  30. <p>If the parameters are invalid or an error occurs, an empty string is returned.</p>
  31. <h3 id="vt">Variant Type Constants</h3>
  32. <pre>
  33. VT_EMPTY = 0 <em>; No value</em>
  34. VT_NULL = 1 <em>; SQL-style Null</em>
  35. VT_I2 = 2 <em>; 16-bit signed int</em>
  36. VT_I4 = 3 <em>; 32-bit signed int</em>
  37. VT_R4 = 4 <em>; 32-bit floating-point number</em>
  38. VT_R8 = 5 <em>; 64-bit floating-point number</em>
  39. VT_CY = 6 <em>; Currency</em>
  40. VT_DATE = 7 <em>; Date</em>
  41. VT_BSTR = 8 <em>; COM string (Unicode string with length prefix)</em>
  42. VT_DISPATCH = 9 <em>; COM object</em>
  43. VT_ERROR = 0xA <em>; Error code (32-bit integer)</em>
  44. VT_BOOL = 0xB <em>; Boolean True (-1) or False (0)</em>
  45. VT_VARIANT = 0xC <em>; <a href="http://msdn.microsoft.com/en-us/library/ms221627.aspx">VARIANT</a> (must be combined with VT_ARRAY or VT_BYREF)</em>
  46. VT_UNKNOWN = 0xD <em>; IUnknown interface pointer</em>
  47. VT_DECIMAL = 0xE <em>; (not supported)</em>
  48. VT_I1 = 0x10 <em>; 8-bit signed int</em>
  49. VT_UI1 = 0x11 <em>; 8-bit unsigned int</em>
  50. VT_UI2 = 0x12 <em>; 16-bit unsigned int</em>
  51. VT_UI4 = 0x13 <em>; 32-bit unsigned int</em>
  52. VT_I8 = 0x14 <em>; 64-bit signed int</em>
  53. VT_UI8 = 0x15 <em>; 64-bit unsigned int</em>
  54. VT_INT = 0x16 <em>; Signed machine int</em>
  55. VT_UINT = 0x17 <em>; Unsigned machine int</em>
  56. VT_RECORD = 0x24 <em>; User-defined type -- NOT SUPPORTED</em>
  57. VT_ARRAY = 0x2000 <em>; <a href="http://msdn.microsoft.com/en-us/library/ms221482.aspx">SAFEARRAY</a></em>
  58. VT_BYREF = 0x4000 <em>; Pointer to another type of value</em>
  59. <em>/*
  60. VT_ARRAY and VT_BYREF are combined with another value (using bitwise OR)
  61. to specify the exact type. For instance, 0x2003 identifies a <a href="http://msdn.microsoft.com/en-us/library/ms221482.aspx">SAFEARRAY</a>
  62. of 32-bit signed integers and 0x400C identifies a pointer to a <a href="http://msdn.microsoft.com/en-us/library/ms221627.aspx">VARIANT</a>.
  63. */</em>
  64. </pre>
  65. <h3>General Remarks</h3>
  66. <p>In most common cases, return values from methods or properties of COM objects are converted to an appropriate data type supported by AutoHotkey. Types which aren't specifically handled are coerced to strings via <a href="http://msdn.microsoft.com/en-us/library/ms221258.aspx">VariantChangeType</a>; if this fails or if the variant type contains the VT_ARRAY or VT_BYREF flag, an object containing both the value and its type is returned instead.</p>
  67. <p>For any variable <i>x</i>, if <code>ComObjType(x)</code> returns an integer, <i>x</i> contains a COM object wrapper.</p>
  68. <h3>Related</h3>
  69. <p><a href="ComObjValue.htm">ComObjValue</a>, <a href="ComObjCreate.htm">ComObjCreate</a>, <a href="ComObjGet.htm">ComObjGet</a>, <a href="ComObjActive.htm">ComObjActive</a></p>
  70. <h3>Examples</h3>
  71. <pre class="NoIndent">
  72. d := <a href="ComObjCreate.htm">ComObjCreate</a>("Scripting.Dictionary")
  73. VarType := ComObjType(d) <em>; Always 9 for script-callable objects.</em>
  74. Name := ComObjType(d, "Name") <em>; Only valid for script-callable objects.</em>
  75. IID := ComObjType(d, "IID") <em>; As above.</em>
  76. MsgBox Variant type:`t%VarType%`nType name:`t%Name%`nInterface ID:`t%IID%
  77. </pre>
  78. </body>
  79. </html>