PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/PropertyStore/PropertyStore.ahk

http://github.com/maul-esel/COM-Classes
AutoHotKey | 114 lines | 35 code | 6 blank | 73 comment | 2 complexity | fb568b871b8338971252b257f8a5f076 MD5 | raw file
  1. /*
  2. class: PropertyStore
  3. wraps the *IPropertyStore* interface and exposes methods for enumerating, getting, and setting property values.
  4. Authors:
  5. - maul.esel (https://github.com/maul-esel)
  6. License:
  7. - *LGPL* (http://www.gnu.org/licenses/lgpl-2.1.txt)
  8. Documentation:
  9. - *class documentation* (http://maul-esel.github.com/COM-Classes/master/PropertyStore)
  10. - *msdn* (http://msdn.microsoft.com/en-us/library/windows/desktop/bb761474)
  11. Requirements:
  12. AutoHotkey - AHK v2 alpha
  13. OS - Windows Vista / Windows Server 2008 or higher
  14. Base classes - _CCF_Error_Handler_, Unknown
  15. Structure classes - PROPERTYKEY
  16. */
  17. class PropertyStore extends Unknown
  18. {
  19. /*
  20. Field: IID
  21. This is IID_IPropertyStore. It is required to create an instance.
  22. */
  23. static IID := "{886d8eeb-8cf2-4446-8d02-cdba1dbdcf99}"
  24. /*
  25. Field: CLSID
  26. This is CLSID_InMemoryPropertyStore. It is required to create an instance.
  27. */
  28. static CLSID := "{9a02e012-6303-4e1e-b9a1-630f802592c5}"
  29. /*
  30. Method: GetCount
  31. Gets the number of properties attached to the file.
  32. Returns:
  33. UINT count - the property count
  34. */
  35. GetCount()
  36. {
  37. local count
  38. this._Error(DllCall(NumGet(this.vt+03*A_PtrSize), "ptr", this.ptr, "uint*", count))
  39. return count
  40. }
  41. /*
  42. Method: GetAt
  43. Gets a property key from an item's array of properties.
  44. Parameters:
  45. UINT index - The index of the property key in the array of PROPERTYKEY structures. This is a zero-based index.
  46. Returns:
  47. UPTR ptr - a PROPERTYKEY instance
  48. */
  49. GetAt(index)
  50. {
  51. local out
  52. this._Error(DllCall(NumGet(this.vt+04*A_PtrSize), "ptr", this.ptr, "uint", index, "ptr*", out))
  53. return PROPERTYKEY.FromStructPtr(out)
  54. }
  55. /*
  56. Method: GetValue
  57. Gets data for a specific property.
  58. Parameters:
  59. PROPERTYKEY key - a reference to the PROPERTYKEY structure retrieved through IPropertyStore::GetAt (either a raw memory pointer or a PROPERTYKEY instance).
  60. Parameters:
  61. UPTR ptr - a pointer to a PROPVARIANT structure *(To be replaced by PROPVARIANT instance!)*
  62. */
  63. GetValue(key)
  64. {
  65. local out
  66. if IsObject(key)
  67. key := key.ToStructPtr()
  68. this._Error(DllCall(NumGet(this.vt+05*A_PtrSize), "ptr", this.ptr, "ptr", key, "ptr*", out))
  69. return out
  70. }
  71. /*
  72. Method: SetValue
  73. Sets a new property value, or replaces or removes an existing value.
  74. Parameters:
  75. PROPERTYKEY key - a reference to the PROPERTYKEY structure retrieved through IPropertyStore::GetAt (either a raw memory pointer or a PROPERTYKEY instance).
  76. UPTR ptr - a pointer to a PROPVARIANT structure
  77. Returns:
  78. BOOL success - true on success, false otherwise
  79. */
  80. SetValue(key, value)
  81. {
  82. if IsObject(key)
  83. key := key.ToStructPtr()
  84. return this._Error(DllCall(NumGet(this.vt+06*A_PtrSize), "ptr", this.ptr, "ptr", key, "ptr", value))
  85. }
  86. /*
  87. Method: Commit
  88. Saves a property change.
  89. Returns:
  90. BOOL success - true on success, false otherwise
  91. */
  92. Commit()
  93. {
  94. return this._Error(DllCall(NumGet(this.vt+07*A_PtrSize), "ptr", this.ptr))
  95. }
  96. }