sys.COM(classname, [use_existing]) constructor
The COM constructor returns a COM object instance, representing an abstraction of a Windows COM object.
COM objects are a collection of Windows registered components that expose a programmable interface to be used by another program or environment. Luart COM Object provides seamless integration of Windows COM objects to Lua (method call, property read/write...).
Therefore, the sys.COM Object has no method or property. It uses instead the methods and properties defined by the Windows COM component.
Parameters
classname
A string representing the class name of the Windows COM object. The class name must correspond to a Windows registered COM component.
[use_existing]
An optional boolean
, that when set to true
, indicates that an already running instance of the COM object will be used. If set to false
= (the default), the system will create a new instance of the COM object.
When using Luart x64 interpreter, the class may not exists as some Windows COM objects are only 32bits compatible.
Example
local dbname = "data.mdb"
-- Create a ADOX.Catalog COM object
local cat = sys.COM("ADOX.Catalog")
-- Call the "Create" method of ADOX.Catalog object to create a _Connection (another COM Object) to the database file
local con = cat:Create("Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source="..dbname)