Lua Memo

タイプライブラリの列挙

luacom のサンプル "testenum.lua" にやり方がある

これを汎用的な形式にしたものが以下。

require("luacom")

function printTypeLib(ProgID)
	local conn = luacom.CreateObject(ProgID)
	if not conn then error("Failed:CreateObject ["..libname.."]") end
	local typeinfo = luacom.GetTypeInfo(conn)
	local typelib = typeinfo:GetTypeLib()
	local enums = typelib:ExportEnumerations()
	for key, val in pairs(enums) do
		print("----------------------------")
		print("-- "..key)
		print("----------------------------")
		if(type(val)=="table") then
			for key, val in pairs(val) do
				print(tostring(key) .. " = " .. tostring(val))
			end
		end
	end
end

printTypeLib("Excel.Application")