Hi
Is there any way to call COM dll library from crystal code?
You can use C Bindings to call COM API like C.
An incomplete example:
@[Link("ole32")]
lib Ole32
alias HResult = LibC::ULong
fun CoInitialize(pvReserved : Void*) : HResult
fun CoCreateInstance(...) : HResult # parameters are omitted
end
Ole32.CoInitialize(Pointer(Void).null)
Ole32.CoCreateInstance(...)
The above way is low-level calling. If you expect a high-level wrapper like the Ruby win32ole library, AFAIK Crystal doesn’t have one. As a compromise, maybe you can use the mruby library mruby-win32ole via Anyolite .
4 Likes
Thanks for helping me!