-
Hi Tim, I would like to implement a third party COM object. I have checked the below docs:
but now I still don't have any idea how to do, as I understand:
Please let me know if there is something wrong. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
After days' search, I need update the question:
I checked the file generated by Tlbimp.exe by ILSpy and there are information as metadata:
Can we parse the metadata and make a projection between COM and dart class? Thank you. |
Beta Was this translation helpful? Give feedback.
-
You should be able to parse the metadata with https://pub.dev/packages/winmd. But you don't necessarily need metadata to build the interop class: you just need to understand the COM object you're wrapping. If you look at a class like https://github.com/timsneath/win32/blob/main/lib/src/com/ISpellCheckerFactory.dart, you'll see how to manually create a similar definition. A vtable is just a table of function pointers. If an interface inherits from The existing projection tooling was only written with Win32 APIs in mind, unfortunately. I haven't tested it with other .winmd files. |
Beta Was this translation helpful? Give feedback.
-
Thank you Tim, The other hand is that the .Net interop handles the COM very easy and no such difficult things(only for me), I need count the elements and check every parameter. For a specific question, do you know how to handle the below projection: [id(0x68030001), propget, helpstring("Get/assign wave,n,k values")] In .Net, it projection as below: In VBA it need ReDim xIndx(10, 3) I don't know what is VARIANT*, I searched it and get a page https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/variant-data-type, it looks like a object(can be anything). Please help me check how to projection it to dart types. |
Beta Was this translation helpful? Give feedback.
-
The Win32 package has a https://pub.dev/documentation/win32/latest/win32/VARIANT-class.html Variant is weakly typed and can contain almost any value; it's your responsibility to know which type to extract from it. For example, you can call |
Beta Was this translation helpful? Give feedback.
-
Thank you, Tim, Sorry for the stupid headache question wastes your time. I tried to define a ARRAY.multi (https://api.dart.dev/stable/2.14.1/dart-ffi/Array/Array.multi.html) and then send to the function but failed. Array<Array> array = Array.multi([4, 4]);
if I define the function parameter as VARIANT as below: the error is: if I define the function parameter as Array<Array> as below: The error is: Would you please help check this? |
Beta Was this translation helpful? Give feedback.
-
We're some way from the win32 package at this point, but the main challenge you have is how to express an array in the The Dart definition of You need to set the |
Beta Was this translation helpful? Give feedback.
-
OK thank you. |
Beta Was this translation helpful? Give feedback.
We're some way from the win32 package at this point, but the main challenge you have is how to express an array in the
VARIANT
data type.The Dart definition of
VARIANT
is here:https://github.com/timsneath/win32/blob/83e32cb0426b3ee066e1c5ea36d5e8d1b0756f7f/lib/src/structs.dart#L328
You need to set the
vt
to the right array type (Win32 has multiple), and then setllVal
to the memory address. Beyond that, I can't help you, I'm afraid -- we're getting into the vagaries of callingIDispatch
and OLE Automation from native code, rather than Dart interop.