FYI: How to create a non-VT_VARIANT SafeArray

6 views
Skip to first unread message

Markus Karg

unread,
Jan 25, 2024, 5:40:29 AMJan 25
to Java Native Access
I just noticed something JNA beginners should be aware of:

You might assume that the following code should create a SafeArray being able to hold n elements of type  VT_UI1 , but actually it will hold elements of type VT_VARIANT instead!

OaIdl.SAFEARRAY.createSafeArray(VT_UI1, n))

The correct way is:

OaIdl.SAFEARRAY.createSafeArray(new WTypes.VARTYPE(VT_UI1), n))

HTH
-Markus
Reply all
Reply to author
Forward
0 new messages