Skip to content

Commit 94386a1

Browse files
committed
Added missing API, constants...
1 parent 35cc5e2 commit 94386a1

5 files changed

Lines changed: 706 additions & 80 deletions

File tree

contrib/platform/src/com/sun/jna/platform/win32/Ole32.java

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.sun.jna.Native;
1616
import com.sun.jna.Pointer;
1717
import com.sun.jna.WString;
18+
import com.sun.jna.platform.win32.COM.IUnknown;
1819
import com.sun.jna.platform.win32.Guid.CLSID;
1920
import com.sun.jna.platform.win32.Guid.GUID;
2021
import com.sun.jna.platform.win32.WinDef.LPVOID;
@@ -35,6 +36,107 @@ public interface Ole32 extends StdCallLibrary {
3536
Ole32 INSTANCE = (Ole32) Native.loadLibrary("Ole32", Ole32.class,
3637
W32APIOptions.UNICODE_OPTIONS);
3738

39+
/**
40+
* Identifies the version number of the installed OLE framework.
41+
*
42+
* @return A DWORD uniquely identifying the installed OLE framework build.
43+
*/
44+
int OleBuildVersion();
45+
46+
/**
47+
* Initializes the COM library on the current apartment, identifies the
48+
* concurrency model as single-thread apartment (STA), and enables
49+
* additional functionality described in the Remarks section below.
50+
* Applications must initialize the COM library before they can call COM
51+
* library functions other than CoGetMalloc and memory allocation functions.
52+
* @param pvReserved Reserved; must be null
53+
* @return S_OK if the COM library and additional functionality were
54+
* initialized successfully on this apartment.
55+
* S_FALSE if the COM library is already initialized on this apartment.
56+
* OLE_E_WRONGCOMPOBJ if the versions of COMPOBJ.DLL and OLE2.DLL on
57+
* your machine are incompatible with each other.
58+
* RPC_E_CHANGED_MODE if a previous call to CoInitializeEx specified
59+
* the concurrency model for this apartment as
60+
* multithread apartment (MTA). If running
61+
* Windows 2000, this could also mean that a
62+
* change from neutral threaded apartment to
63+
* single threaded apartment occurred.
64+
*/
65+
HRESULT OleInitialize(Pointer pvReserved);
66+
/**
67+
* Closes the COM library on the apartment, releases any class factories,
68+
* other COM objects, or servers held by the apartment, disables RPC on the
69+
* apartment, and frees any resources the apartment maintains.
70+
*
71+
* Remarks:
72+
* Call OleUninitialize on application shutdown, as the last COM library
73+
* call, if the apartment was initialized with a call to
74+
* {@link #OleInitialize}. OleUninitialize calls the CoUninitialize function
75+
* internally to shut down the OLE Component Object(COM) Library.
76+
*
77+
* If the COM library was initialized on the apartment with a call to
78+
* CoInitialize or CoInitializeEx, it must be closed with a call to
79+
* CoUninitialize.
80+
*
81+
* The {@link #OleInitialize} and OleUninitialize calls must be balanced —
82+
* if there are multiple calls to the {@link #OleInitialize} function, there
83+
* must be the same number of calls to OleUninitialize: Only the
84+
* OleUninitialize call corresponding to the {@link #OleInitialize} call
85+
* that actually initialized the library can close it.
86+
*/
87+
void OleUninitialize();
88+
89+
/**
90+
* Carries out the clipboard shutdown sequence. It also releases the
91+
* IDataObject pointer that was placed on the clipboard by the
92+
* OleSetClipboard function.
93+
* @return S_OK on success.
94+
* CLIPBRD_E_CANT_OPEN The Windows OpenClipboard function used
95+
* within OleFlushClipboard failed.
96+
* CLIPBRD_E_CANT_CLOSE The Windows CloseClipboard function used
97+
* within OleFlushClipboard failed.
98+
*
99+
* Remarks:
100+
* OleFlushClipboard renders the data from a data object onto the clipboard
101+
* and releases the IDataObject pointer to the data object. While the
102+
* application that put the data object on the clipboard is running, the
103+
* clipboard holds only a pointer to the data object, thus saving memory.
104+
* If you are writing an application that acts as the source of a clipboard
105+
* operation, you can call the OleFlushClipboard function when your
106+
* application is closed, such as when the user exits from your application.
107+
* Calling OleFlushClipboard enables pasting and paste-linking of OLE
108+
* objects after application shutdown.
109+
* Before calling OleFlushClipboard, you can easily determine if your data
110+
* is still on the clipboard with a call to the OleIsCurrentClipboard
111+
* function.
112+
*
113+
* OleFlushClipboard leaves all formats offered by the data transfer object,
114+
* including the OLE 1 compatibility formats, on the clipboard so they are
115+
* available after application shutdown. In addition to OLE 1 compatibility
116+
* formats, these include all formats offered on a global handle medium (all
117+
* except for TYMED_FILE) and formatted with a null target device. For
118+
* example, if a data-source application offers a particular clipboard
119+
* format (say cfFOO) on an IStorage object, and calls the OleFlushClipboard
120+
* function, the storage object is copied into memory and the hglobal memory
121+
* handle is put on the clipboard.
122+
*
123+
* To retrieve the information on the clipboard, you can call the
124+
* OleGetClipboard function from another application, which creates a
125+
* default data object, and the hglobal from the clipboard again becomes a
126+
* storage object. Furthermore, the FORMATETC enumerator and the
127+
* IDataObject::QueryGetData method would all correctly indicate that the
128+
* original clipboard format (cfFOO) is again available on a TYMED_ISTORAGE.
129+
*
130+
* To empty the clipboard, call the OleSetClipboard function specifying a
131+
* null value for its parameter. The application should call this when it
132+
* closes if there is no need to leave data on the clipboard after shutdown,
133+
* or if data will be placed on the clipboard using the standard Windows
134+
* clipboard functions.
135+
*/
136+
HRESULT OleFlushClipboard();
137+
138+
HRESULT OleRun(Pointer pUnknown);
139+
38140
/**
39141
* Creates a GUID, a unique 128-bit integer used for CLSIDs and interface
40142
* identifiers.

contrib/platform/src/com/sun/jna/platform/win32/OleAuto.java

Lines changed: 157 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import com.sun.jna.platform.win32.WinDef.PVOID;
3333
import com.sun.jna.platform.win32.WinDef.UINT;
3434
import com.sun.jna.platform.win32.WinNT.HRESULT;
35-
import com.sun.jna.platform.win32.COM.TypeLib;
3635
import com.sun.jna.ptr.DoubleByReference;
3736
import com.sun.jna.ptr.PointerByReference;
3837
import com.sun.jna.win32.StdCallLibrary;
@@ -215,6 +214,163 @@ public interface OleAuto extends StdCallLibrary {
215214
*/
216215
HRESULT VariantClear(Pointer pvarg);
217216

217+
public static final short VARIANT_NOVALUEPROP = 0x01;
218+
/** For VT_BOOL to VT_BSTR conversions, convert to "True"/"False" instead of "-1"/"0" */
219+
public static final short VARIANT_ALPHABOOL = 0x02;
220+
/** For conversions to/from VT_BSTR, passes LOCALE_NOUSEROVERRIDE to core coercion routines */
221+
public static final short VARIANT_NOUSEROVERRIDE = 0x04;
222+
public static final short VARIANT_CALENDAR_HIJRI = 0x08;
223+
/** For VT_BOOL to VT_BSTR and back, convert to local language rather than English */
224+
public static final short VARIANT_LOCALBOOL = 0x10;
225+
/** SOUTHASIA calendar support */
226+
public static final short VARIANT_CALENDAR_THAI = 0x20;
227+
/** SOUTHASIA calendar support */
228+
public static final short VARIANT_CALENDAR_GREGORIAN = 0x40;
229+
/** NLS function call support */
230+
public static final short VARIANT_USE_NLS = 0x80;
231+
232+
/**
233+
* Converts a variant from one type to another.
234+
* @param pvargDest [out] The destination variant. If this is the same as
235+
* pvarSrc, the variant will be converted in place.
236+
* @param pvarSrc [in] The variant to convert.
237+
* @param wFlags Combination of the following flags
238+
* <table>
239+
* <thead>
240+
* <tr><th><!--indent under wFlags comment--><div style="visibility: hidden">wFlags</div></th><th>Value</th><th>Meaning</th></tr>
241+
* </thead>
242+
* <tbody valign="top">
243+
* <tr><th></th><td>{@link #VARIANT_NOVALUEPROP}</td><td>Prevents the function from attempting to coerce an object to a fundamental type by getting the Value property. Applications should set this flag only if necessary, because it makes their behavior inconsistent with other applications.</td></tr>
244+
* <tr><th></th><td>{@link #VARIANT_ALPHABOOL}</td><td>Converts a {@link Variant#VT_BOOL VT_BOOL} value to a string containing either "True" or "False".</td></tr>
245+
* <tr><th></th><td>{@link #VARIANT_NOUSEROVERRIDE}</td><td>For conversions to or from {@link Variant#VT_BSTR VT_BSTR}, passes LOCALE_NOUSEROVERRIDE to the core coercion routines.</td></tr>
246+
* <tr><th></th><td>{@link #VARIANT_LOCALBOOL}</td><td>For conversions from {@link Variant#VT_BOOL VT_BOOL} to {@link Variant#VT_BSTR VT_BSTR} and back, uses the language specified by the locale in use on the local computer.</td></tr>
247+
* </tbody>
248+
* </table>
249+
* @param vt The type to convert to. If the return code is {@link WinError#S_OK S_OK}, the vt
250+
* field of the vargDest is guaranteed to be equal to this value.
251+
* @return This function can return one of these values:
252+
* <table>
253+
* <thead>
254+
* <tr><th>Return code</th><th>Description</th></tr>
255+
* </thead>
256+
* <tbody valign="top">
257+
* <tr><td>{@link WinError#S_OK S_OK}</td><td>Success.</td></tr>
258+
* <tr><td>{@link WinError#DISP_E_BADVARTYPE DISP_E_BADVARTYPE}</td><td>The variant type is not a valid type of variant.</td></tr>
259+
* <tr><td>{@link WinError#DISP_E_OVERFLOW DISP_E_OVERFLOW}</td><td>The data pointed to by pvarSrc does not fit in the destination type.</td></tr>
260+
* <tr><td>{@link WinError#DISP_E_TYPEMISMATCH DISP_E_TYPEMISMATCH}</td><td>The argument could not be coerced to the specified type.</td></tr>
261+
* <tr><td>{@link WinError#E_INVALIDARG E_INVALIDARG}</td><td>One of the arguments is not valid.</td></tr>
262+
* <tr><td>{@link WinError#E_OUTOFMEMORY E_OUTOFMEMORY}</td><td>Insufficient memory to complete the operation.</td></tr>
263+
* </tbody>
264+
* </table>
265+
*</p>
266+
* <b>Remarks</b>
267+
*</p>
268+
* The VariantChangeType function handles coercions between the fundamental
269+
* types (including numeric-to-string and string-to-numeric coercions). The
270+
* pvarSrc argument is changed during the conversion process. For example,
271+
* if the source variant is of type {@link Variant#VT_BOOL VT_BOOL} and the
272+
* destination is of type {@link Variant#VT_UINT VT_UINT}, the pvarSrc
273+
* argument is first converted to {@link Variant#VT_I2 VT_I2} and then the
274+
* conversion proceeds. A variant that has {@link Variant#VT_BYREF VT_BYREF}
275+
* set is coerced to a value by obtaining the referenced value. An object is
276+
* coerced to a value by invoking the object's Value property
277+
* ({@link OaIdl#DISPID_VALUE DISPID_VALUE}).
278+
*</p>
279+
* Typically, the implementor of
280+
* {@link com.sun.jna.platform.win32.COM.IDispatch#Invoke IDispatch.Invoke}
281+
* determines which member is being accessed, and then calls
282+
* VariantChangeType to get the value of one or more arguments. For example,
283+
* if the IDispatch call specifies a SetTitle member that takes one string
284+
* argument, the implementor would call VariantChangeType to attempt to
285+
* coerce the argument to {@link Variant#VT_BSTR VT_BSTR}. If
286+
* VariantChangeType does not return an error, the argument could then be
287+
* obtained directly from the
288+
* {@link Variant.VARIANT._VARIANT.__VARIANT#bstrVal bstrVal} field of the
289+
* {@link Variant.VARIANT VARIANT}. If VariantChangeType returns
290+
* {@link WinError#DISP_E_TYPEMISMATCH DISP_E_TYPEMISMATCH}, the implementor
291+
* would set {@link com.sun.jna.platform.win32.COM.IDispatch#Invoke Invoke}
292+
* <code> puArgErr</code> parameter referenced value to 0 (indicating the
293+
* argument in error) and return DISP_E_TYPEMISMATCH from Invoke.
294+
*</p>
295+
* Arrays of one type cannot be converted to arrays of another type with
296+
* this function.
297+
*</p>
298+
* <b>Note</b> The type of a {@link Variant.VARIANT VARIANT} should not be
299+
* changed in the {@link DISPPARAMS#rgvarg rgvarg} array in place.
300+
*/
301+
HRESULT VariantChangeType(VARIANT pvargDest, VARIANT pvarSrc, short wFlags, VARTYPE vt);
302+
303+
/**
304+
* Converts a variant from one type to another.
305+
* @param pvargDest [out] The destination variant. If this is the same as
306+
* pvarSrc, the variant will be converted in place.
307+
* @param pvarSrc [in] The variant to convert.
308+
* @param wFlags Combination of the following flags
309+
* <table>
310+
* <thead>
311+
* <tr><th><!--indent under wFlags comment--><div style="visibility: hidden">wFlags</div></th><th>Value</th><th>Meaning</th></tr>
312+
* </thead>
313+
* <tbody valign="top">
314+
* <tr><th></th><td>{@link #VARIANT_NOVALUEPROP}</td><td>Prevents the function from attempting to coerce an object to a fundamental type by getting the Value property. Applications should set this flag only if necessary, because it makes their behavior inconsistent with other applications.</td></tr>
315+
* <tr><th></th><td>{@link #VARIANT_ALPHABOOL}</td><td>Converts a {@link Variant#VT_BOOL VT_BOOL} value to a string containing either "True" or "False".</td></tr>
316+
* <tr><th></th><td>{@link #VARIANT_NOUSEROVERRIDE}</td><td>For conversions to or from {@link Variant#VT_BSTR VT_BSTR}, passes LOCALE_NOUSEROVERRIDE to the core coercion routines.</td></tr>
317+
* <tr><th></th><td>{@link #VARIANT_LOCALBOOL}</td><td>For conversions from {@link Variant#VT_BOOL VT_BOOL} to {@link Variant#VT_BSTR VT_BSTR} and back, uses the language specified by the locale in use on the local computer.</td></tr>
318+
* </tbody>
319+
* </table>
320+
* @param vt The type to convert to. If the return code is {@link WinError#S_OK S_OK}, the vt
321+
* field of the vargDest is guaranteed to be equal to this value.
322+
* @return This function can return one of these values:
323+
* <table>
324+
* <thead>
325+
* <tr><th>Return code</th><th>Description</th></tr>
326+
* </thead>
327+
* <tbody valign="top">
328+
* <tr><td>{@link WinError#S_OK S_OK}</td><td>Success.</td></tr>
329+
* <tr><td>{@link WinError#DISP_E_BADVARTYPE DISP_E_BADVARTYPE}</td><td>The variant type is not a valid type of variant.</td></tr>
330+
* <tr><td>{@link WinError#DISP_E_OVERFLOW DISP_E_OVERFLOW}</td><td>The data pointed to by pvarSrc does not fit in the destination type.</td></tr>
331+
* <tr><td>{@link WinError#DISP_E_TYPEMISMATCH DISP_E_TYPEMISMATCH}</td><td>The argument could not be coerced to the specified type.</td></tr>
332+
* <tr><td>{@link WinError#E_INVALIDARG E_INVALIDARG}</td><td>One of the arguments is not valid.</td></tr>
333+
* <tr><td>{@link WinError#E_OUTOFMEMORY E_OUTOFMEMORY}</td><td>Insufficient memory to complete the operation.</td></tr>
334+
* </tbody>
335+
* </table>
336+
*</p>
337+
* <b>Remarks</b>
338+
*</p>
339+
* The VariantChangeType function handles coercions between the fundamental
340+
* types (including numeric-to-string and string-to-numeric coercions). The
341+
* pvarSrc argument is changed during the conversion process. For example,
342+
* if the source variant is of type {@link Variant#VT_BOOL VT_BOOL} and the
343+
* destination is of type {@link Variant#VT_UINT VT_UINT}, the pvarSrc
344+
* argument is first converted to {@link Variant#VT_I2 VT_I2} and then the
345+
* conversion proceeds. A variant that has {@link Variant#VT_BYREF VT_BYREF}
346+
* set is coerced to a value by obtaining the referenced value. An object is
347+
* coerced to a value by invoking the object's Value property
348+
* ({@link OaIdl#DISPID_VALUE DISPID_VALUE}).
349+
*</p>
350+
* Typically, the implementor of
351+
* {@link com.sun.jna.platform.win32.COM.IDispatch#Invoke IDispatch.Invoke}
352+
* determines which member is being accessed, and then calls
353+
* VariantChangeType to get the value of one or more arguments. For example,
354+
* if the IDispatch call specifies a SetTitle member that takes one string
355+
* argument, the implementor would call VariantChangeType to attempt to
356+
* coerce the argument to {@link Variant#VT_BSTR VT_BSTR}. If
357+
* VariantChangeType does not return an error, the argument could then be
358+
* obtained directly from the
359+
* {@link Variant.VARIANT._VARIANT.__VARIANT#bstrVal bstrVal} field of the
360+
* {@link Variant.VARIANT VARIANT}. If VariantChangeType returns
361+
* {@link WinError#DISP_E_TYPEMISMATCH DISP_E_TYPEMISMATCH}, the implementor
362+
* would set {@link com.sun.jna.platform.win32.COM.IDispatch#Invoke Invoke}
363+
* <code> puArgErr</code> parameter referenced value to 0 (indicating the
364+
* argument in error) and return DISP_E_TYPEMISMATCH from Invoke.
365+
*</p>
366+
* Arrays of one type cannot be converted to arrays of another type with
367+
* this function.
368+
*</p>
369+
* <b>Note</b> The type of a {@link Variant.VARIANT VARIANT} should not be
370+
* changed in the {@link DISPPARAMS#rgvarg rgvarg} array in place.
371+
*/
372+
HRESULT VariantChangeType(VARIANT.ByReference pvargDest, VARIANT.ByReference pvarSrc, short wFlags, VARTYPE vt);
373+
218374
/**
219375
* Creates a new array descriptor, allocates and initializes the data for
220376
* the array, and returns a pointer to the new array descriptor.

0 commit comments

Comments
 (0)