Comparar commits
1 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| 095212a1c4 |
@@ -1,23 +0,0 @@
|
||||
build
|
||||
build-d64
|
||||
build.eclipse
|
||||
build.number
|
||||
build.clover
|
||||
.metadata
|
||||
.DS_Store
|
||||
bin
|
||||
contrib/ntservice/dist
|
||||
contrib/platform/dist
|
||||
doc
|
||||
*~
|
||||
**/*~
|
||||
dist/*.asc
|
||||
dist/*-sources.jar
|
||||
dist/*-javadoc.jar
|
||||
dist/src-mvn.zip
|
||||
dist/out-of-date.jar
|
||||
perf*.txt
|
||||
native/libffi/doc/libffi.info
|
||||
junit-*
|
||||
pom-jna.xml.asc
|
||||
pom-jna-platform.xml.asc
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>jnalib</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
-202
@@ -1,202 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-722
@@ -1,722 +0,0 @@
|
||||
NOTE: as of JNA 4.0, JNA is now dual-licensed under LGPL and ASL (see LICENSE).
|
||||
|
||||
NOTE: JNI native support is typically incompatible between minor versions, and almost always incompatible between major versions.
|
||||
|
||||
Next Release
|
||||
============
|
||||
|
||||
Features
|
||||
--------
|
||||
* Updated AIX natives and build - [@twall](https://github.com/twall).
|
||||
* [#290](https://github.com/twall/jna/pull/290): Improved the stacktrace for the exceptions thrown by `com.sun.jna.Structure` - [@ebourg](https://github.com/ebourg).
|
||||
* [#332](https://github.com/twall/jna/pull/332): Added Win32 Monitor Configuration API in `com.sun.jna.platform.win32.Dxva2` - [@msteiger](https://github.com/msteiger).
|
||||
* Added Winspool monitor sample and updated Kernel32, WinBase, Winspool - [@wolftobias](https://github.com/wolftobias).
|
||||
* Added Some minor changes to MS Office samples Test and small changes to the MS Office samples Bug Fixes - [@wolftobias](https://github.com/wolftobias).
|
||||
* [#333](https://github.com/twall/jna/pull/333): Added `CoTaskMemAlloc`, `CoTaskMemRealloc` and `CoTaskMemFree` to `com.sun.jna.platform.win32.Ole32` - [@msteiger](https://github.com/msteiger).
|
||||
* [#334](https://github.com/twall/jna/pull/334): Added `com.sun.jna.platform.win32.Shell32.SHGetKnownFolderPath` and `KnownFolders` GUID constants - [@msteiger](https://github.com/msteiger).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* [#319](https://github.com/twall/jna/pull/319): Fix direct-mapping type-mapped pointer result types - [@marco2357](https://github.com/marco2357).
|
||||
* Added Variant and TlbImp Fixes - [@wolftobias](https://github.com/wolftobias).
|
||||
|
||||
Release 4.1
|
||||
===========
|
||||
|
||||
Features
|
||||
--------
|
||||
* Added `com.sun.jna.platform.win32.Advapi32Util.registryCloseKey` - [@falldog](https://github.com/falldog).
|
||||
* Enabled platform tests to be run w/o building native bits - [@twall](https://github.com/twall).
|
||||
* Added COM/Typelib java code generator `com.sun.jna.platform.win32.COM.tlb.TlbImp` - [@wolftobias](https://github.com/wolftobias).
|
||||
* [#226](https://github.com/twall/jna/issues/226): Added OSGI information to jna-platform.jar - [@brettwooldridge](https://github.com/brettwooldridge).
|
||||
* [#267](https://github.com/twall/jna/pull/267): Added support for Windows RAS32 API, `com.sun.jna.platform.win32.Rasapi32` and `Rasapi32Util` - [@kc7bfi](https://github.com/kc7bfi).
|
||||
* [#101](https://github.com/twall/jna/issues/101): Modify `com.sun.jna.platform.win32.Advapi32Util.registryGet*` API to support `KEY_WOW64` option - [@falldog](https://github.com/falldog).
|
||||
* [#271](https://github.com/twall/jna/pull/271): Added `com.sun.jna.platform.win32.Gdi32.ChoosePixelFormat` and `SetPixelFormat` - [@kc7bfi](https://github.com/kc7bfi).
|
||||
* [#271](https://github.com/twall/jna/pull/271): Added `com.sun.jna.platform.win32.OpenGL32`, `OpenGL32Util` and `WinOpenGL` - [@kc7bfi](https://github.com/kc7bfi).
|
||||
* [#250](https://github.com/twall/jna/pull/250): Added `com.sun.jna.platform.win32.Kernel32.GetPrivateProfileSection`, `GetPrivateProfileSectionNames` and `WritePrivateProfileSection` and corresponding `Kernel32Util` helpers - [@quipsy-karg](https://github.com/quipsy-karg).
|
||||
* [#287](https://github.com/twall/jna/pull/287): Added `DBTF_MEDIA` and `DBTF_NET` to `com.sun.jna.platform.win32.DBT` - [@daifei4321](https://github.com/daifei4321).
|
||||
* [#295](https://github.com/twall/jna/pull/295): Added `com.sun.jna.platform.win32.Kernel32.ResetEvent` - [@manithree](https://github.com/manithree).
|
||||
* [#301](https://github.com/twall/jna/pull/301): Added `accessCheck` to `com.sun.jna.platform.win32.Advapi32Util`, `MapGenericMask` and `AccessCheck` to `com.sun.jna.platform.win32.Advapi32`, `PRIVILEGE_SET` and `GENERIC_MAPPING` to `com.sun.jna.platform.win32.WinNT` - [@BusyByte](https://github.com/BusyByte).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* Fixed inconsistent behavior on `Structure.ByValue` fields within a `Structure` - [@twall](https://github.com/twall).
|
||||
* [#279](https://github.com/twall/jna/issues/279): Accommodate FreeBSD libc loading - [@sevan](https://github.com/sevan).
|
||||
* [#287](https://github.com/twall/jna/pull/287): Fixed contrib `win32.Win32WindowDemo`, now showing the added/removed drive letter, and whether the event is about media in drive or physical drive - [@daifei4321](https://github.com/daifei4321).
|
||||
* [#300](https://github.com/twall/jna/issues/300): Fix stdcall argument alignment - [@twall](https://github.com/twall).
|
||||
|
||||
Release 4.0
|
||||
===========
|
||||
|
||||
Features
|
||||
--------
|
||||
* Added ASL licensing to facilitate distribution - [@twall](https://github.com/twall).
|
||||
* [#109](https://github.com/twall/jna/issues/109): Set default Java compatibility level to 1.6 - [@twall](https://github.com/twall).
|
||||
* [#209](https://github.com/twall/jna/issues/209): Improved default performance saving last error results - [@twall](https://github.com/twall).
|
||||
* Use predictable names for CPU architecture prefix (namely x86, x86-64); names correspond to OSGI processor values - [@twall](https://github.com/twall).
|
||||
* Avoid superfluous Structure memory allocation from native - [@twall](https://github.com/twall).
|
||||
* Added `Library.OPTION_CLASSLOADER`, which enables loading native libraries from any class loader (including JNA's native library). This enables parallel dependencies on JNA (e.g. within a tomcat deployment without having to include JNA in the app server environment) - [@twall](https://github.com/twall).
|
||||
* Use per-library String encoding settings (see `Native.getDefaultStringEncoding()` and `Structure.getStringEncoding()`) - [@twall](https://github.com/twall).
|
||||
* Added memory dump for debugging (see `com.sun.jna.Memory`) - [@twall](https://github.com/twall).
|
||||
* Improved caching of Structure alignment, type mapping, and encoding information - [@twall](https://github.com/twall).
|
||||
* [#225](https://github.com/twall/jna/pull/225): Added `platform.win32.Kernel32.GetLogicalProcessorInformation` and `platform.win32.Kernel32Util.getLogicalProcessorInformation` - [@trejkaz](https://github.com/trejkaz).
|
||||
* [#236](https://github.com/twall/jna/issues/236): Auto-strip profiler native method prefix specified by `jna.profiler.prefix`, which defaults to $$YJP$$ - [@twall](https://github.com/twall).
|
||||
* Added `jna.debug_load` property to diagnose library loading issues - [@twall](https://github.com/twall).
|
||||
* Throw explicit `IllegalArgumentException` when `Structure.ByReference` is used where it shouldn't be (can result in multiply freed memory or other unexpected behavior) - [@twall](https://github.com/twall).
|
||||
* [#243](https://github.com/twall/jna/issues/243): Automatically accommodate long library paths on Windows which would otherwise fail - [@twall](https://github.com/twall).
|
||||
* [#241](https://github.com/twall/jna/issues/241) - Added `com.sun.jna.platform.win32.Shell32.SHAppBarMessage` - [@bsorrentino](https://github.com/bsorrentino).
|
||||
* Make `Structure.read/writeField()` protected to facilitate per-field overrides - [@twall](https://github.com/twall).
|
||||
* Speed up callback lookup where large numbers of native function pointers are in use - [@twall](https://github.com/twall).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* [#213](https://github.com/twall/jna/pull/213): Fixed `Structure.toString()` not to dump memory when `jna.dump_memory` is false - [@tomohiron](https://github.com/tomohiron).
|
||||
* Use dedicated TLS to indicate callback detach state, to avoid any potential conflicts with last error storage - [@twall](https://github.com/twall).
|
||||
* [#173](https://github.com/twall/jna/issues/173): Fixed OSX 10.8/Xcode 4+ builds, web start path with Oracle 1.7 JDK - [@mkjellman](https://github.com/mkjellman).
|
||||
* [#215](https://github.com/twall/jna/issues/215): Forced use of XSI `strerror_r` on linux - [LionelCons](https://github.com/LionelCons).
|
||||
* [#214](https://github.com/twall/jna/issues/214): Don't map library names when an absolute path is provided - [@twall](https://github.com/twall).
|
||||
* [#218](https://github.com/twall/jna/issues/218): Explicitly handled broken Android `SecurityManager` implementation - [@twall](https://github.com/twall).
|
||||
* [#223](https://github.com/twall/jna/issues/223): Fixed layout/size derivation for unions - [@twall](https://github.com/twall).
|
||||
* [#229](https://github.com/twall/jna/issues/229): Added `CreateProcessW` (Unicode version) - [@twall](https://github.com/twall).
|
||||
* Avoid solaris/x86 JVM bug w/library open flags - [@twall](https://github.com/twall).
|
||||
* Fixed NPE returning wide string from a direct-mapped function - [@twall](https://github.com/twall).
|
||||
* [#237](https://github.com/twall/jna/issues/237): Fix LastErrorException/getLastError on AIX - [@skissane](https://github.com/skissane).
|
||||
* [#228](https://github.com/twall/jna/issues/228): Fix win32/win64 crashes due to LastErrorException buffer overruns (`snprintf` on windows is broken) - [@davidhoyt](https://github.com/davidhoyt).
|
||||
|
||||
Release 3.5.2
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
* Basic [COM support](https://github.com/twall/jna/blob/master/www/PlatformLibrary.md) for w32 - [@wolftobias](https://github.com/wolftobias).
|
||||
* Avoid superfluous Structure memory allocation by using Structure(Pointer) ctors if available - [@twall](https://github.com/twall).
|
||||
* [PR#120](https://github.com/twall/jna/pull/120): Provide methods for extracting native libraries from the class path for use by JNA - [@Zlika](https://github.com/Zlika).
|
||||
* [PR#163](https://github.com/twall/jna/pull/163): The Java `GUID` structure can be used directly as alternative to `Ole32Util.getGUIDFromString()` - [@wolftobias](https://github.com/wolftobias).
|
||||
* [PR#163](https://github.com/twall/jna/pull/163): Ported Win32 `dbt.h` - [@wolftobias](https://github.com/wolftobias).
|
||||
* [PR#163](https://github.com/twall/jna/pull/163): Added Win32 `WTSRegisterSessionNotification()` and `WTSUnRegisterSessionNotification()` from `Wtsapi32.dll` - [@wolftobias](https://github.com/wolftobias).
|
||||
* [PR#163](https://github.com/twall/jna/pull/163): Added Win32 `native_window_msg` that creates windows, registers for USB device and logon/logoff notifications - [@wolftobias](https://github.com/wolftobias).
|
||||
* [PR#178](https://github.com/twall/jna/pull/178): Added Win32 `USER_INFO_10` structure from `LMAccess.h` - [@davidmc24](https://github.com/davidmc24).
|
||||
* [PR#192](https://github.com/twall/jna/pull/192): Added Win32 `SHGetSpecialFolderPath()` and initialization file (.ini) API functions from `kernel32.dll` - [@headcrashing](https://github.com/headcrashing).
|
||||
* [PR#194](https://github.com/twall/jna/pull/194): Added Unit Test for `CLSIDFromProgID()` - [@headcrashing](https://github.com/headcrashing).
|
||||
* [PR#196](https://github.com/twall/jna/pull/196): Added Win32 `RegisterWindowMessage()` and new wrapper `User32Util` for convenient use of `RegisterWindowMessage`, `CreateWindow` and `CreateWindowEx` - [@headcrashing](https://github.com/headcrashing).
|
||||
* [PR#187](https://github.com/twall/jna/pull/187): Allow StructureFieldOrderTest unit test in platform project to run on Linux. - [@bhamail](https://github.com/bhamail).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* [PR#180](https://github.com/twall/jna/pull/180): Fix: added missing fields in `XEvents.getFieldOrder()` - [@xwizard](https://github.com/xwizard).
|
||||
* [PR#183](https://github.com/twall/jna/pull/183): Fix `LMAccess.GROUP_INFO_3.getFieldOrder()` to return correct fields names - [@bhamail](https://github.com/bhamail).
|
||||
* [PR#187](https://github.com/twall/jna/pull/187): Fix `getFieldOrder()` to return correct field names for some X11 structures - [@bhamail](https://github.com/bhamail).
|
||||
* Remove deprecated methods on Memory (getSize,isValid) and Structure (getSize) - [@twall](https://github.com/twall).
|
||||
* Remove problematic AWT check via `Class.forName("java.awt.Component")` (see [here](https://bugs.eclipse.org/bugs/show_bug.cgi?id=388170)) - [@twall](https://github.com/twall).
|
||||
* [PR#210](https://github.com/twall/jna/pull/210) Add OSGI processor specs for Mac OS X - [@bertfrees](https://github.com/bertfrees).
|
||||
* [PR#174](https://github.com/twall/jna/pull/174): Recompile linux-amd64 natives to remove glibc-2.11 dependencies, now requires only 2.2.5 or better - [@twall](https://github.com/twall).
|
||||
* [PR#183](https://github.com/twall/jna/pull/183): Added `StructureFieldOrderInspector` unit test utility to scan for `Structure` field issues; see: `com.sun.jna.platform.StructureFieldOrderTest.testMethodGetFieldOrder` - [@bhamail](https://github.com/bhamail).
|
||||
* [PR#187](https://github.com/twall/jna/pull/187): Allow `StructureFieldOrderTest` unit test in platform project to run on Linux - [@bhamail](https://github.com/bhamail).
|
||||
* [#206](https://github.com/twall/jna/issues/206): Fix `moveToTrash()` on OSX to work with symlinks - [@twall](https://github.com/twall).
|
||||
* Fix NPE if `Thread.getContextClassLoader()` returns `null` - [@twall](https://github.com/twall).
|
||||
|
||||
Release 3.5.1
|
||||
=============
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* Fix bug where string fields sometimes failed to be writtern - [@twall](https://github.com/twall) (roman kisluhin).
|
||||
* [PR#145](https://github.com/twall/jna/pull/145): Fix `Netapi32Util.getDomainTrusts()` returns "empty" domain object - [@aikidojohn](https://github.com/aikidojohn).
|
||||
* [PR#145](https://github.com/twall/jna/pull/145): Fix `Netapi32.getDC()` - added missing fields in `DOMAIN_CONTROLLER_INFO` - [@aikidojohn](https://github.com/aikidojohn).
|
||||
* [PR#151](https://github.com/twall/jna/pull/151): 'platform.jar' in the dist directory was not updated for release 3.5.0. (The 'platform.jar' published to maven central was correct.)
|
||||
|
||||
Release 3.5.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
* [#62](https://github.com/twall/jna/issues/62) If a callback is required to reside in a DLL, use [`DLLCallback`](http://twall.github.com/jna/3.5.1/javadoc/com/sun/jna/win32/DLLCallback.html) to tag your Callback object - [@twall](https://github.com/twall).
|
||||
* `Structure.getFieldOrder()` supersedes `Structure.setFieldOrder()` and is now required - [@twall](https://github.com/twall).
|
||||
* Search `~/Library/Frameworks` and `/Library/Frameworks` on OSX - [@shaneholloway](https://github.com/shaneholloway).
|
||||
* Automatic cleanup of native threads (based on suggestions from neil smith) - [@twall](https://github.com/twall).
|
||||
* Add `android-arm` target - [@ochafik](https://github.com/ochafik), [@twall](https://github.com/twall).
|
||||
* Add `jna.tmpdir` to override temporary JNA storage location - [@twall](https://github.com/twall).
|
||||
* Add `EXTRA_MAKE_OPTS` ant property to override make variables - [@twall](https://github.com/twall).
|
||||
* Add `Library.OPTION_OPEN_FLAGS` to customize dlopen behavior - [@twall](https://github.com/twall).
|
||||
* [#113](https://github.com/twall/jna/issues/113), [#114](https://github.com/twall/jna/issues/114): Add support for GNU/kFreeBSD and debian multi-arch distros - [@twall](https://github.com/twall).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* Fix `Advapi32Util.registryGetValues()` tried to allocate memory for a zero-length `REG_BINARY` value - [@phailwhale22](https://github.com/phailwhale22).
|
||||
* Fix crash in direct mode callbacks with certain type conversions - [@twall](https://github.com/twall).
|
||||
* More thoroughly propagate unexpected exceptions generated in jnidispatch - [@twall](https://github.com/twall).
|
||||
* Cleanup maven poms and publishing to central repo - [@bhamail](https://github.com/bhamail).
|
||||
* [#129](https://github.com/twall/jna/issues/129): Allow `Memory` field in structure - [@twall](https://github.com/twall).
|
||||
* Preserve `PointerType` fields on `Structure.read()` if unchanged - [@twall](https://github.com/twall).
|
||||
* [#128](https://github.com/twall/jna/issues/128): Fix masking extracting DWORD upper and lower WORD values - [@twall](https://github.com/twall).
|
||||
* [#135](https://github.com/twall/jna/issues/135): Fix for `Advapi32Util.registryGetValues()` when reading zero length values - [@danwi](https://github.com/danwi).
|
||||
|
||||
Release 3.4.2
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
* Add `platform.win32.Kernel32.GetEnvironmentVariable` and `platform.win32.Kernel32Util.getEnvironmentVariable` - [@dblock](https://github.com/dblock).
|
||||
* Moved `Kernel32.dll` function definitions from `WinNT.java` into `Kernel32.java` - [@dblock](https://github.com/dblock).
|
||||
* Provide `toPointer()` methods on all `_PTR` types (platform win32) - [@twall](https://github.com/twall).
|
||||
* Provide `ant -Dskip-native` to skip platform native build - [@twall](https://github.com/twall).
|
||||
* Provide `ant -Dheadless=true` to run unit tests headless - [@twall](https://github.com/twall).
|
||||
* Added Windows dev environment instructions - [@twall](https://github.com/twall).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* Ensure platform win32 classes use unsigned where appropriate (`ULONG_PTR`, `UINT_PTR`, `ULONGLONG`, `WORD`, `DWORDLONG`) - [@twall](https://github.com/twall).
|
||||
* [#71](https://github.com/twall/jna/issues/71), [#73](https://github.com/twall/jna/issues/73): Fix OSGI entries in manifest - [@twall](https://github.com/twall).
|
||||
* [#78](https://github.com/twall/jna/issues/78): Fix NPE in `platform.win32.Netapi32Util.getDomainTrusts` - [@dblock](https://github.com/dblock).
|
||||
* Fix: auto-sync memory for `struct**` arguments (array of struct pointers) - [@twall](https://github.com/twall).
|
||||
* Fix: `platform.win32.Secur32.AcquireCredentialsHandle`, `InitializeSecurityContext` and `AcceptSecurityContext` on Win32 64-bit - [@dblock](https://github.com/dblock).
|
||||
* Fix: avoid overwriting native `char *` or `wchar_t *` fields within structures when unmodified (similar to current operation with pointers) - [@twall](https://github.com/twall).
|
||||
* Fix: `platform.win32.DsGetDC.DS_DOMAIN_TRUSTS` and `DsEnumerateDomainTrusts` on Win32 64-bit - [@trejkaz](https://github.com/trejkaz).
|
||||
* Fix: Crash freeing the wrong pointer in `Netapi32Util.getDomainTrusts` - [@trejkaz](https://github.com/trejkaz).
|
||||
* [#100](https://github.com/twall/jna/issues/100): Fix `platform.win32.W32FileMonitor` - [@dblock](https://github.com/dblock).
|
||||
* Return INT_PTR from `platform.win32.Shell32.ShellExecute`, since returning
|
||||
`HINSTANCE` is useless.
|
||||
* Fix runtime error in some instances where Structure.setFieldOrder is used (never return self when sharing AutoAllocated memory).
|
||||
* [#107](https://github.com/twall/jna/issues/107): `Structure.clear()` always calls `ensureAllocated()` to avoid NPE.
|
||||
* Ensure internal memory pointer is *always* allocated when calling `Structure.useMemory()`, even if layout is not yet determined.
|
||||
|
||||
Release 3.4.1
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
* Add 'unsigned' modifier to IntegerType.
|
||||
* Add to `platform.win32.User32`: `GetLastInputInfo`.
|
||||
* Add `platform.win32.WinNT.GetFileType` and `platform.win32.Kernel32Util.getFileType`.
|
||||
* Add to `platform.win32.Kernel32Util`: `getFileType`.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* Re-build linux-amd and linux-i386 against older versions of glibc (2.2.5 and
|
||||
2.1.3 respectively).
|
||||
* Properly initialize first printer info struct in winspool library.
|
||||
* Properly support getting and setting zero-array-length `REG_MULTI_SZ` values on Win32.
|
||||
* Fixed SID in Win32 `USER_INFO_23` and `GROUP_INFO_3`.
|
||||
* Fixed passing domain name into Win32 `Netapi32Util.getUserInfo`.
|
||||
|
||||
Release 3.4.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
* Provide `jna.nosys=true` to avoid loading any system-provided JNA (useful for local build/development).
|
||||
* Allow override of default jnidispatch library name with `jna.boot.library.name` system property.
|
||||
* Throw an Error if a system install of JNA is incompatible or if JNA's JNI library does not match.
|
||||
* Disable automatic jnidispatch unpacking with `jna.nounpack=true`.
|
||||
* Automatically look up system error messages for LastErrorException.
|
||||
* Improved callback thread-mapping support; re-use, rename, and group callback
|
||||
threads.
|
||||
* Cache structure layout results, improving performance of structure creation.
|
||||
* linux/arm 32-bit support (hardware provided by Alex Lam).
|
||||
* linux/ppc 32-bit support (hardware provided by Fritiof Hedman).
|
||||
* Preliminary linux/ia64, linux/ppc64 support (thanks to Laurent Guerby and the GCC compile farm).
|
||||
* Windows CE/Mobile support (w32ce-arm) (resources provided by andrea antonello and Hydrologis SRL).
|
||||
* linux multi-arch support (kohsuke).
|
||||
* Added REG_QWORD registry type support
|
||||
* Add to `platform.unix.x11`: `XGrabKey`, `XUngrabKey`, `XSetErrorHandler`.
|
||||
* Add to `platform.mac.Carbon`: `GetEventDispatcherTarget`, `InstallEventHandler`, `RegisterEventHotKey`, `GetEventParameter`, `RemoveEventHandler`, `UnregisterEventHotKey`.
|
||||
* Add to `platform.win32.Kernel32`: `CopyFile`, `MoveFile`, `MoveFileEx`, `CreateProcess`, `SetEnvironmentVariables`, `GetFileTime`, `SetFileTime`, `SetFileAttributes`, `DeviceIoControl`, `GetDiskFreeSpaceEx`, `CreateToolhelp32Snapshot`, `Process32First`, `Process32Next`.
|
||||
* Add to `platform.win32.Msi`: `MsiGetComponentPath`, `MsiLocateComponent`, `MsiGetProductCode`, `MsiEnumComponents`.
|
||||
* Add to `platform.win32.User32`: `RegisterHotKey`, `UnregisterHotKey`
|
||||
* Add to `platform.win32.SetupApi`: `SetupDiGetClassDevs`, `SetupDiDestroyDeviceInfoList`, `SetupDiEnumDeviceInterfaces`, `SetupDiGetDeviceInterfaceDetail`, `SetupDiGetDeviceRegistryProperty`.
|
||||
* Add `platform.win32.Shell32.ShellExecute`.
|
||||
* Add to `platform.win32.User32`: `SetParent`, `IsWindowVisible`, `MoveWindow`, `SetWindowPos`, `AttachInputThread`, `SetForegroundWindow`, `GetForegroundWindow`, `SetFocus`, `SendInput`, `WaitForInputIdle`, `InvalidateRect`, `RedrawWindow`, `GetWindow`, `UpdateWindow`, `ShowWindow`, `CloseWindow`.
|
||||
* Add to `platform.win32.Version`: `GetFileVersionInfoSize`, `GetFileVersionInfo`, `VerQueryValue`.
|
||||
* Add to `platform.win32.Advapi32`: `GetFileSecurity`, `RegQueryValueEx(...Long...)`.
|
||||
* Add to `platform.win32.Netapi32`: `NetUserGetInfo`.
|
||||
|
||||
Bug Fixes
|
||||
--------
|
||||
* Revise cleanup of in-use temporary files on win32 (issue 6).
|
||||
* Fix structure alignment issues on linux/ppc.
|
||||
* Fix structure alignment issues on linux/arm.
|
||||
* Account for NIO Buffer position (JIRA issue 185).
|
||||
* Avoid crash with very long Strings (> 150k in length).
|
||||
* Fix bug tracking Memory with an associated direct ByteBuffer.
|
||||
* Fix bug handling structs by value when type mappers are in effect (JIRA issue 188).
|
||||
|
||||
Release 3.3.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Facilitate `Memory` subclasses (jbellis).
|
||||
* Allow multiple fields of the same type in Unions (Francis Barber).
|
||||
* Add `platform.win32.Advapi32.AdjustTokenPrivileges`, `platform.win32.Advapi32.LookupPrivilegeName`, `platform.win32.Advapi32.LookupPrivilegeValue`, `platform.win32.Advapi32.ImpersonateSelf`.
|
||||
* Add `platform.win32.Advapi32.DuplicateTokenEx`, `platform.win32.Advapi32.CreateProcessAsUser`, `platform.win32.Kernel32.GetExitCodeProcess`, `platform.win32.Kernel32.TerminateProcess`, `platform.win32.Kernel32.ReadFile`, `platform.win32.Kernel32.CreatePipe`, `platform.win32.Kernel32.SetHandleInformation` and related constants / structures in `platform.win32.WinBase` and `platform.win32.WinNT`. Please note that the `SECURITY_ATTRIBUTES` structure has been moved from `platform.win32.WinNT` to `platform.win32.WinBase`.
|
||||
* Add `platform.win32.Kernel32.DeleteFile` and `platform.win32.Kernel32Util.deleteFile`.
|
||||
* Add `platform.win32.Kernel32.GetFileAttributes` and `platform.win32.Kernel32Util.getFileAttributes`.
|
||||
* Add `platform.win32.Kernel32.GetTickCount`.
|
||||
* Add Win32 Service functions to `platform.win32.Advapi32`.
|
||||
* Add `platform.win32.W32ServiceManager` and `W32Service`.
|
||||
* Add Win32 Event Logging functions to `platform.win32.Advapi32` and `platform.win32.Advapi32Util.EventLogIterator`.
|
||||
* `platform.win32.Advapi32Util.registryCreateKey` returns `true` if key was created, `false` if it already exists.
|
||||
* Add `REG_BINARY`, `REG_EXPAND_SZ` and `REG_MULTI_SZ` support to `platform.win32.Advapi32Util` registry functions.
|
||||
* Reduce JNI crossings in a number of native methods, moving object creation out into pure Java code.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Move all native functions into `com.sun.jna.Native`, to ensure that all dependent classes must be disposed before the `Native` class is unloaded. Note that this change is incompatible with all previous JNA native libraries.
|
||||
* Fix `platform.win32.Kernel32.GetNativeSystemInfo` and `GetSystemInfo` AV on Win64.
|
||||
* Fix several potential minor bugs as reported by TvT.
|
||||
* Fix bug in Structure.StructureSet.toString (Blair Zajac), exposed by Tomcat ThreadLocal cleanup.
|
||||
* Fix several bugs when using Structure(Pointer) ctor and array fields (Samuel Audet).
|
||||
|
||||
Release 3.2.7
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Add native peer value accessors for Pointer
|
||||
* The `jna.library.path` property is now re-evaluated whenever a native library is loaded. Previously this value was cached when the JNA classes loaded.
|
||||
* `Native.loadLibrary` can now load `.drv` files.
|
||||
* Refactor `com.sun.jna.platform.win32.WINBASE` into `WinDef`, `WinNT` and `BaseTSD`, matching Windows SDK headers.
|
||||
* Refactor constants from `com.sun.jna.platform.win32.GDI32` into `WinGDI`, matching Windows SDK headers.
|
||||
* Refactor constants from `com.sun.jna.platform.win32.User32` into `WinUser`, matching Windows SDK headers.
|
||||
* Refactor `platform.win32.WinNT.LARGE_INTEGER` into a union.
|
||||
* Add `platform.win32.ObjBase`, `com.sun.jna.platform.win32.Ole32.CoInitializeEx`, `CoUninitialize`, and `CoCreateInstance`.
|
||||
* Add `platform.win32.Oleaut32.SysAllocString` and `SysFreeString`.
|
||||
* Add `platform.win32.Secur32.ImpersonateSecurityContext` and `RevertSecurityContext`.
|
||||
* Add `platform.win32.WinNT.WELL_KNOWN_SID_TYPE`, `SECURITY_MAX_SID_SIZE` and other related SID-related constants.
|
||||
* Add `platform.win32.Advapi32.CreateWellKnownSid` and `IsWellKnownSid` and `com.sun.jna.platform.win32.Advapi32Util.isWellKnownSid`.
|
||||
* Add `platform.win32.Kernel32.GetVersion`, `GetVersionEx`, `GetSystemInfo`, `GetNativeSystemInfo`, `GlobalMemoryStatusEx`, `GetLogicalDriveStrings` and `IsWow64Process`.
|
||||
* Add `platform.win32.Kernel32Util.getLogicalDriveStrings`.
|
||||
* Add `platform.win32.User32.GetSystemMetrics`.
|
||||
* Add `platform.win32.BaseTSD.DWORD_PTR`.
|
||||
* Add `platform.win32.WinBase.SYSTEM_INFO` and `MEMORYSTATUSEX`.
|
||||
* Add `platform.win32.WinNT.OSVERSIONINFOEX`, `VER` constants.
|
||||
* Add `platform.win32.WinDef.ULONGLONG` and `DWORDLONG`.
|
||||
* Add `platform.win32.Shell32.SHGetDesktopFolder` (prep work for Com4JNA).
|
||||
* Add `platform.win32.Winspool.GetPrinterInfo`.
|
||||
* Add `platform.win32.WinspoolUtil.getPrinterInfo1`.
|
||||
* Add `platform.win32.GDI32.GetDeviceCaps`.
|
||||
* Add `platform.win32.GDI32.GetDIBits`.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix `ClassCastException` in `Structure.equals` (issue 152).
|
||||
* Fix bug initializing a structure object from existing memory when the structure has initialized fields (issue 133).
|
||||
* Fix NPE reading an array of string from a pointer when an element of the array is `NULL` (issue 151).
|
||||
* Avoid calling `UnregisterNatives` in native code (issue 154).
|
||||
* Compare unpacked library path against canonical (long) filename (issue 156).
|
||||
* Fix `read()` of uninitialized memory in `platform.win32.Advapi32Util.getTokenGroups` and `getTokenAccount`.
|
||||
* Fix `com.sun.jna.platform.win32.Secur32.QuerySecurityContextToken` to take a `CtxtHandle` instead of `PSecHandle`.
|
||||
* Fix definition of BITMAPINFO (platform/win32).
|
||||
|
||||
Release 3.2.5
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Split code in examples.jar into a contrib platform.jar package and individual packages for demos.
|
||||
* Fix Eclipse build and added Eclipse projects for all contrib samples, import projects from jnalib and contrib.
|
||||
* Ensure Structure fields correctly ordered when inherited.
|
||||
* Use explicit Structure field whenever provided, regardless of whether the VM requires it.
|
||||
* Add Win32 mappings for two dozen functions from Kernel32.dll, Advapi32.dll, Netapi32.dll, Secur32.dll, NtDll.dll, Ole32.dll, Shell32.dll and Crypt32.dll to com.sun.jna.platform.win32.
|
||||
* Port parts of WinError.h, WinNT.h, LMAccess.h, LMCons.h, LMErr.h, LMJoin.h, NTStatus.h, ShlObj.h, WinDef.h, ShellApi.h, Wdm.h, WinReg.h, WinCrypt.h, Sspi.h, Guid.h, NtSecApi.h and DsGetDc.h.
|
||||
* Add Win32 simplified utility interfaces Kernel32Util, Advapi32Util, Netapi32Util, Crypt32Util, NtDllUtil, Shell32Util, Ole32Util and Secur32Util to com.sun.jna.platform.win32.
|
||||
* Support unicode paths in W32FileUtils.
|
||||
* Fix exception during dispose in W32FileMonitor.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Provide String.replace for 1.4 compatibility.
|
||||
* Avoid allocating memory when Structure is provided a pointer in the ctor.
|
||||
* Ensure proper value returned in Pointer.getValue() for non-null, unchanged NIO Buffer values.
|
||||
* Use 1.4-compatible URI generation (issue 149).
|
||||
|
||||
Release 3.2.4
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Make Pointer ctor public.
|
||||
* Provide access to Function objects for arbitrary Pointer values.
|
||||
* Add linux/ia64 binaries (bpiwowar). See issue 134 patch.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Use a more robust method to decode a file-based URL (issue 135).
|
||||
|
||||
Release 3.2.3
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Include version information in code in case package information lost.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix WindowUtils exception on mouse over TrayIcon.
|
||||
* Fix bug toggling windows transparent/opaque (win32/OSX).
|
||||
* Avoid overwriting unchanged Pointer values in arrays (function calls with Pointer[] and Structure.read).
|
||||
* Ensure Structure fields marked `final` are never written.
|
||||
* Fix bug preventing proper population Structure.ByReference fields on Structure read.
|
||||
* Ensure double buffering is disabled in components added to a transparent window.
|
||||
* Fix UnsatisfiedLinkError attempting to load system libraries under Web Start.
|
||||
* Fix loading Web Start-provided libraries on OSX (libraries must have a .jnilib suffix under Web Start).
|
||||
* Properly include sources in Maven zip file (Issue 129).
|
||||
|
||||
Release 3.2.2
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Provide length-specified Pointer.getStringArray()
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix crash with direct mapping if NULL struct* used (Issue 125).
|
||||
* Fix case where null-valued Structure fields would get non-null values on write.
|
||||
* Synch callback Structure/Structure[] arguments on callback return.
|
||||
* Fix NPE when mapping an interface to the current process.
|
||||
* Automatically load proper C library version from current process on Linux (avoids crashing bug on Ubuntu with libc-i686 packages active).
|
||||
* Avoid scanning structure contents in Structure.toString if contents aren't actually used.
|
||||
|
||||
Release 3.2.1
|
||||
==========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Add HRESULT, LONG mapping to W32API (marc strapetz).
|
||||
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix definition of HWND_BROADCAST in W32API.
|
||||
* Fix memory alignment checking (Issue 121).
|
||||
* Fix Structure equals/hashCode implementation, based on current Java fields rather than strictly native memory contents. Avoid using equals/hashCode when avoiding recursive reads/writes.
|
||||
|
||||
Release 3.2.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Handle String, Structure, Callback, Buffer, and primitive arrays in direct mappings. Handle NativeMapped and TypeMapper, with optimized paths for IntegerType and PointerType.
|
||||
* Optionally throw errno/GetLastError as an exception. This is preferred to (and more efficient than) calling Native.getLastError().
|
||||
* Unload/delete native library unpacked from jna.jar if Native class is garbage collected. Only install shutdown hook if using the system class loader.
|
||||
* Auto-write contiguous Structure arrays when first element is written.
|
||||
* Support NativeMapped[] as function arguments for interface-mapped libraries (Issue 90).
|
||||
* Enable function lookup within current process on Windows.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Restrict recursive structure reads/writes by thread instead of globally. This avoids potentially missed reads/writes with concurrent access (Issue 120).
|
||||
* Ensure Memory is not GC'd and freed if direct NIO buffers mapped to it are extant.
|
||||
* Allow types derived from java.nio.Buffer as Structure fields.
|
||||
|
||||
Release 3.1.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Add raw JNI mapping of static Java methods. Performance is about 10X that of traditional JNA interface mapping, although with less type conversion functionality.
|
||||
* Add library option to allow passing/return of Java Objects.
|
||||
* Allow handling of uncaught callback exceptions (Issue 63).
|
||||
* Object oriented interface to X server (see contrib/x11)
|
||||
* Make Memory class more accessible.
|
||||
* Provide Structure ctor with Pointer argument (issue 102).
|
||||
* Allow implicit library access to current process on linux (issue 98).
|
||||
* Open all shared libraries with RTLD_GLOBAL, if applicable. This was the default behavior on OSX and changes the default behavior on linux.
|
||||
* Allow NIO Buffer as Structure field (with limitations) (Issue 57)
|
||||
* Add `size_t` size.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Run tests with libjsig.so, if available, which fixes some crashes when running tests on 64-bit platforms.
|
||||
* Fix Issue 104.
|
||||
* Fix Issue 94 (Java 1.6 update 10 regression).
|
||||
* Fix Issue 51 (Java 1.6 update 10 regression).
|
||||
* Fix Issue 95.
|
||||
* Fix Issue 101.
|
||||
* Fix Issue 111, memory leak with String-returning Callback.
|
||||
* Fix missing storage of union type information (affects usage of struct/union by value as argument and return type).
|
||||
* Remove non-functional Structure ctors requiring explicit size.
|
||||
|
||||
Release 3.0.9
|
||||
=============
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix issue 93 by only manually searching jna.library.path, then falling back to passing the mapped library name to dlopen/LoadLibrary. This fixes an issue in JRUBY where the incorrect libc.so.6 was being loaded.
|
||||
|
||||
Release 3.0.8
|
||||
==========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Auto-map Pointer[]/String[]/WString[] return values.
|
||||
* Provide utility functions to convert String to primitive array.
|
||||
* Add jna.library.boot.path property to define the directory that the native stub library is loaded from
|
||||
|
||||
Release 3.0.7
|
||||
==========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Improve Win32 loading of libraries with dependencies.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix bug reading structures with PointerType fields, introduced with Pointer field preservation fix.
|
||||
|
||||
Release 3.0.6
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Allow arbitrary callback method names if only one method is defined in the class which implements Callback (colinwalters).
|
||||
* Allow specification of callback type mappers by using a TYPE_MAPPER field (colinwalters).
|
||||
* Allow uninitialized (null-valued) boxed primitives in Structures (colinwalters).
|
||||
* Add convenience methods to set active Union field and value simultaneously (xylo).
|
||||
* Augment Union read/writeField to set the active field.
|
||||
* Allow Structure auto-synch across native calls to be disabled.
|
||||
* Win64 support.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Avoid overwriting unchanged Structure fields of type Pointer.
|
||||
* Avoid more content dragging on OSX or warn if it's too late.
|
||||
* Fix UnsatisfiedLinkError using transparent window on Win2K.
|
||||
* Fix memory leak with callbacks called from native threads with no Java context (johnwallace).
|
||||
* Defer structure size calculation if type mapper not yet set, allowing type mapper to be set in derived constructors (colinwalters).
|
||||
* Ensure structure memory is allocated in Structure.read/writeField.
|
||||
|
||||
Release 3.0.5
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Allow explicit declaration of field order for VMs which have an unpredictable field order.
|
||||
* Check for w32 libraries with a "lib" prefix in addition to normal lookup.
|
||||
* Allow String[]/WString[] as callback argument/return value (assume NULL-terminated array).
|
||||
* Add Solaris8 compatibility to sunos-sparc build (Corey Puffalt).
|
||||
* Look up libraries using web start library path, if appropriate (Corey Puffalt).
|
||||
* Use constants to return integer boolean values.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Properly track cursor on alpha-masked windows.
|
||||
* Avoid searching /lib or /usr/lib on 64-bit Linux.
|
||||
* Avoid using incorrect version of a library when both 32- and 64-bit versions are found.
|
||||
* Avoid transparent window events always dragging window bug on OSX.
|
||||
* Fix division by zero error calculating structure size on OSX/ppc.
|
||||
* Avoid overwriting initialized NativeMapped Structure fields when calculating structure size.
|
||||
* Fix NPE reading back into StringArray.
|
||||
|
||||
Release 3.0.4
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Automatically write contents of Structure.ByReference fields on Structure.write().
|
||||
* Use the actual parameter type in Function invocations if no parameter type information is available (whether method is missing or untyped varargs).
|
||||
* Augmented X11 library mappings (xylo).
|
||||
* Support read/write of NativeMapped arrays within Structure (notably NativeLong).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix library load error when /usr/lib32 and /usr/lib both exist (linux) (Marek Slama).
|
||||
* Avoid incorrect matches against libraries named with the same prefix (e.g. libc-client.so vs libc.so) (xylo).
|
||||
* Properly handle arrays of NativeMapped (e.g. NativeLong) as a Structure field (stefan endrullis).
|
||||
* Ensure structure size calculated prior to setting union active type.
|
||||
* XID is 64-bits on 64-bit X clients (xylo).
|
||||
* Ensure proper arch name is used on Debian (amd64 instead of x86_64).
|
||||
|
||||
Release 3.0.3
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Enable build/run using IBM's J9 VM (leonardo).
|
||||
* Make StdCallFunctionMapper attempt a leading underscore if the simpler mapping doesn't work.
|
||||
* Allow Structure.read to overwrite final fields (may not work on some 1.4 VMs).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Fix NPE when passing an array of Structure.ByReference.
|
||||
* Compare entire linux library version when finding a match.
|
||||
* Don't pass struct by value unless the method signature declares it.
|
||||
* Restrict custom first element structure alignment to OSX/ppc.
|
||||
* Improve performance and reduce memory footprint for window masks. Optimize polygon-based masks on w32. Use XFillRectangles on X11.
|
||||
* Fix linkage settings on sunos-amd64 to avoid relocation errors.
|
||||
* Fix callback allocation code on w32, solaris, freebsd, darwin (libffi was misconfigured).
|
||||
* Fix bug when NativeMapped fields are used in a Structure.ByValue instance.
|
||||
* Fix NPE calling Structure.read() before memory is initialized.
|
||||
* Fix NPE calling Structure.read/write with uninitialized NativeMapped fields.
|
||||
|
||||
Release 3.0.2
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Attempt to force unload of jnidispatch library prior to deleting it (w32).
|
||||
* Added amd64 targets for OSX, FreeBSD, and Solaris.
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Reduce space allocated for invocation arguments.
|
||||
* Fix NPE when NativeMapped type is used in a Structure.
|
||||
* Fix some X11 type mappings for 64-bit.
|
||||
* Fix OSX Leopard/JRE1.5+ window transparency.
|
||||
* Fix window alpha compositing on X11.
|
||||
* Fix loading of libraries with unicode names on OSX.
|
||||
|
||||
Release 3.0.1
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Improve transparent window drawing performance on w32
|
||||
* Use closure allocation from libffi
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Ensure nested structure arrays initialized with Structure.toArray use the appropriate native memory.
|
||||
* Ensure structure size is calculated prior to converting to array
|
||||
* Avoid creating new windows when setting a window mask
|
||||
* Fix bug in Pointer.setChar.
|
||||
|
||||
Release 3.0
|
||||
===========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* More supported platforms, via GCC's libffi (wmeissner)
|
||||
* Support struct by value as parameter and return value (duncan)
|
||||
* Support struct by reference within structures
|
||||
* Provide access to native peer for java.awt.Component
|
||||
* Provide access to native peer on OS X.
|
||||
* Support MINGW32 builds (fullung)
|
||||
* Allow per-field Structure read/write by field name
|
||||
* Avoid writing Structure fields marked 'volatile'
|
||||
* Read and wrap function pointers in Structure fields when read with a Java proxy to allow easy Java-side invocation (Ken Larson)
|
||||
* Support array-backed Buffers as arguments (wmeissner)
|
||||
* Auto-conversion of custom types (wmeissner)
|
||||
* Allow pointer type-safety
|
||||
* Optional VM crash protection, via Native.setProtected(boolean)
|
||||
* Auto-convert WString[]
|
||||
* Provide library synchronization wrapper similar to Collections.synchronizedX
|
||||
* Support lookup of OSX framework libraries by name
|
||||
* Explicit access to shared library global data
|
||||
* Invocation interception to facilitate translation of C preprocessor macros and inline functions
|
||||
* Provide utility to determine Web Start native library cache location; auto-include this path if jnidispatch is included as a <nativelib> (robertengels)
|
||||
* Provide access to aligned memory
|
||||
* Versioning information embedded in jna.jar and native library
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Avoid attempts to free native library if it failed to load (wmeissner)
|
||||
* Explicitly check method signatures for varargs instead of heuristically guessing (wmeissner)
|
||||
* Disallow declaring Pointer-derived fields in Structures (Function, Memory)
|
||||
* Ensure Object.toString/hashCode/equals methods are intercepted on proxyied interfaces
|
||||
* Update X11 library for 64-bit use (wmeissner)
|
||||
* Properly map arrays of char*/wchar_t* under w32
|
||||
* Allow Pointer[] as a Structure field and Function argument
|
||||
* Fix some misleading Structure error messages
|
||||
* Properly preserve/return GetLastError/errno after native calls
|
||||
* Allocate executable memory on w32 to avoid errors with hardware-enforced data execution protection (DEP)
|
||||
* Fix VM crash on w32 stdcall callbacks
|
||||
* Use long offsets and sizes rather than ints (64-bit safe)
|
||||
* Properly clean up references and release closure memory on JNI_Unload
|
||||
* Use simpler AWT/JAWT library loading workaround
|
||||
* Avoid changing array references within a Structure on read
|
||||
|
||||
Release 2.5
|
||||
===========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Unions
|
||||
* Optimized shaped windows (chris deckers & olivier chafik); instantiation time improved by about 2-3 orders of magnitude for large, mostly contiguous shapes
|
||||
* Provide type mapping in callback arguments/results
|
||||
* Provide access to ByteBuffer direct address as a Pointer
|
||||
* Provide customization of native string encoding with jna.encoding system property
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Properly handle VMs with reversed Structure member storage
|
||||
* Avoid making window undecorated when clearing window mask on X11
|
||||
* Fix structure alignment bug on OSX/PPC when first element is > 4 bytes in size
|
||||
* Clearing OSX window mask by setting to MASK_NONE now works properly
|
||||
* Avoid index exceptions if native buffers are not NUL-terminated on string conversions
|
||||
* Write initialized Structure[] argument memory prior to function calls
|
||||
* Fix IllegalArgumentException reading WString into a Structure
|
||||
* Clear memory when allocating a structure block (fixes VM crash)
|
||||
* Remove versioned JAWT dependency on OSX, allowing use on 10.3/JRE1.4.
|
||||
|
||||
Release 2.4
|
||||
===========
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Explicitly support unaligned structures
|
||||
* Auto-reallocate structure arrays
|
||||
* Automatic handling of w32 UNICODE/ASCII variants
|
||||
* Automatic mapping of decorated w32 stdcall function names
|
||||
* Customizable, automatic type conversion of arguments and results (wmeissner)
|
||||
* Support char*[] arguments as Java String[]
|
||||
* Structure supports Callback members (wmeissner)
|
||||
* getByteBuffer from Pointer/Memory (wmeissner)
|
||||
* Allow GC of native libraries
|
||||
* Facilitate use from non-Java contexts (JRuby et al.) (wmeissner)
|
||||
* Improve library path searching (wmeissner)
|
||||
* Handle Structure[] arguments
|
||||
* Handle native long arguments and return values
|
||||
* Handle direct and array-based ByteBuffer arguments (wmeissner)
|
||||
* Change default w32 build to use GCC (it's free, yo)
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
* Structure.toArray failed to initialize members
|
||||
* Disallow explicit free of Structure/Memory
|
||||
* Ensure native libraries are only loaded once until released
|
||||
* Properly handle NULL when the return value is a Structure
|
||||
* Proper conversion to wchar_t on linux
|
||||
* Copy full length of Java strings to C strings instead of stopping when a NUL character is encountered
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
JNA is dual-licensed under 2 alternative Open Source/Free
|
||||
licenses: LGPL 2.1 and Apache License 2.0. (starting with
|
||||
JNA version 4.0.0).
|
||||
|
||||
What this means is that one can choose either one of these
|
||||
licenses (for purposes of re-distributing JNA; usually by
|
||||
including it as one of jars another application or
|
||||
library uses) by downloading corresponding jar file,
|
||||
using it, and living happily everafter.
|
||||
|
||||
You may obtain a copy of the LGPL License at:
|
||||
|
||||
http://www.gnu.org/licenses/licenses.html
|
||||
|
||||
A copy is also included in the downloadable source code package
|
||||
containing JNA, in file "LGPL2.1", under the same directory
|
||||
as this file.
|
||||
|
||||
You may obtain a copy of the ASL License at:
|
||||
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
A copy is also included in the downloadable source code package
|
||||
containing JNA, in file "ASL2.0", under the same directory
|
||||
as this file.
|
||||
@@ -1,12 +0,0 @@
|
||||
This copy of JNA is licensed under the
|
||||
Apache (Software) License, version 2.0 ("the License").
|
||||
See the License for details about distribution rights, and the
|
||||
specific rights regarding derivate works.
|
||||
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
A copy is also included in the downloadable source code package
|
||||
containing JNA, in file "ASL2.0", under the same directory
|
||||
as this file.
|
||||
@@ -1,13 +0,0 @@
|
||||
This copy of JNA is licensed under the
|
||||
Lesser General Public License (LGPL), version 2.1 ("the License").
|
||||
See the License for details about distribution rights, and the
|
||||
specific rights regarding derivate works.
|
||||
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.gnu.org/licenses/licenses.html
|
||||
|
||||
A copy is also included in the downloadable source code package
|
||||
containing JNA, in file "LGPL2.1", under the same directory
|
||||
as this file.
|
||||
|
||||
-120
@@ -1,120 +0,0 @@
|
||||

|
||||
|
||||
Java Native Access (JNA)
|
||||
========================
|
||||
|
||||
The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://twall.github.com/jna/4.1.0). Please read the [overview](http://twall.github.io/jna/4.1.0/overview-summary.html#overview_description). Questions, comments, or exploratory conversations should begin on the [mailing list](http://groups.google.com/group/jna-users), although you may find it easier to find answers to already-solved problems on [StackOverflow](http://stackoverflow.com/questions/tagged/jna).
|
||||
|
||||
JNA provides Java programs easy access to native shared libraries without writing anything but Java code - no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes.
|
||||
|
||||
JNA allows you to call directly into native functions using natural Java method invocation. The Java call looks just like the call does in native code. Most calls require no special handling or configuration; no boilerplate or generated code is required.
|
||||
|
||||
JNA uses a small JNI library stub to dynamically invoke native code. The developer uses a Java interface to describe functions and structures in the target native library. This makes it quite easy to take advantage of native platform features without incurring the high overhead of configuring and building JNI code for multiple platforms.
|
||||
|
||||
While significant attention has been paid to performance, correctness and ease of use take priority.
|
||||
|
||||
In addition, JNA includes a platform library with many native functions already mapped as well as a set of utility interfaces that simplify native access.
|
||||
|
||||
Projects Using JNA
|
||||
==================
|
||||
JNA is a mature library with dozens of contributors and hundreds of commercial and non-commercial projects that use it. If you're using JNA, feel free to [tell us about it](http://groups.google.com/group/jna-users). Include some details about your company, project name, purpose and size and tell us how you use the library.
|
||||
|
||||
Download
|
||||
========
|
||||
|
||||
Version 4.1.0
|
||||
|
||||
* [jna.jar](https://maven.java.net/content/repositories/releases/net/java/dev/jna/jna/4.1.0/jna-4.1.0.jar)
|
||||
* [jna-platform.jar](https://maven.java.net/content/repositories/releases/net/java/dev/jna/jna-platform/4.1.0/jna-platform-4.1.0.jar)
|
||||
|
||||
Features
|
||||
========
|
||||
|
||||
* Automatic mapping from Java to native functions, with simple mappings for all primitive data types
|
||||
* Runs on most platforms which support Java
|
||||
* Automatic conversion between C and Java strings, with customizable encoding/decoding
|
||||
* Structure and Union arguments/return values, by reference and by value
|
||||
* Function Pointers, (callbacks from native code to Java) as arguments and/or members of a struct
|
||||
* Auto-generated Java proxies for native function pointers
|
||||
* By-reference (pointer-to-type) arguments
|
||||
* Java array and NIO Buffer arguments (primitive types and pointers) as pointer-to-buffer
|
||||
* Nested structures and arrays
|
||||
* Wide (wchar_t-based) strings
|
||||
* Native long support (32- or 64-bit as appropriate)
|
||||
* [Demo applications/examples](https://github.com/twall/jna/tree/master/contrib)
|
||||
* Supported on 1.4 or later JVMs, including JavaME (earlier VMs may work with stubbed NIO support)
|
||||
* Customizable marshalling/unmarshalling (argument and return value conversions)
|
||||
* Customizable mapping from Java method to native function name, and customizable invocation to simulate C preprocessor function macros
|
||||
* Support for automatic Windows ASCII/UNICODE function mappings
|
||||
* Varargs support
|
||||
* Type-safety for native pointers
|
||||
* VM crash protection (optional)
|
||||
* Optimized direct mapping for high-performance applications.
|
||||
* COM support for early and late binding.
|
||||
* COM/Typelib java code generator.
|
||||
|
||||
Community and Support
|
||||
=====================
|
||||
|
||||
All questions should be posted to the [jna-users Google group](http://groups.google.com/group/jna-users). Issues can be submitted [here on Github](https://github.com/twall/jna/issues).
|
||||
|
||||
When posting to the mailing list, please include the following:
|
||||
|
||||
* What OS/CPU/architecture you're using (e.g. Windows 7 64-bit)
|
||||
* Reference to your native interface definitions (i.e. C headers), if available
|
||||
* The JNA mapping you're trying to use
|
||||
* VM crash logs, if any
|
||||
* Example native usage, and your attempted Java usage
|
||||
|
||||
It's nearly impossible to indicate proper Java usage when there's no native
|
||||
reference to work from.
|
||||
|
||||
For commercial support, please contact twalljava [at] java [dot] net.
|
||||
|
||||
Using the Library
|
||||
=================
|
||||
|
||||
* [Getting Started](https://github.com/twall/jna/blob/master/www/GettingStarted.md)
|
||||
* [Mapping between Java and Native](https://github.com/twall/jna/blob/master/www/Mappings.md)
|
||||
* [Using Pointers and Arrays](https://github.com/twall/jna/blob/master/www/PointersAndArrays.md)
|
||||
* [Using Structures and Unions](https://github.com/twall/jna/blob/master/www/StructuresAndUnions.md)
|
||||
* [Using By-Reference Arguments](https://github.com/twall/jna/blob/master/www/ByRefArguments.md)
|
||||
* [Customization of Type Mapping](https://github.com/twall/jna/blob/master/www/CustomMappings.md)
|
||||
* [Callbacks/Function Pointers/Closures](https://github.com/twall/jna/blob/master/www/CallbacksAndClosures.md)
|
||||
* [Dynamically Typed Languages (JRuby/Jython)](https://github.com/twall/jna/blob/master/www/DynamicallyTypedLanguages.md)
|
||||
* [Platform Library](https://github.com/twall/jna/blob/master/www/PlatformLibrary.md)
|
||||
* [Direct Method Mapping](https://github.com/twall/jna/blob/master/www/DirectMapping.md) (Optimization)
|
||||
* [Frequently Asked Questions (FAQ)](https://github.com/twall/jna/blob/master/www/FrequentlyAskedQuestions.md)
|
||||
* [Avoiding Crashes](http://twall.github.com/jna/4.1.0/javadoc/overview-summary.html#crash-protection)
|
||||
|
||||
Primary Documentation (JavaDoc)
|
||||
===============================
|
||||
|
||||
The definitive JNA reference is in the [JavaDoc](http://twall.github.com/jna/4.1.0/).
|
||||
|
||||
Developers
|
||||
==========
|
||||
|
||||
* [Contributing to JNA](https://github.com/twall/jna/blob/master/www/Contributing.md)
|
||||
* [Setting up a Windows Development Environment](https://github.com/twall/jna/blob/master/www/WindowsDevelopmentEnvironment.md)
|
||||
* [Setting up an Android Development Environment](https://github.com/twall/jna/blob/master/www/AndroidDevelopmentEnvironment.md)
|
||||
* [Releasing JNA](https://github.com/twall/jna/blob/master/www/ReleasingJNA.md)
|
||||
* [Publishing to Maven Central](https://github.com/twall/jna/blob/master/www/PublishingToMavenCentral.md)
|
||||
|
||||
Contributing
|
||||
============
|
||||
|
||||
You're encouraged to contribute to JNA. Fork the code from [https://github.com/twall/jna](https://github.com/twall/jna) and submit pull requests.
|
||||
|
||||
For more information on setting up a development environment see [Contributing to JNA](https://github.com/twall/jna/blob/master/www/Contributing.md).
|
||||
|
||||
If you are interested in paid support, feel free to say so on the [jna-users mailing list](http://groups.google.com/group/jna-users). Most simple questions will be answered on the list, but more complicated work, new features or target platforms can be negotiated with any of the JNA developers (this is how several of JNA's features came into being). You may even encounter other users with the same need and be able to cost share the new development.
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is licensed under the LGPL, version 2.1 or later, and (from version 4.0 onward) the Apache Software License, version 2.0. Commercial license arrangements are negotiable.
|
||||
|
||||
*NOTE: Oracle is not sponsoring this project, even though the package name (com.sun.jna) might imply otherwise.*
|
||||
|
||||
|
||||
-1200
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>alphamaskdemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.alphamaskdemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.alphamaskdemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-alphamask.jar"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.AlphaMaskDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="jna-platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com"/>
|
||||
<!-- jna -->
|
||||
<zipfileset src="${file.reference.jna.jar}"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>balloonmanagerdemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,68 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.balloonmanagerdemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.balloonmanagerdemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-balloonmanager.jar"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.BalloonManagerDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="jna-platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com"/>
|
||||
<!-- jna -->
|
||||
<zipfileset src="${file.reference.jna.jar}"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>balloontips</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,68 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.balloontipsdemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.balloontipsdemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-balloontips.jar"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.FilteredTextField" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="jna-platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com"/>
|
||||
<!-- jna -->
|
||||
<zipfileset src="${file.reference.jna.jar}"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>dnddemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,68 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.dnddemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.dnddemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-dnd.jar"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.GhostedDragImageDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="jna-platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com"/>
|
||||
<!-- jna -->
|
||||
<zipfileset src="${file.reference.jna.jar}"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,206 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Martin Steiger
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.platform.EnumUtils;
|
||||
import com.sun.jna.platform.win32.Dxva2;
|
||||
import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI;
|
||||
import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_COLOR_TEMPERATURE;
|
||||
import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_DISPLAY_TECHNOLOGY_TYPE;
|
||||
import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_DRIVE_TYPE;
|
||||
import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_GAIN_TYPE;
|
||||
import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_POSITION_TYPE;
|
||||
import com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_SIZE_TYPE;
|
||||
import com.sun.jna.platform.win32.LowLevelMonitorConfigurationAPI.MC_TIMING_REPORT;
|
||||
import com.sun.jna.platform.win32.PhysicalMonitorEnumerationAPI.PHYSICAL_MONITOR;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
import com.sun.jna.platform.win32.WTypes.LPSTR;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORDByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.LPARAM;
|
||||
import com.sun.jna.platform.win32.WinDef.RECT;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
import com.sun.jna.platform.win32.WinUser.HMONITOR;
|
||||
import com.sun.jna.platform.win32.WinUser.MONITORENUMPROC;
|
||||
import com.sun.jna.platform.win32.WinUser.MONITORINFOEX;
|
||||
|
||||
/**
|
||||
* A small demo that tests the Win32 monitor API.
|
||||
* All available physical and virtual monitors are enumerated and
|
||||
* their capabilities printed to stdout
|
||||
* @author Martin Steiger
|
||||
*/
|
||||
public class MonitorInfoDemo
|
||||
{
|
||||
/**
|
||||
* @param args (ignored)
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.println("Installed Physical Monitors: " + User32.INSTANCE.GetSystemMetrics(WinUser.SM_CMONITORS));
|
||||
|
||||
User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() {
|
||||
|
||||
@Override
|
||||
public int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam)
|
||||
{
|
||||
enumerate(hMonitor);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}, new LPARAM(0));
|
||||
}
|
||||
|
||||
static void enumerate(HMONITOR hMonitor)
|
||||
{
|
||||
System.out.println("Found HMONITOR: " + hMonitor.getPointer().toString());
|
||||
|
||||
MONITORINFOEX info = new MONITORINFOEX();
|
||||
User32.INSTANCE.GetMonitorInfo(hMonitor, info);
|
||||
System.out.println("Screen " + info.rcMonitor);
|
||||
System.out.println("Work area " + info.rcWork);
|
||||
boolean isPrimary = (info.dwFlags & WinUser.MONITORINFOF_PRIMARY) != 0;
|
||||
System.out.println("Primary? " + (isPrimary ? "yes" : "no"));
|
||||
System.out.println("Device " + new String(info.szDevice));
|
||||
|
||||
DWORDByReference pdwNumberOfPhysicalMonitors = new DWORDByReference();
|
||||
Dxva2.INSTANCE.GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, pdwNumberOfPhysicalMonitors);
|
||||
int monitorCount = pdwNumberOfPhysicalMonitors.getValue().intValue();
|
||||
|
||||
System.out.println("HMONITOR is linked to " + monitorCount + " physical monitors");
|
||||
|
||||
PHYSICAL_MONITOR[] physMons = new PHYSICAL_MONITOR[monitorCount];
|
||||
Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons);
|
||||
|
||||
for (int i = 0; i < monitorCount; i++)
|
||||
{
|
||||
HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
|
||||
System.out.println("Monitor " + i + " - " + new String(physMons[i].szPhysicalMonitorDescription));
|
||||
|
||||
enumeratePhysicalMonitor(hPhysicalMonitor);
|
||||
}
|
||||
|
||||
Dxva2.INSTANCE.DestroyPhysicalMonitors(monitorCount, physMons);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hPhysicalMonitor
|
||||
*/
|
||||
private static void enumeratePhysicalMonitor(HANDLE hPhysicalMonitor)
|
||||
{
|
||||
MC_DISPLAY_TECHNOLOGY_TYPE.ByReference techType = new MC_DISPLAY_TECHNOLOGY_TYPE.ByReference();
|
||||
Dxva2.INSTANCE.GetMonitorTechnologyType(hPhysicalMonitor, techType);
|
||||
System.out.println("TECHTYPE: " + techType.getValue());
|
||||
|
||||
DWORDByReference temps = new DWORDByReference();
|
||||
DWORDByReference caps = new DWORDByReference();
|
||||
Dxva2.INSTANCE.GetMonitorCapabilities(hPhysicalMonitor, caps, temps);
|
||||
System.out.println("CAPS " + EnumUtils.setFromInteger(caps.getValue().intValue(), HighLevelMonitorConfigurationAPI.MC_CAPS.class));
|
||||
System.out.println("Temps " + temps.getValue());
|
||||
|
||||
// Brightness
|
||||
DWORDByReference pdwMinimumBrightness = new DWORDByReference();
|
||||
DWORDByReference pdwCurrentBrightness = new DWORDByReference();
|
||||
DWORDByReference pdwMaximumBrightness = new DWORDByReference();
|
||||
Dxva2.INSTANCE.GetMonitorBrightness(hPhysicalMonitor, pdwMinimumBrightness, pdwCurrentBrightness, pdwMaximumBrightness);
|
||||
|
||||
System.out.println("Brightness Min: " + pdwMinimumBrightness.getValue());
|
||||
System.out.println("Brightness Current: " + pdwCurrentBrightness.getValue());
|
||||
System.out.println("Brightness Max: " + pdwMaximumBrightness.getValue());
|
||||
|
||||
// Contrast
|
||||
DWORDByReference pdwMinimumContrast = new DWORDByReference();
|
||||
DWORDByReference pdwCurrentContrast = new DWORDByReference();
|
||||
DWORDByReference pdwMaximumContrast = new DWORDByReference();
|
||||
Dxva2.INSTANCE.GetMonitorContrast(hPhysicalMonitor, pdwMinimumContrast, pdwCurrentContrast, pdwMaximumContrast);
|
||||
|
||||
System.out.println("Contrast Min: " + pdwMinimumContrast.getValue());
|
||||
System.out.println("Contrast Current: " + pdwCurrentContrast.getValue());
|
||||
System.out.println("Contrast Max: " + pdwMaximumContrast.getValue());
|
||||
|
||||
// Temperature
|
||||
MC_COLOR_TEMPERATURE.ByReference pctCurrentColorTemperature = new MC_COLOR_TEMPERATURE.ByReference();
|
||||
Dxva2.INSTANCE.GetMonitorColorTemperature(hPhysicalMonitor, pctCurrentColorTemperature);
|
||||
System.out.println("Current Temp: " + pctCurrentColorTemperature.getValue());
|
||||
|
||||
// Capabilities string
|
||||
DWORDByReference pdwCapabilitiesStringLengthInCharacters = new DWORDByReference();
|
||||
Dxva2.INSTANCE.GetCapabilitiesStringLength(hPhysicalMonitor, pdwCapabilitiesStringLengthInCharacters);
|
||||
DWORD capStrLen = pdwCapabilitiesStringLengthInCharacters.getValue();
|
||||
|
||||
LPSTR pszASCIICapabilitiesString = new LPSTR(new Memory(capStrLen.intValue()));
|
||||
Dxva2.INSTANCE.CapabilitiesRequestAndCapabilitiesReply(hPhysicalMonitor, pszASCIICapabilitiesString, capStrLen);
|
||||
System.out.println("Cap-String:" + new String(pszASCIICapabilitiesString.getPointer().getString(0)));
|
||||
|
||||
// Position
|
||||
MC_POSITION_TYPE ptPositionType = MC_POSITION_TYPE.MC_HORIZONTAL_POSITION;
|
||||
DWORDByReference pdwMinimumPosition = new DWORDByReference();
|
||||
DWORDByReference pdwCurrentPosition = new DWORDByReference();
|
||||
DWORDByReference pdwMaximumPosition = new DWORDByReference();
|
||||
Dxva2.INSTANCE.GetMonitorDisplayAreaPosition(hPhysicalMonitor, ptPositionType, pdwMinimumPosition, pdwCurrentPosition, pdwMaximumPosition);
|
||||
|
||||
System.out.println("Position (horz) Min: " + pdwMinimumPosition.getValue());
|
||||
System.out.println("Position (horz) Current: " + pdwCurrentPosition.getValue());
|
||||
System.out.println("Position (horz) Max: " + pdwMaximumPosition.getValue());
|
||||
|
||||
// Size
|
||||
MC_SIZE_TYPE ptSizeType = MC_SIZE_TYPE.MC_WIDTH;
|
||||
DWORDByReference pdwMinimumSize = new DWORDByReference();
|
||||
DWORDByReference pdwCurrentSize = new DWORDByReference();
|
||||
DWORDByReference pdwMaximumSize = new DWORDByReference();
|
||||
Dxva2.INSTANCE.GetMonitorDisplayAreaSize(hPhysicalMonitor, ptSizeType, pdwMinimumSize, pdwCurrentSize, pdwMaximumSize);
|
||||
|
||||
System.out.println("Width Min: " + pdwMinimumSize.getValue());
|
||||
System.out.println("Width Current: " + pdwCurrentSize.getValue());
|
||||
System.out.println("Width Max: " + pdwMaximumSize.getValue());
|
||||
|
||||
// Gain
|
||||
MC_GAIN_TYPE ptGainType = MC_GAIN_TYPE.MC_RED_GAIN;
|
||||
DWORDByReference pdwMinimumGain = new DWORDByReference();
|
||||
DWORDByReference pdwCurrentGain = new DWORDByReference();
|
||||
DWORDByReference pdwMaximumGain = new DWORDByReference();
|
||||
Dxva2.INSTANCE.GetMonitorRedGreenOrBlueGain(hPhysicalMonitor, ptGainType, pdwMinimumGain, pdwCurrentGain, pdwMaximumGain);
|
||||
|
||||
System.out.println("Red Gain Min: " + pdwMinimumSize.getValue());
|
||||
System.out.println("Red Gain Current: " + pdwCurrentSize.getValue());
|
||||
System.out.println("Red Gain Max: " + pdwMaximumSize.getValue());
|
||||
|
||||
// Drive
|
||||
MC_DRIVE_TYPE ptDriveType = MC_DRIVE_TYPE.MC_RED_DRIVE;
|
||||
DWORDByReference pdwMinimumDrive = new DWORDByReference();
|
||||
DWORDByReference pdwCurrentDrive = new DWORDByReference();
|
||||
DWORDByReference pdwMaximumDrive = new DWORDByReference();
|
||||
Dxva2.INSTANCE.GetMonitorRedGreenOrBlueDrive(hPhysicalMonitor, ptDriveType, pdwMinimumDrive, pdwCurrentDrive, pdwMaximumDrive);
|
||||
|
||||
System.out.println("Red Drive Min: " + pdwMinimumSize.getValue());
|
||||
System.out.println("Red Drive Current: " + pdwCurrentSize.getValue());
|
||||
System.out.println("Red Drive Max: " + pdwMaximumSize.getValue());
|
||||
|
||||
// Timing Report
|
||||
MC_TIMING_REPORT pmtrMonitorTimingReport = new MC_TIMING_REPORT();
|
||||
Dxva2.INSTANCE.GetTimingReport(hPhysicalMonitor, pmtrMonitorTimingReport);
|
||||
System.out.println("HorizontalFrequencyInHZ " + pmtrMonitorTimingReport.dwHorizontalFrequencyInHZ);
|
||||
System.out.println("VerticalFrequencyInHZ " + pmtrMonitorTimingReport.dwVerticalFrequencyInHZ);
|
||||
|
||||
System.out.println("--------------------------------------");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
|
||||
<classpathentry kind="var" path="JNA_LIB"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>msoffice</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
Arquivo binário não exibido.
Arquivo binário não exibido.
@@ -1,43 +0,0 @@
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.jna.platform.win32.COM.COMUtils;
|
||||
import com.sun.jna.platform.win32.COM.COMUtils.COMInfo;
|
||||
|
||||
public class COMInfoUtil {
|
||||
|
||||
public static void main(String[] args) {
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
String filename = "C:\\TEMP\\CLSIDs.txt";
|
||||
ArrayList<COMInfo> comInfos = COMUtils.getAllCOMInfoOnSystem();
|
||||
writer = new FileWriter(filename);
|
||||
|
||||
for (COMInfo comInfo : comInfos) {
|
||||
String result = "CLSID: " + comInfo.clsid + "\n";
|
||||
result += "InprocHandler32: " + comInfo.inprocHandler32 + "\n";
|
||||
result += "InprocServer32: " + comInfo.inprocServer32 + "\n";
|
||||
result += "LocalServer32: " + comInfo.localServer32 + "\n";
|
||||
result += "ProgID: " + comInfo.progID + "\n";
|
||||
result += "ProgTypeLibID: " + comInfo.typeLib + "\n";
|
||||
|
||||
writer.write(result + "\n");
|
||||
}
|
||||
|
||||
System.out.println("file written to: " + filename);
|
||||
System.out.println("Found CLSID`s on the system: "
|
||||
+ comInfos.size());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package com.sun.jna.platform.win32.COM.office;
|
||||
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.COM.COMException;
|
||||
import com.sun.jna.platform.win32.COM.COMLateBindingObject;
|
||||
import com.sun.jna.platform.win32.COM.IDispatch;
|
||||
|
||||
public class MSExcel extends COMLateBindingObject {
|
||||
|
||||
public MSExcel() throws COMException {
|
||||
super("Excel.Application", false);
|
||||
}
|
||||
|
||||
public MSExcel(boolean visible) throws COMException {
|
||||
this();
|
||||
this.setVisible(visible);
|
||||
}
|
||||
|
||||
public void setVisible(boolean bVisible) throws COMException {
|
||||
this.setProperty("Visible", bVisible);
|
||||
}
|
||||
|
||||
public String getVersion() throws COMException {
|
||||
return this.getStringProperty("Version");
|
||||
}
|
||||
|
||||
public void newExcelBook() throws COMException {
|
||||
this.invokeNoReply("Add", getWorkbooks());
|
||||
}
|
||||
|
||||
public void openExcelBook(String filename, boolean bVisible)
|
||||
throws COMException {
|
||||
// OpenDocument
|
||||
this.invokeNoReply("Open", getWorkbooks(), new VARIANT(filename));
|
||||
}
|
||||
|
||||
public void closeActiveWorkbook(boolean bSave) throws COMException {
|
||||
this.invokeNoReply("Close", getActiveWorkbook(), new VARIANT(bSave));
|
||||
}
|
||||
|
||||
public void quit() throws COMException {
|
||||
this.invokeNoReply("Quit");
|
||||
}
|
||||
|
||||
public void insertValue(String range, String value) throws COMException {
|
||||
Range pRange = new Range(this.getAutomationProperty("Range",
|
||||
this.getActiveSheet(), new VARIANT(range)));
|
||||
this.setProperty("Value", pRange, new VARIANT(value));
|
||||
}
|
||||
|
||||
public Application getApplication() {
|
||||
return new Application(this.getAutomationProperty("Application"));
|
||||
}
|
||||
|
||||
public ActiveWorkbook getActiveWorkbook() {
|
||||
return new ActiveWorkbook(this.getAutomationProperty("ActiveWorkbook"));
|
||||
}
|
||||
|
||||
public Workbooks getWorkbooks() {
|
||||
return new Workbooks(this.getAutomationProperty("WorkBooks"));
|
||||
}
|
||||
|
||||
public ActiveSheet getActiveSheet() {
|
||||
return new ActiveSheet(this.getAutomationProperty("ActiveSheet"));
|
||||
}
|
||||
|
||||
public class Application extends COMLateBindingObject {
|
||||
|
||||
public Application(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class Workbooks extends COMLateBindingObject {
|
||||
public Workbooks(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class ActiveWorkbook extends COMLateBindingObject {
|
||||
public ActiveWorkbook(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class ActiveSheet extends COMLateBindingObject {
|
||||
public ActiveSheet(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class Range extends COMLateBindingObject {
|
||||
public Range(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
package com.sun.jna.platform.win32.COM.office;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.sun.jna.platform.win32.COM.COMException;
|
||||
import com.sun.jna.platform.win32.WinDef.LONG;
|
||||
|
||||
public class MSOfficeDemo {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
new MSOfficeDemo();
|
||||
}
|
||||
|
||||
private String currentWorkingDir = new File("").getAbsolutePath()
|
||||
+ File.separator;
|
||||
|
||||
public MSOfficeDemo() {
|
||||
this.testMSWord();
|
||||
// this.testMSExcel();
|
||||
}
|
||||
|
||||
public void testMSWord() {
|
||||
MSWord msWord = null;
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/office/ff839952(v=office.15).aspx
|
||||
LONG wdFormatPDF = new LONG(17); // PDF format.
|
||||
LONG wdFormatRTF = new LONG(6); // Rich text format (RTF).
|
||||
LONG wdFormatHTML = new LONG(8); // Standard HTML format.
|
||||
LONG wdFormatDocument = new LONG(0); // Microsoft Office Word 97 - 2003 binary file format.
|
||||
LONG wdFormatDocumentDefault = new LONG(16); // Word default document file format. For Word 2010, this is the DOCX format.
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/office/ff838709(v=office.15).aspx
|
||||
LONG wdOriginalDocumentFormat = new LONG(1); // Original document format.
|
||||
LONG wdPromptUser = new LONG(2); // Prompt user to select a document format.
|
||||
LONG wdWordDocument = new LONG(0); // Microsoft Word document format.
|
||||
|
||||
try {
|
||||
msWord = new MSWord();
|
||||
System.out.println("MSWord version: " + msWord.getVersion());
|
||||
|
||||
msWord.setVisible(true);
|
||||
// msWord.newDocument();
|
||||
msWord.openDocument(currentWorkingDir + "jnatest.doc", true);
|
||||
msWord.insertText("Hello from JNA! \n\n");
|
||||
// wait 10sec. before closing
|
||||
Thread.currentThread().sleep(1000);
|
||||
// save in different formats
|
||||
// pdf format is only supported in MSWord 2007 and above
|
||||
msWord.SaveAs("C:\\TEMP\\jnatestSaveAs.doc", wdFormatDocument);
|
||||
msWord.SaveAs("C:\\TEMP\\jnatestSaveAs.pdf", wdFormatPDF);
|
||||
msWord.SaveAs("C:\\TEMP\\jnatestSaveAs.rtf", wdFormatRTF);
|
||||
msWord.SaveAs("C:\\TEMP\\jnatestSaveAs.html", wdFormatHTML);
|
||||
// close and save the document
|
||||
msWord.closeActiveDocument(false);
|
||||
msWord.newDocument();
|
||||
// msWord.openDocument(currentWorkingDir + "jnatest.doc", true);
|
||||
msWord.insertText("Hello from JNA! \n Please notice that JNA can control MS Word via the new COM interface! \nHere we are creating a new word document and we save it to the 'TEMP' directory!");
|
||||
// save with no user prompt
|
||||
msWord.SaveAs("C:\\TEMP\\jnatestNewDoc1.docx", wdFormatDocumentDefault);
|
||||
msWord.SaveAs("C:\\TEMP\\jnatestNewDoc2.docx", wdFormatDocumentDefault);
|
||||
msWord.SaveAs("C:\\TEMP\\jnatestNewDoc3.docx", wdFormatDocumentDefault);
|
||||
// close and save the document
|
||||
msWord.closeActiveDocument(false);
|
||||
// open 3 documents
|
||||
msWord.openDocument("C:\\TEMP\\jnatestNewDoc1.docx", true);
|
||||
msWord.insertText("Hello some changes from JNA!\n");
|
||||
msWord.openDocument("C:\\TEMP\\jnatestNewDoc2.docx", true);
|
||||
msWord.insertText("Hello some changes from JNA!\n");
|
||||
msWord.openDocument("C:\\TEMP\\jnatestNewDoc3.docx", true);
|
||||
msWord.insertText("Hello some changes from JNA!\n");
|
||||
// save the document and prompt the user
|
||||
msWord.Save(false, wdPromptUser);
|
||||
// wait then close word
|
||||
msWord.quit();
|
||||
} catch(InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
} catch (COMException e) {
|
||||
if (e.getExcepInfo() != null) {
|
||||
System.out
|
||||
.println("bstrSource: " + e.getExcepInfo().bstrSource);
|
||||
System.out.println("bstrDescription: "
|
||||
+ e.getExcepInfo().bstrDescription);
|
||||
}
|
||||
|
||||
// print stack trace
|
||||
e.printStackTrace();
|
||||
|
||||
if (msWord != null)
|
||||
msWord.quit();
|
||||
}
|
||||
}
|
||||
|
||||
public void testMSExcel() {
|
||||
MSExcel msExcel = null;
|
||||
|
||||
try {
|
||||
msExcel = new MSExcel();
|
||||
System.out.println("MSExcel version: " + msExcel.getVersion());
|
||||
msExcel.setVisible(true);
|
||||
// msExcel.newExcelBook();
|
||||
msExcel.openExcelBook(currentWorkingDir + "jnatest.xls", true);
|
||||
msExcel.insertValue("A1", "Hello from JNA!");
|
||||
// wait 10sec. before closing
|
||||
Thread.currentThread().sleep(10000);
|
||||
// close and save the active sheet
|
||||
msExcel.closeActiveWorkbook(true);
|
||||
msExcel.setVisible(true);
|
||||
// msExcel.newExcelBook();
|
||||
msExcel.openExcelBook(currentWorkingDir + "jnatest.xls", true);
|
||||
msExcel.insertValue("A1", "Hello from JNA!");
|
||||
// close and save the active sheet
|
||||
msExcel.closeActiveWorkbook(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
if (msExcel != null)
|
||||
msExcel.quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
package com.sun.jna.platform.win32.COM.office;
|
||||
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.COM.COMException;
|
||||
import com.sun.jna.platform.win32.COM.COMLateBindingObject;
|
||||
import com.sun.jna.platform.win32.COM.IDispatch;
|
||||
import com.sun.jna.platform.win32.WinDef.LONG;
|
||||
|
||||
public class MSWord extends COMLateBindingObject {
|
||||
|
||||
public MSWord() throws COMException {
|
||||
super("Word.Application", false);
|
||||
}
|
||||
|
||||
public MSWord(boolean visible) throws COMException {
|
||||
this();
|
||||
this.setVisible(visible);
|
||||
}
|
||||
|
||||
public void setVisible(boolean bVisible) throws COMException {
|
||||
this.setProperty("Visible", bVisible);
|
||||
}
|
||||
|
||||
public String getVersion() throws COMException {
|
||||
return this.getStringProperty("Version");
|
||||
}
|
||||
|
||||
public void newDocument() throws COMException {
|
||||
this.invokeNoReply("Add", getDocuments());
|
||||
}
|
||||
|
||||
public void openDocument(String filename, boolean bVisible)
|
||||
throws COMException {
|
||||
// OpenDocument
|
||||
this.invokeNoReply("Open", getDocuments(), new VARIANT(filename));
|
||||
}
|
||||
|
||||
public void closeActiveDocument(boolean bSave) throws COMException {
|
||||
this.invokeNoReply("Close", getActiveDocument(), new VARIANT(bSave));
|
||||
}
|
||||
|
||||
public void quit() throws COMException {
|
||||
this.invokeNoReply("Quit");
|
||||
}
|
||||
|
||||
public void insertText(String text) throws COMException {
|
||||
Selection pSelection = new Selection(this.getAutomationProperty(
|
||||
"Selection", this.getIDispatch()));
|
||||
this.invokeNoReply("TypeText", pSelection, new VARIANT(text));
|
||||
}
|
||||
|
||||
public void Save(boolean bNoPrompt, LONG originalFormat) throws COMException {
|
||||
VARIANT vtNoPrompt = new VARIANT(bNoPrompt);
|
||||
VARIANT vtOriginalFormat = new VARIANT(originalFormat);
|
||||
|
||||
this.invokeNoReply("Save", this.getDocuments(),
|
||||
vtNoPrompt, vtOriginalFormat);
|
||||
}
|
||||
|
||||
public void SaveAs(String FileName, LONG FileFormat) throws COMException {
|
||||
VARIANT vtFileName = new VARIANT(FileName);
|
||||
VARIANT vtFileFormat = new VARIANT(FileFormat);
|
||||
|
||||
this.invokeNoReply("SaveAs", this.getActiveDocument(),
|
||||
vtFileName, vtFileFormat);
|
||||
}
|
||||
|
||||
public ActiveDocument getActiveDocument() {
|
||||
return new ActiveDocument(this.getAutomationProperty("ActiveDocument"));
|
||||
}
|
||||
|
||||
public Documents getDocuments() {
|
||||
// GetDocuments
|
||||
Documents pDocuments = new Documents(this.getAutomationProperty(
|
||||
"Documents", this.getApplication().getIDispatch()));
|
||||
|
||||
return pDocuments;
|
||||
}
|
||||
|
||||
public Application getApplication() {
|
||||
return new Application(this.getAutomationProperty("Application"));
|
||||
}
|
||||
|
||||
public class Application extends COMLateBindingObject {
|
||||
public Application(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class Documents extends COMLateBindingObject {
|
||||
public Documents(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class ActiveDocument extends COMLateBindingObject {
|
||||
public ActiveDocument(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class Selection extends COMLateBindingObject {
|
||||
public Selection(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
|
||||
<classpathentry kind="lib" path="C:/GitHub/jna-3.5.1.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>native_window_msg</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,381 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.DBT;
|
||||
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_DEVICEINTERFACE;
|
||||
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_HANDLE;
|
||||
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_HDR;
|
||||
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_OEM;
|
||||
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_PORT;
|
||||
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_VOLUME;
|
||||
import com.sun.jna.platform.win32.Kernel32;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
import com.sun.jna.platform.win32.WinDef.HMODULE;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinDef.LPARAM;
|
||||
import com.sun.jna.platform.win32.WinDef.LRESULT;
|
||||
import com.sun.jna.platform.win32.WinDef.WPARAM;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
import com.sun.jna.platform.win32.WinUser.HDEVNOTIFY;
|
||||
import com.sun.jna.platform.win32.WinUser.MSG;
|
||||
import com.sun.jna.platform.win32.WinUser.WNDCLASSEX;
|
||||
import com.sun.jna.platform.win32.WinUser.WindowProc;
|
||||
import com.sun.jna.platform.win32.Wtsapi32;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class Win32WindowTest.
|
||||
*/
|
||||
public class Win32WindowDemo implements WindowProc {
|
||||
|
||||
/**
|
||||
* Instantiates a new win32 window test.
|
||||
*/
|
||||
public Win32WindowDemo() {
|
||||
// define new window class
|
||||
WString windowClass = new WString("MyWindowClass");
|
||||
HMODULE hInst = Kernel32.INSTANCE.GetModuleHandle("");
|
||||
|
||||
WNDCLASSEX wClass = new WNDCLASSEX();
|
||||
wClass.hInstance = hInst;
|
||||
wClass.lpfnWndProc = Win32WindowDemo.this;
|
||||
wClass.lpszClassName = windowClass;
|
||||
|
||||
// register window class
|
||||
User32.INSTANCE.RegisterClassEx(wClass);
|
||||
getLastError();
|
||||
|
||||
// create new window
|
||||
HWND hWnd = User32.INSTANCE
|
||||
.CreateWindowEx(
|
||||
User32.WS_EX_TOPMOST,
|
||||
windowClass,
|
||||
"My hidden helper window, used only to catch the windows events",
|
||||
0, 0, 0, 0, 0,
|
||||
null, // WM_DEVICECHANGE contradicts parent=WinUser.HWND_MESSAGE
|
||||
null, hInst, null);
|
||||
|
||||
getLastError();
|
||||
System.out.println("window sucessfully created! window hwnd: "
|
||||
+ hWnd.getPointer().toString());
|
||||
|
||||
Wtsapi32.INSTANCE.WTSRegisterSessionNotification(hWnd,
|
||||
Wtsapi32.NOTIFY_FOR_THIS_SESSION);
|
||||
|
||||
/* this filters for all device classes */
|
||||
// DEV_BROADCAST_HDR notificationFilter = new DEV_BROADCAST_HDR();
|
||||
// notificationFilter.dbch_devicetype = DBT.DBT_DEVTYP_DEVICEINTERFACE;
|
||||
|
||||
/* this filters for all usb device classes */
|
||||
DEV_BROADCAST_DEVICEINTERFACE notificationFilter = new DEV_BROADCAST_DEVICEINTERFACE();
|
||||
notificationFilter.dbcc_size = notificationFilter.size();
|
||||
notificationFilter.dbcc_devicetype = DBT.DBT_DEVTYP_DEVICEINTERFACE;
|
||||
notificationFilter.dbcc_classguid = DBT.GUID_DEVINTERFACE_USB_DEVICE;
|
||||
|
||||
/*
|
||||
* use User32.DEVICE_NOTIFY_ALL_INTERFACE_CLASSES instead of
|
||||
* DEVICE_NOTIFY_WINDOW_HANDLE to ignore the dbcc_classguid value
|
||||
*/
|
||||
HDEVNOTIFY hDevNotify = User32.INSTANCE.RegisterDeviceNotification(
|
||||
hWnd, notificationFilter, User32.DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
|
||||
getLastError();
|
||||
if (hDevNotify != null)
|
||||
System.out.println("RegisterDeviceNotification was sucessfully!");
|
||||
|
||||
MSG msg = new MSG();
|
||||
while (User32.INSTANCE.GetMessage(msg, hWnd, 0, 0) != 0) {
|
||||
User32.INSTANCE.TranslateMessage(msg);
|
||||
User32.INSTANCE.DispatchMessage(msg);
|
||||
}
|
||||
|
||||
User32.INSTANCE.UnregisterDeviceNotification(hDevNotify);
|
||||
Wtsapi32.INSTANCE.WTSUnRegisterSessionNotification(hWnd);
|
||||
User32.INSTANCE.UnregisterClass(windowClass, hInst);
|
||||
User32.INSTANCE.DestroyWindow(hWnd);
|
||||
|
||||
System.out.println("program exit!");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.sun.jna.platform.win32.User32.WindowProc#callback(com.sun.jna.platform
|
||||
* .win32.WinDef.HWND, int, com.sun.jna.platform.win32.WinDef.WPARAM,
|
||||
* com.sun.jna.platform.win32.WinDef.LPARAM)
|
||||
*/
|
||||
public LRESULT callback(HWND hwnd, int uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch (uMsg) {
|
||||
case WinUser.WM_CREATE: {
|
||||
onCreate(wParam, lParam);
|
||||
return new LRESULT(0);
|
||||
}
|
||||
case WinUser.WM_DESTROY: {
|
||||
User32.INSTANCE.PostQuitMessage(0);
|
||||
return new LRESULT(0);
|
||||
}
|
||||
case WinUser.WM_SESSION_CHANGE: {
|
||||
this.onSessionChange(wParam, lParam);
|
||||
return new LRESULT(0);
|
||||
}
|
||||
case WinUser.WM_DEVICECHANGE: {
|
||||
LRESULT lResult = this.onDeviceChange(wParam, lParam);
|
||||
return lResult != null ? lResult :
|
||||
User32.INSTANCE.DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
default:
|
||||
return User32.INSTANCE.DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last error.
|
||||
*
|
||||
* @return the last error
|
||||
*/
|
||||
public int getLastError() {
|
||||
int rc = Kernel32.INSTANCE.GetLastError();
|
||||
|
||||
if (rc != 0)
|
||||
System.out.println("error: " + rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* On session change.
|
||||
*
|
||||
* @param wParam
|
||||
* the w param
|
||||
* @param lParam
|
||||
* the l param
|
||||
*/
|
||||
protected void onSessionChange(WPARAM wParam, LPARAM lParam) {
|
||||
switch (wParam.intValue()) {
|
||||
case Wtsapi32.WTS_CONSOLE_CONNECT: {
|
||||
this.onConsoleConnect(lParam.intValue());
|
||||
break;
|
||||
}
|
||||
case Wtsapi32.WTS_CONSOLE_DISCONNECT: {
|
||||
this.onConsoleDisconnect(lParam.intValue());
|
||||
break;
|
||||
}
|
||||
case Wtsapi32.WTS_SESSION_LOGON: {
|
||||
this.onMachineLogon(lParam.intValue());
|
||||
break;
|
||||
}
|
||||
case Wtsapi32.WTS_SESSION_LOGOFF: {
|
||||
this.onMachineLogoff(lParam.intValue());
|
||||
break;
|
||||
}
|
||||
case Wtsapi32.WTS_SESSION_LOCK: {
|
||||
this.onMachineLocked(lParam.intValue());
|
||||
break;
|
||||
}
|
||||
case Wtsapi32.WTS_SESSION_UNLOCK: {
|
||||
this.onMachineUnlocked(lParam.intValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On console connect.
|
||||
*
|
||||
* @param sessionId
|
||||
* the session id
|
||||
*/
|
||||
protected void onConsoleConnect(int sessionId) {
|
||||
System.out.println("onConsoleConnect: " + sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* On console disconnect.
|
||||
*
|
||||
* @param sessionId
|
||||
* the session id
|
||||
*/
|
||||
protected void onConsoleDisconnect(int sessionId) {
|
||||
System.out.println("onConsoleDisconnect: " + sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* On machine locked.
|
||||
*
|
||||
* @param sessionId
|
||||
* the session id
|
||||
*/
|
||||
protected void onMachineLocked(int sessionId) {
|
||||
System.out.println("onMachineLocked: " + sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* On machine unlocked.
|
||||
*
|
||||
* @param sessionId
|
||||
* the session id
|
||||
*/
|
||||
protected void onMachineUnlocked(int sessionId) {
|
||||
System.out.println("onMachineUnlocked: " + sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* On machine logon.
|
||||
*
|
||||
* @param sessionId
|
||||
* the session id
|
||||
*/
|
||||
protected void onMachineLogon(int sessionId) {
|
||||
System.out.println("onMachineLogon: " + sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* On machine logoff.
|
||||
*
|
||||
* @param sessionId
|
||||
* the session id
|
||||
*/
|
||||
protected void onMachineLogoff(int sessionId) {
|
||||
System.out.println("onMachineLogoff: " + sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* On device change.
|
||||
*
|
||||
* @param wParam
|
||||
* the w param
|
||||
* @param lParam
|
||||
* the l param
|
||||
* @return the result. Null if the message is not processed.
|
||||
*/
|
||||
protected LRESULT onDeviceChange(WPARAM wParam, LPARAM lParam) {
|
||||
switch (wParam.intValue()) {
|
||||
case DBT.DBT_DEVICEARRIVAL: {
|
||||
return onDeviceChangeArrival(lParam);
|
||||
}
|
||||
case DBT.DBT_DEVICEREMOVECOMPLETE: {
|
||||
return onDeviceChangeRemoveComplete(lParam);
|
||||
}
|
||||
case DBT.DBT_DEVNODES_CHANGED: {
|
||||
//lParam is 0 for this wParam
|
||||
return onDeviceChangeNodesChanged();
|
||||
}
|
||||
default:
|
||||
System.out
|
||||
.println("Message WM_DEVICECHANGE message received, value unhandled.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected LRESULT onDeviceChangeArrivalOrRemoveComplete(LPARAM lParam, String action) {
|
||||
DEV_BROADCAST_HDR bhdr = new DEV_BROADCAST_HDR(lParam.longValue());
|
||||
switch (bhdr.dbch_devicetype) {
|
||||
case DBT.DBT_DEVTYP_DEVICEINTERFACE: {
|
||||
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363244.aspx
|
||||
DEV_BROADCAST_DEVICEINTERFACE bdif = new DEV_BROADCAST_DEVICEINTERFACE(bhdr.getPointer());
|
||||
System.out.println("BROADCAST_DEVICEINTERFACE: " + action);
|
||||
System.out.println("dbcc_devicetype: " + bdif.dbcc_devicetype);
|
||||
System.out.println("dbcc_name: " + bdif.getDbcc_name());
|
||||
System.out.println("dbcc_classguid: "
|
||||
+ bdif.dbcc_classguid.toGuidString());
|
||||
break;
|
||||
}
|
||||
case DBT.DBT_DEVTYP_HANDLE: {
|
||||
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363245.aspx
|
||||
DEV_BROADCAST_HANDLE bhd = new DEV_BROADCAST_HANDLE(bhdr.getPointer());
|
||||
System.out.println("BROADCAST_HANDLE: " + action);
|
||||
break;
|
||||
}
|
||||
case DBT.DBT_DEVTYP_OEM: {
|
||||
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363247.aspx
|
||||
DEV_BROADCAST_OEM boem = new DEV_BROADCAST_OEM(bhdr.getPointer());
|
||||
System.out.println("BROADCAST_OEM: " + action);
|
||||
break;
|
||||
}
|
||||
case DBT.DBT_DEVTYP_PORT: {
|
||||
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363248.aspx
|
||||
DEV_BROADCAST_PORT bpt = new DEV_BROADCAST_PORT(bhdr.getPointer());
|
||||
System.out.println("BROADCAST_PORT: " + action);
|
||||
break;
|
||||
}
|
||||
case DBT.DBT_DEVTYP_VOLUME: {
|
||||
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363249.aspx
|
||||
DEV_BROADCAST_VOLUME bvl = new DEV_BROADCAST_VOLUME(bhdr.getPointer());
|
||||
int logicalDriveAffected = bvl.dbcv_unitmask;
|
||||
short flag = bvl.dbcv_flags;
|
||||
boolean isMediaNotPhysical = 0 != (flag & DBT.DBTF_MEDIA/*value is 1*/);
|
||||
boolean isNet = 0 != (flag & DBT.DBTF_NET/*value is 2*/);
|
||||
System.out.println(action);
|
||||
int driveLetterIndex = 0;
|
||||
while (logicalDriveAffected != 0) {
|
||||
if (0 != (logicalDriveAffected & 1)) {
|
||||
System.out.println("Logical Drive Letter: " +
|
||||
((char) ('A' + driveLetterIndex)));
|
||||
}
|
||||
logicalDriveAffected >>>= 1;
|
||||
driveLetterIndex++;
|
||||
}
|
||||
System.out.println("isMediaNotPhysical:"+isMediaNotPhysical);
|
||||
System.out.println("isNet:"+isNet);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
// return TRUE means processed message for this wParam.
|
||||
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363205.aspx
|
||||
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363208.aspx
|
||||
return new LRESULT(1);
|
||||
}
|
||||
|
||||
protected LRESULT onDeviceChangeArrival(LPARAM lParam) {
|
||||
return onDeviceChangeArrivalOrRemoveComplete(lParam, "Arrival");
|
||||
}
|
||||
|
||||
protected LRESULT onDeviceChangeRemoveComplete(LPARAM lParam) {
|
||||
return onDeviceChangeArrivalOrRemoveComplete(lParam, "Remove Complete");
|
||||
}
|
||||
|
||||
protected LRESULT onDeviceChangeNodesChanged() {
|
||||
System.out.println("Message DBT_DEVNODES_CHANGED");
|
||||
// return TRUE means processed message for this wParam.
|
||||
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363211.aspx
|
||||
return new LRESULT(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* On create.
|
||||
*
|
||||
* @param wParam
|
||||
* the w param
|
||||
* @param lParam
|
||||
* the l param
|
||||
*/
|
||||
protected void onCreate(WPARAM wParam, LPARAM lParam) {
|
||||
System.out.println("onCreate: WM_CREATE");
|
||||
}
|
||||
|
||||
/**
|
||||
* The main method.
|
||||
*
|
||||
* @param args
|
||||
* the arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
new Win32WindowDemo();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ntservice</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
* Advapi32.java
|
||||
*
|
||||
* Created on 6. August 2007, 11:24
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface Advapi32 extends StdCallLibrary {
|
||||
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32",
|
||||
Advapi32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/*
|
||||
* SC_HANDLE WINAPI OpenSCManager( LPCTSTR lpMachineName, LPCTSTR
|
||||
* lpDatabaseName, DWORD dwDesiredAccess );
|
||||
*/
|
||||
public Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName,
|
||||
int dwDesiredAccess);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI CloseServiceHandle( SC_HANDLE hSCObject );
|
||||
*/
|
||||
public boolean CloseServiceHandle(Pointer hSCObject);
|
||||
|
||||
/*
|
||||
* SC_HANDLE WINAPI OpenService( SC_HANDLE hSCManager, LPCTSTR
|
||||
* lpServiceName, DWORD dwDesiredAccess );
|
||||
*/
|
||||
public Pointer OpenService(Pointer hSCManager, String lpServiceName,
|
||||
int dwDesiredAccess);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI StartService( SC_HANDLE hService, DWORD dwNumServiceArgs,
|
||||
* LPCTSTR* lpServiceArgVectors );
|
||||
*/
|
||||
public boolean StartService(Pointer hService, int dwNumServiceArgs,
|
||||
char[] lpServiceArgVectors);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI ControlService( SC_HANDLE hService, DWORD dwControl,
|
||||
* LPSERVICE_STATUS lpServiceStatus );
|
||||
*/
|
||||
public boolean ControlService(Pointer hService, int dwControl,
|
||||
SERVICE_STATUS lpServiceStatus);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI StartServiceCtrlDispatcher( const SERVICE_TABLE_ENTRY*
|
||||
* lpServiceTable );
|
||||
*/
|
||||
public boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable);
|
||||
|
||||
/*
|
||||
* SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler( LPCTSTR
|
||||
* lpServiceName, LPHANDLER_FUNCTION lpHandlerProc );
|
||||
*/
|
||||
public Pointer RegisterServiceCtrlHandler(String lpServiceName,
|
||||
Handler lpHandlerProc);
|
||||
|
||||
/*
|
||||
* SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx( LPCTSTR
|
||||
* lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext );
|
||||
*/
|
||||
public Pointer RegisterServiceCtrlHandlerEx(String lpServiceName,
|
||||
HandlerEx lpHandlerProc, Pointer lpContext);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI SetServiceStatus( SERVICE_STATUS_HANDLE hServiceStatus,
|
||||
* LPSERVICE_STATUS lpServiceStatus );
|
||||
*/
|
||||
public boolean SetServiceStatus(Pointer hServiceStatus,
|
||||
SERVICE_STATUS lpServiceStatus);
|
||||
|
||||
/*
|
||||
* SC_HANDLE WINAPI CreateService( SC_HANDLE hSCManager, LPCTSTR
|
||||
* lpServiceName, LPCTSTR lpDisplayName, DWORD dwDesiredAccess, DWORD
|
||||
* dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCTSTR
|
||||
* lpBinaryPathName, LPCTSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCTSTR
|
||||
* lpDependencies, LPCTSTR lpServiceStartName, LPCTSTR lpPassword );
|
||||
*/
|
||||
public Pointer CreateService(Pointer hSCManager, String lpServiceName,
|
||||
String lpDisplayName, int dwDesiredAccess, int dwServiceType,
|
||||
int dwStartType, int dwErrorControl, String lpBinaryPathName,
|
||||
String lpLoadOrderGroup, IntByReference lpdwTagId,
|
||||
String lpDependencies, String lpServiceStartName, String lpPassword);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI DeleteService( SC_HANDLE hService );
|
||||
*/
|
||||
public boolean DeleteService(Pointer hService);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI ChangeServiceConfig2( SC_HANDLE hService, DWORD dwInfoLevel,
|
||||
* LPVOID lpInfo );
|
||||
*/
|
||||
public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel,
|
||||
ChangeServiceConfig2Info lpInfo);
|
||||
|
||||
/*
|
||||
* LONG WINAPI RegEnumValue( HKEY hKey, DWORD dwIndex, LPTSTR lpValueName,
|
||||
* LPDWORD lpcchValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE
|
||||
* lpData, LPDWORD lpcbData );
|
||||
*/
|
||||
public int RegEnumValue(int hKey, int dwIndex, char[] lpValueName,
|
||||
IntByReference lpcchValueName, IntByReference reserved,
|
||||
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
|
||||
|
||||
interface SERVICE_MAIN_FUNCTION extends StdCallCallback {
|
||||
/*
|
||||
* VOID WINAPI ServiceMain( DWORD dwArgc, LPTSTR* lpszArgv );
|
||||
*/
|
||||
public void callback(int dwArgc, Pointer lpszArgv);
|
||||
}
|
||||
|
||||
interface Handler extends StdCallCallback {
|
||||
/*
|
||||
* VOID WINAPI Handler( DWORD fdwControl );
|
||||
*/
|
||||
public void callback(int fdwControl);
|
||||
}
|
||||
|
||||
interface HandlerEx extends StdCallCallback {
|
||||
/*
|
||||
* DWORD WINAPI HandlerEx( DWORD dwControl, DWORD dwEventType, LPVOID
|
||||
* lpEventData, LPVOID lpContext );
|
||||
*/
|
||||
public int callback(int dwControl, int dwEventType,
|
||||
Pointer lpEventData, Pointer lpContext);
|
||||
}
|
||||
|
||||
/*
|
||||
* typedef struct _SERVICE_STATUS { DWORD dwServiceType; DWORD
|
||||
* dwCurrentState; DWORD dwControlsAccepted; DWORD dwWin32ExitCode; DWORD
|
||||
* dwServiceSpecificExitCode; DWORD dwCheckPoint; DWORD dwWaitHint; }
|
||||
* SERVICE_STATUS,LPSERVICE_STATUS;
|
||||
*/
|
||||
public static class SERVICE_STATUS extends Structure {
|
||||
public int dwServiceType;
|
||||
public int dwCurrentState;
|
||||
public int dwControlsAccepted;
|
||||
public int dwWin32ExitCode;
|
||||
public int dwServiceSpecificExitCode;
|
||||
public int dwCheckPoint;
|
||||
public int dwWaitHint;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint" });
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* typedef struct _SERVICE_TABLE_ENTRY { LPTSTR lpServiceName;
|
||||
* LPSERVICE_MAIN_FUNCTION lpServiceProc; } SERVICE_TABLE_ENTRY,
|
||||
* LPSERVICE_TABLE_ENTRY;
|
||||
*/
|
||||
public static class SERVICE_TABLE_ENTRY extends Structure {
|
||||
public String lpServiceName;
|
||||
public SERVICE_MAIN_FUNCTION lpServiceProc;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "lpServiceName", "lpServiceProc" });
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class ChangeServiceConfig2Info extends Structure {
|
||||
}
|
||||
|
||||
/*
|
||||
* typedef struct _SERVICE_DESCRIPTION { LPTSTR lpDescription; }
|
||||
* SERVICE_DESCRIPTION,LPSERVICE_DESCRIPTION;
|
||||
*/
|
||||
public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
|
||||
public String lpDescription;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "lpDescription" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* WINNT.java
|
||||
*
|
||||
* Created on 8. August 2007, 13:41
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface WINNT {
|
||||
public final static int DELETE = 0x00010000;
|
||||
public final static int READ_CONTROL = 0x00020000;
|
||||
public final static int WRITE_DAC = 0x00040000;
|
||||
public final static int WRITE_OWNER = 0x00080000;
|
||||
public final static int SYNCHRONIZE = 0x00100000;
|
||||
|
||||
public final static int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
|
||||
|
||||
public final static int STANDARD_RIGHTS_READ = READ_CONTROL;
|
||||
public final static int STANDARD_RIGHTS_WRITE = READ_CONTROL;
|
||||
public final static int STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
|
||||
|
||||
public final static int STANDARD_RIGHTS_ALL = 0x001F0000;
|
||||
|
||||
public final static int SPECIFIC_RIGHTS_ALL = 0x0000FFFF;
|
||||
|
||||
public final static int GENERIC_EXECUTE = 0x20000000;
|
||||
|
||||
public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
# placeholder
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
|
||||
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>platform</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,182 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="platform" default="default" basedir=".">
|
||||
<description>Builds and tests platform-specific code.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="JnaContrib-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
|
||||
<target name="-do-jar-without-manifest">
|
||||
<jar jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="com.sun.jna.Native"/>
|
||||
<attribute name="Manifest-Version" value="1.0"/>
|
||||
<attribute name="Implementation-Title" value="${impl.title}"/>
|
||||
<attribute name="Implementation-Vendor" value="${vendor}"/>
|
||||
<attribute name="Implementation-Version" value="${impl.version}"/>
|
||||
<attribute name="Specification-Title" value="${spec.title}"/>
|
||||
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
|
||||
<attribute name="Specification-Version" value="${spec.version}"/>
|
||||
<!--
|
||||
OSGi Bundle attributes
|
||||
See http://www.osgi.org/Specifications/Reference
|
||||
-->
|
||||
<attribute name="Bundle-Category" value="jni"/>
|
||||
<attribute name="Bundle-ManifestVersion" value="2"/>
|
||||
<attribute name="Bundle-Name" value="jna-platform"/>
|
||||
<attribute name="Bundle-Description" value="JNA Platform Library"/>
|
||||
<attribute name="Bundle-SymbolicName" value="com.sun.jna.platform"/>
|
||||
<attribute name="Bundle-Version" value="${osgi.version}"/>
|
||||
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
|
||||
<attribute name="Bundle-Vendor" value="${vendor}"/>
|
||||
<attribute name="Require-Bundle" value="com.sun.jna;bundle-version="${osgi.version}""/>
|
||||
<attribute name="Export-Package"
|
||||
value="
|
||||
com.sun.jna.platform,
|
||||
com.sun.jna.platform.dnd,
|
||||
com.sun.jna.platform.mac,
|
||||
com.sun.jna.platform.unix,
|
||||
com.sun.jna.platform.win32,
|
||||
com.sun.jna.platform.win32.COM,
|
||||
com.sun.jna.platform.win32.COM.tlb,
|
||||
com.sun.jna.platform.win32.COM.tlb.imp,
|
||||
com.sun.jna.platform.wince
|
||||
"/>
|
||||
</manifest>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="test" depends="init,compile,compile-test,-pre-test-run" description="Run platform unit tests.">
|
||||
<echo>Running platform tests: ${test.src.dir}</echo>
|
||||
<property name="test.fork" value="yes"/>
|
||||
<property name="build.test.results.dir.abs" location="${build.test.results.dir}"/>
|
||||
<mkdir dir="${build.test.results.dir.abs}"/>
|
||||
<echo>Saving test results in ${build.test.results.dir.abs}</echo>
|
||||
<condition property="tests.platform" value="**/mac/**">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<condition property="tests.platform" value="**/win32/**">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<condition property="tests.platform" value="**/unix/**">
|
||||
<os family="unix"/>
|
||||
</condition>
|
||||
<property name="tests.platform" value=""/>
|
||||
<property name="tests.exclude" value=""/>
|
||||
<property name="tests.exclude-patterns" value=""/>
|
||||
<condition property="java.awt.headless" value="true">
|
||||
<isset property="headless"/>
|
||||
</condition>
|
||||
<condition property="vmopt.arch" value="-d64" else="-Dignore">
|
||||
<and>
|
||||
<!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
|
||||
<not><os family="windows"/></not>
|
||||
<equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
|
||||
</and>
|
||||
</condition>
|
||||
<propertyset id="headless">
|
||||
<propertyref prefix="java.awt.headless"/>
|
||||
</propertyset>
|
||||
<echo>tests.platform=${tests.platform}</echo>
|
||||
<junit fork="${test.fork}" failureproperty="testfailure" tempdir="${build.dir}">
|
||||
<!-- optionally run headless -->
|
||||
<syspropertyset refid="headless"/>
|
||||
<!-- avoid VM conflicts with JNA protected mode -->
|
||||
<env key="${ld.preload.name}" file="${libjsig}"/>
|
||||
<!-- Ignore any system install of JNA -->
|
||||
<sysproperty key="jna.nosys" value="true"/>
|
||||
<!-- Avoid VM crashes, if possible -->
|
||||
<sysproperty key="jna.protected" value="true"/>
|
||||
<sysproperty key="jna.builddir" file="${file.reference.jna.build}"/>
|
||||
<jvmarg value="${vmopt.arch}"/>
|
||||
<classpath><path path="${run.test.classpath}"/><path path="${file.reference.jna.build}/test-classes"/></classpath>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<batchtest todir="${build.test.results.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="${tests.exclude-patterns}">
|
||||
<!-- Until StructureFieldOrderTest gets fixed up a little -->
|
||||
<exclude name="**/StructureFieldOrderTest.java"/>
|
||||
<include name="com/sun/jna/platform/*Test.java"/>
|
||||
<include name="${tests.platform}"/>
|
||||
<exclude name="${tests.exclude}"/>
|
||||
</fileset>
|
||||
</batchtest>
|
||||
</junit>
|
||||
<junitreport todir="${build.test.results.dir}">
|
||||
<fileset dir="${build.test.results.dir}">
|
||||
<include name="TEST-*.xml"/>
|
||||
</fileset>
|
||||
<report todir="${build.test.results.dir}"/>
|
||||
</junitreport>
|
||||
<echo message="View test report in file://${build.test.results.dir.abs}/index.html" />
|
||||
<fail if="testfailure">One or more tests failed</fail>
|
||||
</target>
|
||||
|
||||
<!-- One-off test to check field order definitions -->
|
||||
<target name="test-field-order" depends="-pre-test-run-single" >
|
||||
<!-- @todo How to ensure sys prop: jna.nosys=true is seen in tests? -->
|
||||
<!--<property name="test.includes" value="com/sun/jna/platform/**/*.java"/>-->
|
||||
<property name="test.includes" value="com/sun/jna/platform/StructureFieldOrderTest.java"/>
|
||||
<property name="javac.includes" value="**/*"/>
|
||||
<antcall target="test-single"/>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,541 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
*** GENERATED FROM project.xml - DO NOT EDIT ***
|
||||
*** EDIT ../build.xml INSTEAD ***
|
||||
|
||||
For the purpose of easier reading the script
|
||||
is divided into following sections:
|
||||
|
||||
- initialization
|
||||
- compilation
|
||||
- jar
|
||||
- execution
|
||||
- debugging
|
||||
- javadoc
|
||||
- junit compilation
|
||||
- junit execution
|
||||
- junit debugging
|
||||
- applet
|
||||
- cleanup
|
||||
|
||||
-->
|
||||
<project name="platform-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
|
||||
<target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
|
||||
<!--
|
||||
======================
|
||||
INITIALIZATION SECTION
|
||||
======================
|
||||
-->
|
||||
<target name="-pre-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-private" depends="-pre-init">
|
||||
<property file="nbproject/private/private.properties"/>
|
||||
</target>
|
||||
<target name="-init-user" depends="-pre-init,-init-private">
|
||||
<property file="${user.properties.file}"/>
|
||||
<!-- The two properties below are usually overridden -->
|
||||
<!-- by the active platform. Just a fallback. -->
|
||||
<property name="default.javac.source" value="1.4"/>
|
||||
<property name="default.javac.target" value="1.4"/>
|
||||
</target>
|
||||
<target name="-init-project" depends="-pre-init,-init-private,-init-user">
|
||||
<property file="nbproject/project.properties"/>
|
||||
</target>
|
||||
<target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property">
|
||||
<available file="${manifest.file}" property="manifest.available"/>
|
||||
<condition property="manifest.available+main.class">
|
||||
<and>
|
||||
<isset property="manifest.available"/>
|
||||
<isset property="main.class"/>
|
||||
<not>
|
||||
<equals arg1="${main.class}" arg2="" trim="true"/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="manifest.available+main.class+mkdist.available">
|
||||
<and>
|
||||
<istrue value="${manifest.available+main.class}"/>
|
||||
<isset property="libs.CopyLibs.classpath"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="have.tests">
|
||||
<or>
|
||||
<available file="${test.src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="have.sources">
|
||||
<or>
|
||||
<available file="${src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="netbeans.home+have.tests">
|
||||
<and>
|
||||
<isset property="netbeans.home"/>
|
||||
<isset property="have.tests"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="no.javadoc.preview">
|
||||
<isfalse value="${javadoc.preview}"/>
|
||||
</condition>
|
||||
<property name="run.jvmargs" value=""/>
|
||||
<property name="javac.compilerargs" value=""/>
|
||||
<property name="work.dir" value="${basedir}"/>
|
||||
<condition property="no.deps">
|
||||
<and>
|
||||
<istrue value="${no.dependencies}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="javac.debug" value="true"/>
|
||||
<property name="javadoc.preview" value="true"/>
|
||||
</target>
|
||||
<target name="-post-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init">
|
||||
<fail unless="src.dir">Must set src.dir</fail>
|
||||
<fail unless="test.src.dir">Must set test.src.dir</fail>
|
||||
<fail unless="build.dir">Must set build.dir</fail>
|
||||
<fail unless="dist.dir">Must set dist.dir</fail>
|
||||
<fail unless="build.classes.dir">Must set build.classes.dir</fail>
|
||||
<fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
|
||||
<fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
|
||||
<fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
|
||||
<fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
|
||||
<fail unless="dist.jar">Must set dist.jar</fail>
|
||||
</target>
|
||||
<target name="-init-macrodef-property">
|
||||
<macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name"/>
|
||||
<attribute name="value"/>
|
||||
<sequential>
|
||||
<property name="@{name}" value="${@{value}}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-javac">
|
||||
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="srcdir" default="${src.dir}"/>
|
||||
<attribute name="destdir" default="${build.classes.dir}"/>
|
||||
<attribute name="classpath" default="${javac.classpath}"/>
|
||||
<attribute name="debug" default="${javac.debug}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<compilerarg line="${javac.compilerargs}"/>
|
||||
<customize/>
|
||||
</javac>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-junit">
|
||||
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="includes" default="**/*Test.java"/>
|
||||
<sequential>
|
||||
<junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
|
||||
<batchtest todir="${build.test.results.dir}">
|
||||
<fileset dir="${test.src.dir}" includes="@{includes}"/>
|
||||
</batchtest>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper type="glob" from="test-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-nbjpda">
|
||||
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<attribute name="stopclassname" default=""/>
|
||||
<sequential>
|
||||
<nbjpdastart transport="dt_socket" addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
</nbjpdastart>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="dir" default="${build.classes.dir}"/>
|
||||
<sequential>
|
||||
<nbjpdareload>
|
||||
<fileset includes="${fix.includes}*.class" dir="@{dir}"/>
|
||||
</nbjpdareload>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-debug">
|
||||
<macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg value="-Xdebug"/>
|
||||
<jvmarg value="-Xnoagent"/>
|
||||
<jvmarg value="-Djava.compiler=none"/>
|
||||
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-java">
|
||||
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="${run.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-presetdef-jar">
|
||||
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<jar jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<j2seproject1:fileset dir="${build.classes.dir}"/>
|
||||
</jar>
|
||||
</presetdef>
|
||||
</target>
|
||||
<target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar"/>
|
||||
<!--
|
||||
===================
|
||||
COMPILATION SECTION
|
||||
===================
|
||||
-->
|
||||
<target name="deps-jar" depends="init" unless="no.deps"/>
|
||||
<target name="-pre-pre-compile" depends="init,deps-jar">
|
||||
<mkdir dir="${build.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile" if="have.sources">
|
||||
<j2seproject3:javac/>
|
||||
<copy todir="${build.classes.dir}">
|
||||
<fileset dir="${src.dir}" excludes="${build.classes.excludes}"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/>
|
||||
<target name="-pre-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac>
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
</target>
|
||||
<target name="-post-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/>
|
||||
<!--
|
||||
====================
|
||||
JAR BUILDING SECTION
|
||||
====================
|
||||
-->
|
||||
<target name="-pre-pre-jar" depends="init">
|
||||
<dirname property="dist.jar.dir" file="${dist.jar}"/>
|
||||
<mkdir dir="${dist.jar.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-jar-without-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available">
|
||||
<j2seproject1:jar/>
|
||||
</target>
|
||||
<target name="-do-jar-with-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" unless="manifest.available+main.class">
|
||||
<j2seproject1:jar manifest="${manifest.file}"/>
|
||||
</target>
|
||||
<target name="-do-jar-with-mainclass" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" unless="manifest.available+main.class+mkdist.available">
|
||||
<j2seproject1:jar manifest="${manifest.file}">
|
||||
<j2seproject1:manifest>
|
||||
<j2seproject1:attribute name="Main-Class" value="${main.class}"/>
|
||||
</j2seproject1:manifest>
|
||||
</j2seproject1:jar>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<pathconvert property="run.classpath.with.dist.jar">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
|
||||
</pathconvert>
|
||||
<echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
|
||||
</target>
|
||||
<target name="-do-jar-with-libraries" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available">
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<pathconvert property="run.classpath.without.build.classes.dir">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to=""/>
|
||||
</pathconvert>
|
||||
<pathconvert property="jar.classpath" pathsep=" ">
|
||||
<path path="${run.classpath.without.build.classes.dir}"/>
|
||||
<chainedmapper>
|
||||
<flattenmapper/>
|
||||
<globmapper from="*" to="lib/*"/>
|
||||
</chainedmapper>
|
||||
</pathconvert>
|
||||
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" name="copylibs" classpath="${libs.CopyLibs.classpath}"/>
|
||||
<copylibs manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}" jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main.class}"/>
|
||||
<attribute name="Class-Path" value="${jar.classpath}"/>
|
||||
</manifest>
|
||||
</copylibs>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<echo>java -jar "${dist.jar.resolved}"</echo>
|
||||
</target>
|
||||
<target name="-post-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="jar" depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR."/>
|
||||
<!--
|
||||
=================
|
||||
EXECUTION SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="run" depends="init,compile" description="Run a main class.">
|
||||
<j2seproject1:java>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<target name="run-single" depends="init,compile-single">
|
||||
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
|
||||
<j2seproject1:java classname="${run.class}"/>
|
||||
</target>
|
||||
<!--
|
||||
=================
|
||||
DEBUGGING SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="-debug-start-debugger" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart name="${debug.class}"/>
|
||||
</target>
|
||||
<target name="-debug-start-debuggee" depends="init,compile">
|
||||
<j2seproject3:debug>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE."/>
|
||||
<target name="-debug-start-debugger-stepinto" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart stopclassname="${main.class}"/>
|
||||
</target>
|
||||
<target name="debug-stepinto" if="netbeans.home" depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/>
|
||||
<target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
|
||||
<j2seproject3:debug classname="${debug.class}"/>
|
||||
</target>
|
||||
<target name="debug-single" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/>
|
||||
<target name="-pre-debug-fix" depends="init">
|
||||
<fail unless="fix.includes">Must set fix.includes</fail>
|
||||
<property name="javac.includes" value="${fix.includes}.java"/>
|
||||
</target>
|
||||
<target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single">
|
||||
<j2seproject1:nbjpdareload/>
|
||||
</target>
|
||||
<target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/>
|
||||
<!--
|
||||
===============
|
||||
JAVADOC SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="-javadoc-build" depends="init">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<sourcepath>
|
||||
<pathelement location="${src.dir}"/>
|
||||
</sourcepath>
|
||||
<packageset dir="${src.dir}" includes="*/**"/>
|
||||
<fileset dir="${src.dir}" includes="*.java"/>
|
||||
</javadoc>
|
||||
</target>
|
||||
<target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,-javadoc-build">
|
||||
<nbbrowse file="${dist.javadoc.dir}/index.html"/>
|
||||
</target>
|
||||
<target name="javadoc" depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc."/>
|
||||
<!--
|
||||
=========================
|
||||
JUNIT COMPILATION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-pre-pre-compile-test" if="have.tests" depends="init,compile">
|
||||
<mkdir dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test">
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"/>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/>
|
||||
<target name="-pre-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}">
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT EXECUTION SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-pre-test-run" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run">
|
||||
<j2seproject3:junit/>
|
||||
</target>
|
||||
<target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-report" if="have.tests" depends="init"/>
|
||||
<target name="-test-browse" if="netbeans.home+have.tests" depends="init"/>
|
||||
<target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/>
|
||||
<target name="-pre-test-run-single" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single">
|
||||
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
|
||||
<j2seproject3:junit includes="${test.includes}"/>
|
||||
</target>
|
||||
<target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT DEBUGGING SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test">
|
||||
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
|
||||
<j2seproject3:debug classname="junit.textui.TestRunner" classpath="${debug.test.classpath}">
|
||||
<customize>
|
||||
<arg line="${test.class}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test">
|
||||
<j2seproject1:nbjpdastart name="${test.class}" classpath="${debug.test.classpath}"/>
|
||||
</target>
|
||||
<target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/>
|
||||
<target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single">
|
||||
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/>
|
||||
<!--
|
||||
=========================
|
||||
APPLET EXECUTION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="run-applet" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject1:java classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<!--
|
||||
=========================
|
||||
APPLET DEBUGGING SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-applet" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject3:debug classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug-applet" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/>
|
||||
<!--
|
||||
===============
|
||||
CLEANUP SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="deps-clean" depends="init" unless="no.deps"/>
|
||||
<target name="-do-clean" depends="init">
|
||||
<delete dir="${build.dir}"/>
|
||||
<delete dir="${dist.dir}"/>
|
||||
</target>
|
||||
<target name="-post-clean">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="clean" depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products."/>
|
||||
</project>
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Martin Steiger
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import com.sun.jna.FromNativeContext;
|
||||
import com.sun.jna.ToNativeContext;
|
||||
import com.sun.jna.TypeConverter;
|
||||
|
||||
/**
|
||||
* A {@link TypeConverter} that maps an integer enum value to
|
||||
* an actual Java enum.
|
||||
* @param <T> the enum type
|
||||
* @author Martin Steiger
|
||||
*/
|
||||
public class EnumConverter<T extends Enum<T>> implements TypeConverter {
|
||||
|
||||
private final Class<T> clazz;
|
||||
|
||||
/**
|
||||
* @param clazz the enum class
|
||||
*/
|
||||
public EnumConverter(Class<T> clazz)
|
||||
{
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromNative(Object input, FromNativeContext context) {
|
||||
Integer i = (Integer) input;
|
||||
|
||||
T[] vals = clazz.getEnumConstants();
|
||||
return vals[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer toNative(Object input, ToNativeContext context) {
|
||||
T t = clazz.cast(input);
|
||||
|
||||
return Integer.valueOf(t.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Integer> nativeType() {
|
||||
return Integer.class;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Martin Steiger
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sun.jna.platform.win32.FlagEnum;
|
||||
|
||||
/**
|
||||
* Several helper methods to convert integer flag (sets)
|
||||
* into enum (sets)
|
||||
* @author Martin Steiger
|
||||
*/
|
||||
public class EnumUtils
|
||||
{
|
||||
/**
|
||||
* Uninitialized integer flag
|
||||
*/
|
||||
public static final int UNINITIALIZED = -1;
|
||||
|
||||
/**
|
||||
* @param val the enum
|
||||
* @return the index of the enum in the enum list
|
||||
*/
|
||||
public static <E extends Enum<E>> int toInteger(E val)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
E[] vals = (E[]) val.getClass().getEnumConstants();
|
||||
|
||||
for (int idx = 0; idx < vals.length; idx++)
|
||||
{
|
||||
if (vals[idx] == val)
|
||||
return idx;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param idx the enum index
|
||||
* @param clazz the enum class
|
||||
* @return the enum at position idx
|
||||
*/
|
||||
public static <E extends Enum<E>> E fromInteger(int idx, Class<E> clazz)
|
||||
{
|
||||
if (idx == UNINITIALIZED)
|
||||
return null;
|
||||
|
||||
E[] vals = clazz.getEnumConstants();
|
||||
return vals[idx];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flags the ORed flags
|
||||
* @param clazz the enum class
|
||||
* @return the representing set
|
||||
*/
|
||||
public static <T extends FlagEnum> Set<T> setFromInteger(int flags, Class<T> clazz)
|
||||
{
|
||||
T[] vals = clazz.getEnumConstants();
|
||||
Set<T> result = new HashSet<T>();
|
||||
|
||||
for (T val : vals)
|
||||
{
|
||||
if ((flags & val.getFlag()) != 0)
|
||||
{
|
||||
result.add(val);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param set the set to convert
|
||||
* @return the flags combined into an integer
|
||||
*/
|
||||
public static <T extends FlagEnum> int setToInteger(Set<T> set) {
|
||||
int sum = 0;
|
||||
|
||||
for (T t : set)
|
||||
{
|
||||
sum |= t.getFlag();
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.jna.platform.win32.W32FileMonitor;
|
||||
|
||||
/** Provides notification of file system changes. Actual capabilities may
|
||||
* vary slightly by platform.
|
||||
* <p>
|
||||
* Watched files which are removed from the filesystem are no longer watched.
|
||||
* @author twall
|
||||
*/
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class FileMonitor {
|
||||
|
||||
public static final int FILE_CREATED = 0x1;
|
||||
public static final int FILE_DELETED = 0x2;
|
||||
public static final int FILE_MODIFIED = 0x4;
|
||||
public static final int FILE_ACCESSED = 0x8;
|
||||
public static final int FILE_NAME_CHANGED_OLD = 0x10;
|
||||
public static final int FILE_NAME_CHANGED_NEW = 0x20;
|
||||
public static final int FILE_RENAMED = FILE_NAME_CHANGED_OLD|FILE_NAME_CHANGED_NEW;
|
||||
public static final int FILE_SIZE_CHANGED = 0x40;
|
||||
public static final int FILE_ATTRIBUTES_CHANGED = 0x80;
|
||||
public static final int FILE_SECURITY_CHANGED = 0x100;
|
||||
public static final int FILE_ANY = 0x1FF;
|
||||
|
||||
public interface FileListener {
|
||||
public void fileChanged(FileEvent e);
|
||||
}
|
||||
|
||||
public class FileEvent extends EventObject {
|
||||
private final File file;
|
||||
private final int type;
|
||||
public FileEvent(File file, int type) {
|
||||
super(FileMonitor.this);
|
||||
this.file = file;
|
||||
this.type = type;
|
||||
}
|
||||
public File getFile() { return file; }
|
||||
public int getType() { return type; }
|
||||
public String toString() {
|
||||
return "FileEvent: " + file + ":" + type;
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<File, Integer> watched = new HashMap<File, Integer>();
|
||||
private List<FileListener> listeners = new ArrayList<FileListener>();
|
||||
|
||||
protected abstract void watch(File file, int mask, boolean recursive) throws IOException ;
|
||||
protected abstract void unwatch(File file);
|
||||
public abstract void dispose();
|
||||
|
||||
public void addWatch(File dir) throws IOException {
|
||||
addWatch(dir, FILE_ANY);
|
||||
}
|
||||
|
||||
public void addWatch(File dir, int mask) throws IOException {
|
||||
addWatch(dir, mask, dir.isDirectory());
|
||||
}
|
||||
|
||||
public void addWatch(File dir, int mask, boolean recursive) throws IOException {
|
||||
watched.put(dir, new Integer(mask));
|
||||
watch(dir, mask, recursive);
|
||||
}
|
||||
|
||||
public void removeWatch(File file) {
|
||||
if (watched.remove(file) != null) {
|
||||
unwatch(file);
|
||||
}
|
||||
}
|
||||
|
||||
protected void notify(FileEvent e) {
|
||||
for (FileListener listener : listeners) {
|
||||
listener.fileChanged(e);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void addFileListener(FileListener listener) {
|
||||
List<FileListener> list = new ArrayList<FileListener>(listeners);
|
||||
list.add(listener);
|
||||
listeners = list;
|
||||
}
|
||||
|
||||
public synchronized void removeFileListener(FileListener x) {
|
||||
List<FileListener> list = new ArrayList<FileListener>(listeners);
|
||||
list.remove(x);
|
||||
listeners = list;
|
||||
}
|
||||
|
||||
protected void finalize() {
|
||||
for (File watchedFile : watched.keySet()) {
|
||||
removeWatch(watchedFile);
|
||||
}
|
||||
|
||||
dispose();
|
||||
}
|
||||
|
||||
/** Canonical lazy loading of a singleton. */
|
||||
private static class Holder {
|
||||
public static final FileMonitor INSTANCE;
|
||||
static {
|
||||
String os = System.getProperty("os.name");
|
||||
if (os.startsWith("Windows")) {
|
||||
INSTANCE = new W32FileMonitor();
|
||||
}
|
||||
else {
|
||||
throw new Error("FileMonitor not implemented for " + os);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static FileMonitor getInstance() {
|
||||
return Holder.INSTANCE;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides integrated, extended drag and drop functionality,
|
||||
allowing ghosted drag images to be used on all platforms.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Denis Tulskiy
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sun.jna.platform.mac;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Callback;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Author: Denis Tulskiy
|
||||
* Date: 7/25/11
|
||||
*/
|
||||
public interface Carbon extends Library {
|
||||
public static Carbon INSTANCE = (Carbon) Native.loadLibrary("Carbon", Carbon.class);
|
||||
|
||||
public static final int cmdKey = 0x0100;
|
||||
public static final int shiftKey = 0x0200;
|
||||
public static final int optionKey = 0x0800;
|
||||
public static final int controlKey = 0x1000;
|
||||
|
||||
/**
|
||||
* Obtains the event target reference for the standard toolbox dispatcher
|
||||
*/
|
||||
public Pointer GetEventDispatcherTarget();
|
||||
|
||||
/**
|
||||
* Installs an event handler on a specified event target.
|
||||
*/
|
||||
public int InstallEventHandler(Pointer inTarget, EventHandlerProcPtr inHandler, int inNumTypes, EventTypeSpec[] inList, Pointer inUserData, PointerByReference outRef);
|
||||
|
||||
/**
|
||||
* Registers a global hot key.
|
||||
*/
|
||||
public int RegisterEventHotKey(int inHotKeyCode, int inHotKeyModifiers, EventHotKeyID.ByValue inHotKeyID, Pointer inTarget, int inOptions, PointerByReference outRef);
|
||||
|
||||
/**
|
||||
* Obtains a parameter from the specified event.
|
||||
*/
|
||||
public int GetEventParameter(Pointer inEvent, int inName, int inDesiredType, Pointer outActualType, int inBufferSize, IntBuffer outActualSize, EventHotKeyID outData);
|
||||
|
||||
/**
|
||||
* Removes the specified event handler
|
||||
*/
|
||||
public int RemoveEventHandler(Pointer inHandlerRef);
|
||||
|
||||
/**
|
||||
* Unregisters a global hot key.
|
||||
*/
|
||||
public int UnregisterEventHotKey(Pointer inHotKey);
|
||||
|
||||
public class EventTypeSpec extends Structure {
|
||||
public int eventClass;
|
||||
public int eventKind;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "eventClass", "eventKind" }); }
|
||||
}
|
||||
|
||||
public static class EventHotKeyID extends Structure {
|
||||
public int signature;
|
||||
public int id;
|
||||
|
||||
public static class ByValue extends EventHotKeyID implements Structure.ByValue { }
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "signature", "id" }); }
|
||||
}
|
||||
|
||||
public static interface EventHandlerProcPtr extends Callback {
|
||||
public int callback(Pointer inHandlerCallRef, Pointer inEvent, Pointer inUserData);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/* Copyright (c) 2007-2013 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.mac;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.ptr.ByteByReference;
|
||||
import com.sun.jna.platform.FileUtils;
|
||||
|
||||
public class MacFileUtils extends FileUtils {
|
||||
|
||||
public boolean hasTrash() { return true; }
|
||||
|
||||
public interface FileManager extends Library {
|
||||
|
||||
public FileManager INSTANCE = (FileManager)Native.loadLibrary("CoreServices", FileManager.class);
|
||||
|
||||
int kFSFileOperationDefaultOptions = 0;
|
||||
int kFSFileOperationsOverwrite = 0x01;
|
||||
int kFSFileOperationsSkipSourcePermissionErrors = 0x02;
|
||||
int kFSFileOperationsDoNotMoveAcrossVolumes = 0x04;
|
||||
int kFSFileOperationsSkipPreflight = 0x08;
|
||||
|
||||
int kFSPathDefaultOptions = 0x0;
|
||||
int kFSPathMakeRefDoNotFollowLeafSymlink = 0x01;
|
||||
|
||||
class FSRef extends Structure {
|
||||
public byte[] hidden = new byte[80];
|
||||
protected List getFieldOrder() { return Arrays.asList(new String[] { "hidden" }); }
|
||||
}
|
||||
|
||||
// Deprecated; use trashItemAtURL instead:
|
||||
// https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/trashItemAtURL:resultingItemURL:error:
|
||||
int FSRefMakePath(FSRef fsref, byte[] path, int maxPathSize);
|
||||
int FSPathMakeRef(String source, int options, ByteByReference isDirectory);
|
||||
int FSPathMakeRefWithOptions(String source, int options, FSRef fsref, ByteByReference isDirectory);
|
||||
int FSPathMoveObjectToTrashSync(String source, PointerByReference target, int options);
|
||||
int FSMoveObjectToTrashSync(FSRef source, FSRef target, int options);
|
||||
}
|
||||
|
||||
public void moveToTrash(File[] files) throws IOException {
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
File trash = new File(home, ".Trash");
|
||||
if (!trash.exists()) {
|
||||
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
|
||||
}
|
||||
List<String> failed = new ArrayList<String>();
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
FileManager.FSRef fsref = new FileManager.FSRef();
|
||||
int status = FileManager.INSTANCE.FSPathMakeRefWithOptions(src.getAbsolutePath(),
|
||||
FileManager.kFSPathMakeRefDoNotFollowLeafSymlink,
|
||||
fsref, null);
|
||||
if (status != 0) {
|
||||
failed.add(src + " (FSRef: " + status + ")");
|
||||
continue;
|
||||
}
|
||||
status = FileManager.INSTANCE.FSMoveObjectToTrashSync(fsref, null, 0);
|
||||
if (status != 0) {
|
||||
failed.add(src + " (" + status + ")");
|
||||
}
|
||||
}
|
||||
if (failed.size() > 0) {
|
||||
throw new IOException("The following files could not be trashed: " + failed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides cross-platform utilities based on platform-specific libraries.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,13 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides common library mappings for Unix and X11-based platforms.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1,127 +0,0 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.IntegerType;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.ptr.ByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Based on basetsd.h (various types)
|
||||
* @author dblock[at]dblock[dot]org
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public interface BaseTSD extends StdCallLibrary {
|
||||
/**
|
||||
* Signed long type for pointer precision.
|
||||
* Use when casting a pointer to a long to perform pointer arithmetic.
|
||||
*/
|
||||
public static class LONG_PTR extends IntegerType {
|
||||
public LONG_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public LONG_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
|
||||
public Pointer toPointer() {
|
||||
return Pointer.createConstant(longValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Signed SIZE_T.
|
||||
*/
|
||||
public static class SSIZE_T extends LONG_PTR {
|
||||
public SSIZE_T() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public SSIZE_T(long value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsigned LONG_PTR.
|
||||
*/
|
||||
public static class ULONG_PTR extends IntegerType {
|
||||
public ULONG_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public ULONG_PTR(long value) {
|
||||
super(Pointer.SIZE, value, true);
|
||||
}
|
||||
|
||||
public Pointer toPointer() {
|
||||
return Pointer.createConstant(longValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PULONG_PTR
|
||||
*/
|
||||
public static class ULONG_PTRByReference extends ByReference {
|
||||
public ULONG_PTRByReference() {
|
||||
this(new ULONG_PTR(0));
|
||||
}
|
||||
public ULONG_PTRByReference(ULONG_PTR value) {
|
||||
super(Pointer.SIZE);
|
||||
setValue(value);
|
||||
}
|
||||
public void setValue(ULONG_PTR value) {
|
||||
if (Pointer.SIZE == 4) {
|
||||
getPointer().setInt(0, value.intValue());
|
||||
}
|
||||
else {
|
||||
getPointer().setLong(0, value.longValue());
|
||||
}
|
||||
}
|
||||
public ULONG_PTR getValue() {
|
||||
return new ULONG_PTR(Pointer.SIZE == 4
|
||||
? getPointer().getInt(0)
|
||||
: getPointer().getLong(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unsigned DWORD_PTR.
|
||||
*/
|
||||
public static class DWORD_PTR extends IntegerType {
|
||||
public DWORD_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public DWORD_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum number of bytes to which a pointer can point.
|
||||
* Use for a count that must span the full range of a pointer.
|
||||
*/
|
||||
public static class SIZE_T extends ULONG_PTR {
|
||||
public SIZE_T() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public SIZE_T(long value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,338 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid;
|
||||
import com.sun.jna.platform.win32.Guid.CLSID;
|
||||
import com.sun.jna.platform.win32.Kernel32;
|
||||
import com.sun.jna.platform.win32.OaIdl;
|
||||
import com.sun.jna.platform.win32.OaIdl.DISPID;
|
||||
import com.sun.jna.platform.win32.OaIdl.DISPIDByReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.platform.win32.Ole32;
|
||||
import com.sun.jna.platform.win32.OleAuto;
|
||||
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.Variant.VariantArg;
|
||||
import com.sun.jna.platform.win32.WTypes;
|
||||
import com.sun.jna.platform.win32.WinDef.LCID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Helper class to provide basic COM support.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class COMBindingBaseObject extends COMInvoker {
|
||||
|
||||
/** The Constant LOCALE_USER_DEFAULT. */
|
||||
public final static LCID LOCALE_USER_DEFAULT = Kernel32.INSTANCE
|
||||
.GetUserDefaultLCID();
|
||||
|
||||
/** The Constant LOCALE_SYSTEM_DEFAULT. */
|
||||
public final static LCID LOCALE_SYSTEM_DEFAULT = Kernel32.INSTANCE
|
||||
.GetSystemDefaultLCID();
|
||||
|
||||
/** The i unknown. */
|
||||
private IUnknown iUnknown;
|
||||
|
||||
/** The i dispatch. */
|
||||
private IDispatch iDispatch;
|
||||
|
||||
/** IDispatch interface reference. */
|
||||
private PointerByReference pDispatch = new PointerByReference();
|
||||
|
||||
/** IUnknown interface reference. */
|
||||
private PointerByReference pUnknown = new PointerByReference();
|
||||
|
||||
public COMBindingBaseObject(IDispatch dispatch) {
|
||||
// transfer the value
|
||||
this.iDispatch = dispatch;
|
||||
}
|
||||
|
||||
public COMBindingBaseObject(CLSID clsid, boolean useActiveInstance) {
|
||||
this(clsid, useActiveInstance, WTypes.CLSCTX_SERVER);
|
||||
}
|
||||
|
||||
public COMBindingBaseObject(CLSID clsid, boolean useActiveInstance,
|
||||
int dwClsContext) {
|
||||
// Initialize COM for this thread...
|
||||
HRESULT hr = Ole32.INSTANCE.CoInitialize(null);
|
||||
|
||||
if (COMUtils.FAILED(hr)) {
|
||||
Ole32.INSTANCE.CoUninitialize();
|
||||
throw new COMException("CoInitialize() failed!");
|
||||
}
|
||||
|
||||
if (useActiveInstance) {
|
||||
hr = OleAuto.INSTANCE.GetActiveObject(clsid, null, this.pUnknown);
|
||||
|
||||
if (COMUtils.SUCCEEDED(hr)) {
|
||||
this.iUnknown = new Unknown(this.pUnknown.getValue());
|
||||
hr = iUnknown.QueryInterface(IDispatch.IID_IDISPATCH,
|
||||
this.pDispatch);
|
||||
} else {
|
||||
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null, dwClsContext,
|
||||
IDispatch.IID_IDISPATCH, this.pDispatch);
|
||||
}
|
||||
} else {
|
||||
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null, dwClsContext,
|
||||
IDispatch.IID_IDISPATCH, this.pDispatch);
|
||||
}
|
||||
|
||||
if (COMUtils.FAILED(hr)) {
|
||||
throw new COMException("COM object with CLSID "
|
||||
+ clsid.toGuidString() + " not registered properly!");
|
||||
}
|
||||
|
||||
this.iDispatch = new Dispatch(this.pDispatch.getValue());
|
||||
}
|
||||
|
||||
public COMBindingBaseObject(String progId, boolean useActiveInstance,
|
||||
int dwClsContext) throws COMException {
|
||||
// Initialize COM for this thread...
|
||||
HRESULT hr = Ole32.INSTANCE.CoInitialize(null);
|
||||
|
||||
if (COMUtils.FAILED(hr)) {
|
||||
this.release();
|
||||
throw new COMException("CoInitialize() failed!");
|
||||
}
|
||||
|
||||
// Get CLSID for Word.Application...
|
||||
CLSID.ByReference clsid = new CLSID.ByReference();
|
||||
hr = Ole32.INSTANCE.CLSIDFromProgID(progId, clsid);
|
||||
|
||||
if (COMUtils.FAILED(hr)) {
|
||||
Ole32.INSTANCE.CoUninitialize();
|
||||
throw new COMException("CLSIDFromProgID() failed!");
|
||||
}
|
||||
|
||||
if (useActiveInstance) {
|
||||
hr = OleAuto.INSTANCE.GetActiveObject(clsid, null, this.pUnknown);
|
||||
|
||||
if (COMUtils.SUCCEEDED(hr)) {
|
||||
this.iUnknown = new Unknown(this.pUnknown.getValue());
|
||||
hr = iUnknown.QueryInterface(IDispatch.IID_IDISPATCH,
|
||||
this.pDispatch);
|
||||
} else {
|
||||
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null, dwClsContext,
|
||||
IDispatch.IID_IDISPATCH, this.pDispatch);
|
||||
}
|
||||
} else {
|
||||
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null, dwClsContext,
|
||||
IDispatch.IID_IDISPATCH, this.pDispatch);
|
||||
}
|
||||
|
||||
if (COMUtils.FAILED(hr)) {
|
||||
throw new COMException("COM object with ProgID '" + progId
|
||||
+ "' and CLSID " + clsid.toGuidString()
|
||||
+ " not registered properly!");
|
||||
}
|
||||
|
||||
this.iDispatch = new Dispatch(this.pDispatch.getValue());
|
||||
}
|
||||
|
||||
public COMBindingBaseObject(String progId, boolean useActiveInstance)
|
||||
throws COMException {
|
||||
this(progId, useActiveInstance, WTypes.CLSCTX_SERVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the i dispatch.
|
||||
*
|
||||
* @return the i dispatch
|
||||
*/
|
||||
public IDispatch getIDispatch() {
|
||||
return iDispatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the i dispatch pointer.
|
||||
*
|
||||
* @return the i dispatch pointer
|
||||
*/
|
||||
public PointerByReference getIDispatchPointer() {
|
||||
return pDispatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the i unknown.
|
||||
*
|
||||
* @return the i unknown
|
||||
*/
|
||||
public IUnknown getIUnknown() {
|
||||
return iUnknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the i unknown pointer.
|
||||
*
|
||||
* @return the i unknown pointer
|
||||
*/
|
||||
public PointerByReference getIUnknownPointer() {
|
||||
return pUnknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release.
|
||||
*/
|
||||
public void release() {
|
||||
if (this.iDispatch != null)
|
||||
this.iDispatch.Release();
|
||||
|
||||
Ole32.INSTANCE.CoUninitialize();
|
||||
}
|
||||
|
||||
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
|
||||
IDispatch pDisp, String name, VARIANT[] pArgs) throws COMException {
|
||||
|
||||
if (pDisp == null)
|
||||
throw new COMException("pDisp (IDispatch) parameter is null!");
|
||||
|
||||
// variable declaration
|
||||
WString[] ptName = new WString[] { new WString(name) };
|
||||
DISPIDByReference pdispID = new DISPIDByReference();
|
||||
|
||||
// Get DISPID for name passed...
|
||||
HRESULT hr = pDisp.GetIDsOfNames(Guid.IID_NULL, ptName, 1,
|
||||
LOCALE_USER_DEFAULT, pdispID);
|
||||
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return this
|
||||
.oleMethod(nType, pvResult, pDisp, pdispID.getValue(), pArgs);
|
||||
}
|
||||
|
||||
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
|
||||
IDispatch pDisp, DISPID dispId, VARIANT[] pArgs)
|
||||
throws COMException {
|
||||
|
||||
if (pDisp == null)
|
||||
throw new COMException("pDisp (IDispatch) parameter is null!");
|
||||
|
||||
// variable declaration
|
||||
int _argsLen = 0;
|
||||
VARIANT[] _args = null;
|
||||
DISPPARAMS dp = new DISPPARAMS();
|
||||
EXCEPINFO.ByReference pExcepInfo = new EXCEPINFO.ByReference();
|
||||
IntByReference puArgErr = new IntByReference();
|
||||
|
||||
// make parameter reverse ordering as expected by COM runtime
|
||||
if ((pArgs != null) && (pArgs.length > 0)) {
|
||||
_argsLen = pArgs.length;
|
||||
_args = new VARIANT[_argsLen];
|
||||
|
||||
int revCount = _argsLen;
|
||||
for (int i = 0; i < _argsLen; i++) {
|
||||
_args[i] = pArgs[--revCount];
|
||||
}
|
||||
}
|
||||
|
||||
// Handle special-case for property-puts!
|
||||
if (nType == OleAuto.DISPATCH_PROPERTYPUT) {
|
||||
dp.cNamedArgs = new UINT(_argsLen);
|
||||
dp.rgdispidNamedArgs = new DISPIDByReference(
|
||||
OaIdl.DISPID_PROPERTYPUT);
|
||||
}
|
||||
|
||||
// Build DISPPARAMS
|
||||
if (_argsLen > 0) {
|
||||
dp.cArgs = new UINT(_args.length);
|
||||
// make pointer of variant array
|
||||
dp.rgvarg = new VariantArg.ByReference(_args);
|
||||
|
||||
// write 'DISPPARAMS' structure to memory
|
||||
dp.write();
|
||||
}
|
||||
|
||||
// Make the call!
|
||||
HRESULT hr = pDisp.Invoke(dispId, Guid.IID_NULL, LOCALE_SYSTEM_DEFAULT,
|
||||
new DISPID(nType), dp, pvResult, pExcepInfo, puArgErr);
|
||||
|
||||
COMUtils.checkRC(hr, pExcepInfo, puArgErr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ole method.
|
||||
*
|
||||
* @param nType
|
||||
* the n type
|
||||
* @param pvResult
|
||||
* the pv result
|
||||
* @param pDisp
|
||||
* the disp
|
||||
* @param name
|
||||
* the name
|
||||
* @param pArg
|
||||
* the arg
|
||||
* @return the hresult
|
||||
* @throws COMException
|
||||
* the cOM exception
|
||||
*/
|
||||
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
|
||||
IDispatch pDisp, String name, VARIANT pArg) throws COMException {
|
||||
|
||||
return this.oleMethod(nType, pvResult, pDisp, name,
|
||||
new VARIANT[] { pArg });
|
||||
}
|
||||
|
||||
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
|
||||
IDispatch pDisp, DISPID dispId, VARIANT pArg) throws COMException {
|
||||
|
||||
return this.oleMethod(nType, pvResult, pDisp, dispId,
|
||||
new VARIANT[] { pArg });
|
||||
}
|
||||
|
||||
/**
|
||||
* Ole method.
|
||||
*
|
||||
* @param nType
|
||||
* the n type
|
||||
* @param pvResult
|
||||
* the pv result
|
||||
* @param pDisp
|
||||
* the disp
|
||||
* @param name
|
||||
* the name
|
||||
* @return the hresult
|
||||
* @throws COMException
|
||||
* the cOM exception
|
||||
*/
|
||||
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
|
||||
IDispatch pDisp, String name) throws COMException {
|
||||
|
||||
return this.oleMethod(nType, pvResult, pDisp, name, (VARIANT[]) null);
|
||||
}
|
||||
|
||||
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
|
||||
IDispatch pDisp, DISPID dispId) throws COMException {
|
||||
|
||||
return this.oleMethod(nType, pvResult, pDisp, dispId, (VARIANT[]) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check failed.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
*/
|
||||
protected void checkFailed(HRESULT hr) {
|
||||
COMUtils.checkRC(hr, null, null);
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.CLSID;
|
||||
import com.sun.jna.platform.win32.Guid.IID;
|
||||
import com.sun.jna.platform.win32.OaIdl.DISPID;
|
||||
import com.sun.jna.platform.win32.OaIdl.DISPIDByReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.platform.win32.OleAuto;
|
||||
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT.ByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.LCID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.UINTByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Helper class to provide basic COM support.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class COMEarlyBindingObject extends COMBindingBaseObject implements
|
||||
IDispatch {
|
||||
|
||||
public COMEarlyBindingObject(CLSID clsid, boolean useActiveInstance,
|
||||
int dwClsContext) {
|
||||
super(clsid, useActiveInstance, dwClsContext);
|
||||
}
|
||||
|
||||
protected String getStringProperty(DISPID dispId) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.getIDispatch(), dispId);
|
||||
|
||||
return result.getValue().toString();
|
||||
}
|
||||
|
||||
protected void setProperty(DISPID dispId, boolean value) {
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null, this.getIDispatch(),
|
||||
dispId, new VARIANT(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HRESULT QueryInterface(IID riid, PointerByReference ppvObject) {
|
||||
return this.getIDispatch().QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int AddRef() {
|
||||
return this.getIDispatch().AddRef();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int Release() {
|
||||
return this.getIDispatch().Release();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HRESULT GetTypeInfoCount(UINTByReference pctinfo) {
|
||||
return this.getIDispatch().GetTypeInfoCount(pctinfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HRESULT GetTypeInfo(UINT iTInfo, LCID lcid,
|
||||
PointerByReference ppTInfo) {
|
||||
return this.getIDispatch().GetTypeInfo(iTInfo, lcid, ppTInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HRESULT GetIDsOfNames(IID riid, WString[] rgszNames, int cNames,
|
||||
LCID lcid, DISPIDByReference rgDispId) {
|
||||
return this.getIDispatch().GetIDsOfNames(riid, rgszNames, cNames, lcid,
|
||||
rgDispId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HRESULT Invoke(DISPID dispIdMember, IID riid, LCID lcid,
|
||||
DISPID wFlags, DISPPARAMS pDispParams, ByReference pVarResult,
|
||||
EXCEPINFO.ByReference pExcepInfo,
|
||||
IntByReference puArgErr) {
|
||||
return this.getIDispatch().Invoke(dispIdMember, riid, lcid, wFlags,
|
||||
pDispParams, pVarResult, pExcepInfo, puArgErr);
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Exception class for all COM related classes.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class COMException extends RuntimeException {
|
||||
|
||||
/** The p excep info. */
|
||||
private EXCEPINFO pExcepInfo;
|
||||
|
||||
/** The pu arg err. */
|
||||
private IntByReference puArgErr;
|
||||
|
||||
private int uArgErr;
|
||||
|
||||
/**
|
||||
* Instantiates a new automation exception.
|
||||
*/
|
||||
public COMException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new automation exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
* @param cause
|
||||
* the cause
|
||||
*/
|
||||
public COMException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new automation exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
*/
|
||||
public COMException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new automation exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
* @param pExcepInfo
|
||||
* the excep info
|
||||
* @param puArgErr
|
||||
* the pu arg err
|
||||
*/
|
||||
public COMException(String message, EXCEPINFO pExcepInfo,
|
||||
IntByReference puArgErr) {
|
||||
super(message + " (puArgErr=" + puArgErr.getValue() + ")");
|
||||
this.pExcepInfo = pExcepInfo;
|
||||
this.puArgErr = puArgErr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new automation exception.
|
||||
*
|
||||
* @param cause
|
||||
* the cause
|
||||
*/
|
||||
public COMException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the excep info.
|
||||
*
|
||||
* @return the excep info
|
||||
*/
|
||||
public EXCEPINFO getExcepInfo() {
|
||||
return pExcepInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the arg err.
|
||||
*
|
||||
* @return the arg err
|
||||
*/
|
||||
public IntByReference getArgErr() {
|
||||
return puArgErr;
|
||||
}
|
||||
|
||||
public int getuArgErr() {
|
||||
return uArgErr;
|
||||
}
|
||||
|
||||
public void setuArgErr(int uArgErr) {
|
||||
this.uArgErr = uArgErr;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Function;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.PointerType;
|
||||
|
||||
public abstract class COMInvoker extends PointerType {
|
||||
|
||||
protected int _invokeNativeInt(int vtableId, Object[] args) {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
// we take the vtable id and multiply with the pointer size (4 bytes on
|
||||
// 32bit OS)
|
||||
Function func = Function.getFunction(vptr.getPointer(vtableId
|
||||
* Pointer.SIZE));
|
||||
return func.invokeInt(args);
|
||||
}
|
||||
|
||||
protected Object _invokeNativeObject(int vtableId, Object[] args,
|
||||
Class returnType) {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
// we take the vtable id and multiply with the pointer size (4 bytes on
|
||||
// 32bit OS)
|
||||
Function func = Function.getFunction(vptr.getPointer(vtableId
|
||||
* Pointer.SIZE));
|
||||
return func.invoke(returnType, args);
|
||||
}
|
||||
|
||||
protected void _invokeNativeVoid(int vtableId, Object[] args) {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
// we take the vtable id and multiply with the pointer size (4 bytes on
|
||||
// 32bit OS)
|
||||
Function func = Function.getFunction(vptr.getPointer(vtableId
|
||||
* Pointer.SIZE));
|
||||
func.invokeVoid(args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,622 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.sun.jna.platform.win32.Guid.CLSID;
|
||||
import com.sun.jna.platform.win32.OaIdl.VARIANT_BOOL;
|
||||
import com.sun.jna.platform.win32.OleAuto;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WinDef.LONG;
|
||||
import com.sun.jna.platform.win32.WinDef.SHORT;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Helper class to provide basic COM support.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class COMLateBindingObject extends COMBindingBaseObject {
|
||||
|
||||
/**
|
||||
* Instantiates a new cOM object.
|
||||
*
|
||||
* @param iDispatch
|
||||
* the i dispatch
|
||||
*/
|
||||
public COMLateBindingObject(IDispatch iDispatch) {
|
||||
super(iDispatch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new cOM object.
|
||||
*
|
||||
* @param clsid
|
||||
* the clsid
|
||||
* @param useActiveInstance
|
||||
* the use active instance
|
||||
*/
|
||||
public COMLateBindingObject(CLSID clsid, boolean useActiveInstance) {
|
||||
super(clsid, useActiveInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new cOM object.
|
||||
*
|
||||
* @param progId
|
||||
* the prog id
|
||||
* @param useActiveInstance
|
||||
* the use active instance
|
||||
* @throws COMException
|
||||
* the automation exception
|
||||
*/
|
||||
public COMLateBindingObject(String progId, boolean useActiveInstance)
|
||||
throws COMException {
|
||||
super(progId, useActiveInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the automation property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @return the automation property
|
||||
*/
|
||||
protected IDispatch getAutomationProperty(String propertyName) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.getIDispatch(), propertyName);
|
||||
|
||||
return ((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the automation property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @param comObject
|
||||
* the com object
|
||||
* @return the automation property
|
||||
*/
|
||||
protected IDispatch getAutomationProperty(String propertyName,
|
||||
COMLateBindingObject comObject) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
comObject.getIDispatch(), propertyName);
|
||||
|
||||
return ((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the automation property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @param comObject
|
||||
* the com object
|
||||
* @param value
|
||||
* the value
|
||||
* @return the automation property
|
||||
*/
|
||||
protected IDispatch getAutomationProperty(String propertyName,
|
||||
COMLateBindingObject comObject, VARIANT value) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
comObject.getIDispatch(), propertyName, value);
|
||||
|
||||
return ((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the automation property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @param iDispatch
|
||||
* the i dispatch
|
||||
* @return the automation property
|
||||
*/
|
||||
protected IDispatch getAutomationProperty(String propertyName,
|
||||
IDispatch iDispatch) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.getIDispatch(), propertyName);
|
||||
|
||||
return ((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the boolean property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @return the boolean property
|
||||
*/
|
||||
protected boolean getBooleanProperty(String propertyName) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.getIDispatch(), propertyName);
|
||||
|
||||
return (((VARIANT_BOOL) result.getValue()).intValue() != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the date property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @return the date property
|
||||
*/
|
||||
protected Date getDateProperty(String propertyName) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.getIDispatch(), propertyName);
|
||||
|
||||
return result.dateValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the int property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @return the int property
|
||||
*/
|
||||
protected int getIntProperty(String propertyName) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.getIDispatch(), propertyName);
|
||||
|
||||
return ((LONG) result.getValue()).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the short property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @return the short property
|
||||
*/
|
||||
protected short getShortProperty(String propertyName) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.getIDispatch(), propertyName);
|
||||
|
||||
return ((SHORT) result.getValue()).shortValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @return the string property
|
||||
*/
|
||||
protected String getStringProperty(String propertyName) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.getIDispatch(), propertyName);
|
||||
|
||||
return result.getValue().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @return the variant
|
||||
*/
|
||||
protected VARIANT invoke(String methodName) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, result, this.getIDispatch(),
|
||||
methodName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param arg
|
||||
* the arg
|
||||
* @return the variant
|
||||
*/
|
||||
protected VARIANT invoke(String methodName, VARIANT arg) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, result, this.getIDispatch(),
|
||||
methodName, arg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param args
|
||||
* the args
|
||||
* @return the variant
|
||||
*/
|
||||
protected VARIANT invoke(String methodName, VARIANT[] args) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, result, this.getIDispatch(),
|
||||
methodName, args);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param arg1
|
||||
* the arg1
|
||||
* @param arg2
|
||||
* the arg2
|
||||
* @return the variant
|
||||
*/
|
||||
protected VARIANT invoke(String methodName, VARIANT arg1, VARIANT arg2) {
|
||||
return invoke(methodName, new VARIANT[] { arg1, arg2 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param arg1
|
||||
* the arg1
|
||||
* @param arg2
|
||||
* the arg2
|
||||
* @param arg3
|
||||
* the arg3
|
||||
* @return the variant
|
||||
*/
|
||||
protected VARIANT invoke(String methodName, VARIANT arg1, VARIANT arg2,
|
||||
VARIANT arg3) {
|
||||
return invoke(methodName, new VARIANT[] { arg1, arg2, arg3 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param arg1
|
||||
* the arg1
|
||||
* @param arg2
|
||||
* the arg2
|
||||
* @param arg3
|
||||
* the arg3
|
||||
* @param arg4
|
||||
* the arg4
|
||||
* @return the variant
|
||||
*/
|
||||
protected VARIANT invoke(String methodName, VARIANT arg1, VARIANT arg2,
|
||||
VARIANT arg3, VARIANT arg4) {
|
||||
return invoke(methodName, new VARIANT[] { arg1, arg2, arg3, arg4 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke no reply.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param dispatch
|
||||
* the dispatch
|
||||
*/
|
||||
protected void invokeNoReply(String methodName, IDispatch dispatch) {
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, null, dispatch, methodName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke no reply.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param comObject
|
||||
* the com object
|
||||
*/
|
||||
protected void invokeNoReply(String methodName,
|
||||
COMLateBindingObject comObject) {
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, null, comObject.getIDispatch(),
|
||||
methodName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke no reply.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param dispatch
|
||||
* the dispatch
|
||||
* @param arg
|
||||
* the arg
|
||||
*/
|
||||
protected void invokeNoReply(String methodName, IDispatch dispatch,
|
||||
VARIANT arg) {
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, null, dispatch, methodName, arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke no reply.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param dispatch
|
||||
* the dispatch
|
||||
* @param arg1
|
||||
* the arg1
|
||||
* @param arg2
|
||||
* the arg2
|
||||
*/
|
||||
protected void invokeNoReply(String methodName, IDispatch dispatch,
|
||||
VARIANT arg1, VARIANT arg2) {
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, null, dispatch, methodName,
|
||||
new VARIANT[] { arg1, arg2 });
|
||||
}
|
||||
|
||||
protected void invokeNoReply(String methodName, COMLateBindingObject comObject,
|
||||
VARIANT arg1, VARIANT arg2) {
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, null, comObject.getIDispatch(), methodName,
|
||||
new VARIANT[] { arg1, arg2 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke no reply.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param comObject
|
||||
* the com object
|
||||
* @param arg
|
||||
* the arg
|
||||
*/
|
||||
protected void invokeNoReply(String methodName,
|
||||
COMLateBindingObject comObject, VARIANT arg) {
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, null, comObject.getIDispatch(),
|
||||
methodName, arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke no reply.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param dispatch
|
||||
* the dispatch
|
||||
* @param args
|
||||
* the args
|
||||
*/
|
||||
protected void invokeNoReply(String methodName, IDispatch dispatch,
|
||||
VARIANT[] args) {
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, null, dispatch, methodName,
|
||||
args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke no reply.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
*/
|
||||
protected void invokeNoReply(String methodName) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, result, this.getIDispatch(),
|
||||
methodName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke no reply.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param arg
|
||||
* the arg
|
||||
*/
|
||||
protected void invokeNoReply(String methodName, VARIANT arg) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, result, this.getIDispatch(),
|
||||
methodName, arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke no reply.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param args
|
||||
* the args
|
||||
*/
|
||||
protected void invokeNoReply(String methodName, VARIANT[] args) {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, result, this.getIDispatch(),
|
||||
methodName, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke no reply.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param arg1
|
||||
* the arg1
|
||||
* @param arg2
|
||||
* the arg2
|
||||
*/
|
||||
protected void invokeNoReply(String methodName, VARIANT arg1, VARIANT arg2) {
|
||||
invokeNoReply(methodName, new VARIANT[] { arg1, arg2 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke no reply.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param arg1
|
||||
* the arg1
|
||||
* @param arg2
|
||||
* the arg2
|
||||
* @param arg3
|
||||
* the arg3
|
||||
*/
|
||||
protected void invokeNoReply(String methodName, VARIANT arg1, VARIANT arg2,
|
||||
VARIANT arg3) {
|
||||
invokeNoReply(methodName, new VARIANT[] { arg1, arg2, arg3 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke no reply.
|
||||
*
|
||||
* @param methodName
|
||||
* the method name
|
||||
* @param arg1
|
||||
* the arg1
|
||||
* @param arg2
|
||||
* the arg2
|
||||
* @param arg3
|
||||
* the arg3
|
||||
* @param arg4
|
||||
* the arg4
|
||||
*/
|
||||
protected void invokeNoReply(String methodName, VARIANT arg1, VARIANT arg2,
|
||||
VARIANT arg3, VARIANT arg4) {
|
||||
invokeNoReply(methodName, new VARIANT[] { arg1, arg2, arg3, arg4 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
protected void setProperty(String propertyName, boolean value) {
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null, this.getIDispatch(),
|
||||
propertyName, new VARIANT(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
protected void setProperty(String propertyName, Date value) {
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null, this.getIDispatch(),
|
||||
propertyName, new VARIANT(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
protected void setProperty(String propertyName, IDispatch value) {
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null, this.getIDispatch(),
|
||||
propertyName, new VARIANT(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
protected void setProperty(String propertyName, int value) {
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null, this.getIDispatch(),
|
||||
propertyName, new VARIANT(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
protected void setProperty(String propertyName, short value) {
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null, this.getIDispatch(),
|
||||
propertyName, new VARIANT(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
protected void setProperty(String propertyName, String value) {
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null, this.getIDispatch(),
|
||||
propertyName, new VARIANT(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @param iDispatch
|
||||
* the i dispatch
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
protected void setProperty(String propertyName, IDispatch iDispatch,
|
||||
VARIANT value) {
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null, iDispatch,
|
||||
propertyName, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property.
|
||||
*
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @param comObject
|
||||
* the com object
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
protected void setProperty(String propertyName,
|
||||
COMLateBindingObject comObject, VARIANT value) {
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null,
|
||||
comObject.getIDispatch(), propertyName, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* To variant.
|
||||
*
|
||||
* @return the variant
|
||||
*/
|
||||
public VARIANT toVariant() {
|
||||
return new VARIANT(this.getIDispatch());
|
||||
}
|
||||
}
|
||||
@@ -1,231 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.Advapi32;
|
||||
import com.sun.jna.platform.win32.Advapi32Util;
|
||||
import com.sun.jna.platform.win32.Advapi32Util.EnumKey;
|
||||
import com.sun.jna.platform.win32.Advapi32Util.InfoKey;
|
||||
import com.sun.jna.platform.win32.Kernel32Util;
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WinNT;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.WinReg;
|
||||
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class COMUtils.
|
||||
*
|
||||
* @author wolf.tobias@gmx.net The Class COMUtils.
|
||||
*/
|
||||
public abstract class COMUtils {
|
||||
|
||||
/** The Constant CO_E_NOTINITIALIZED. */
|
||||
public static final int S_OK = 0;
|
||||
|
||||
/**
|
||||
* Succeeded.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean SUCCEEDED(HRESULT hr) {
|
||||
return SUCCEEDED(hr.intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Succeeded.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean SUCCEEDED(int hr) {
|
||||
if (hr == S_OK)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Failed.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean FAILED(HRESULT hr) {
|
||||
return FAILED(hr.intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Failed.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean FAILED(int hr) {
|
||||
if (hr != S_OK)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw new exception.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
*/
|
||||
public static void checkRC(HRESULT hr) {
|
||||
checkRC(hr, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw new exception.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @param pExcepInfo
|
||||
* the excep info
|
||||
* @param puArgErr
|
||||
* the pu arg err
|
||||
*/
|
||||
public static void checkRC(HRESULT hr, EXCEPINFO pExcepInfo,
|
||||
IntByReference puArgErr) {
|
||||
if (FAILED(hr)) {
|
||||
String formatMessageFromHR = Kernel32Util.formatMessage(hr);
|
||||
throw new COMException(formatMessageFromHR, pExcepInfo, puArgErr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the all com info on system.
|
||||
*
|
||||
* @return the all com info on system
|
||||
*/
|
||||
public static ArrayList<COMInfo> getAllCOMInfoOnSystem() {
|
||||
HKEYByReference phkResult = new HKEYByReference();
|
||||
HKEYByReference phkResult2 = new HKEYByReference();
|
||||
String subKey;
|
||||
ArrayList<COMInfo> comInfos = new ArrayList<COMUtils.COMInfo>();
|
||||
|
||||
try {
|
||||
// open root key
|
||||
phkResult = Advapi32Util.registryGetKey(WinReg.HKEY_CLASSES_ROOT,
|
||||
"CLSID", WinNT.KEY_ALL_ACCESS);
|
||||
// open subkey
|
||||
InfoKey infoKey = Advapi32Util.registryQueryInfoKey(
|
||||
phkResult.getValue(), WinNT.KEY_ALL_ACCESS);
|
||||
|
||||
for (int i = 0; i < infoKey.lpcSubKeys.getValue(); i++) {
|
||||
EnumKey enumKey = Advapi32Util.registryRegEnumKey(
|
||||
phkResult.getValue(), i);
|
||||
subKey = Native.toString(enumKey.lpName);
|
||||
|
||||
COMInfo comInfo = new COMInfo(subKey);
|
||||
|
||||
phkResult2 = Advapi32Util.registryGetKey(phkResult.getValue(),
|
||||
subKey, WinNT.KEY_ALL_ACCESS);
|
||||
InfoKey infoKey2 = Advapi32Util.registryQueryInfoKey(
|
||||
phkResult2.getValue(), WinNT.KEY_ALL_ACCESS);
|
||||
|
||||
for (int y = 0; y < infoKey2.lpcSubKeys.getValue(); y++) {
|
||||
EnumKey enumKey2 = Advapi32Util.registryRegEnumKey(
|
||||
phkResult2.getValue(), y);
|
||||
String subKey2 = Native.toString(enumKey2.lpName);
|
||||
|
||||
if (subKey2.equals("InprocHandler32")) {
|
||||
comInfo.inprocHandler32 = (String) Advapi32Util
|
||||
.registryGetValue(phkResult2.getValue(),
|
||||
subKey2, null);
|
||||
} else if (subKey2.equals("InprocServer32")) {
|
||||
comInfo.inprocServer32 = (String) Advapi32Util
|
||||
.registryGetValue(phkResult2.getValue(),
|
||||
subKey2, null);
|
||||
} else if (subKey2.equals("LocalServer32")) {
|
||||
comInfo.localServer32 = (String) Advapi32Util
|
||||
.registryGetValue(phkResult2.getValue(),
|
||||
subKey2, null);
|
||||
} else if (subKey2.equals("ProgID")) {
|
||||
comInfo.progID = (String) Advapi32Util
|
||||
.registryGetValue(phkResult2.getValue(),
|
||||
subKey2, null);
|
||||
} else if (subKey2.equals("TypeLib")) {
|
||||
comInfo.typeLib = (String) Advapi32Util
|
||||
.registryGetValue(phkResult2.getValue(),
|
||||
subKey2, null);
|
||||
}
|
||||
}
|
||||
|
||||
Advapi32.INSTANCE.RegCloseKey(phkResult2.getValue());
|
||||
comInfos.add(comInfo);
|
||||
}
|
||||
} finally {
|
||||
Advapi32.INSTANCE.RegCloseKey(phkResult.getValue());
|
||||
Advapi32.INSTANCE.RegCloseKey(phkResult2.getValue());
|
||||
}
|
||||
|
||||
return comInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class COMInfo.
|
||||
*
|
||||
* @author wolf.tobias@gmx.net The Class COMInfo.
|
||||
*/
|
||||
public static class COMInfo {
|
||||
|
||||
/** The clsid. */
|
||||
public String clsid;
|
||||
|
||||
/** The inproc handler32. */
|
||||
public String inprocHandler32;
|
||||
|
||||
/** The inproc server32. */
|
||||
public String inprocServer32;
|
||||
|
||||
/** The local server32. */
|
||||
public String localServer32;
|
||||
|
||||
/** The prog id. */
|
||||
public String progID;
|
||||
|
||||
/** The type lib. */
|
||||
public String typeLib;
|
||||
|
||||
/**
|
||||
* Instantiates a new cOM info.
|
||||
*/
|
||||
public COMInfo() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new cOM info.
|
||||
*
|
||||
* @param clsid
|
||||
* the clsid
|
||||
*/
|
||||
public COMInfo(String clsid) {
|
||||
this.clsid = clsid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.IID;
|
||||
import com.sun.jna.platform.win32.OaIdl.DISPID;
|
||||
import com.sun.jna.platform.win32.OaIdl.DISPIDByReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WinDef.LCID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.UINTByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the IDispatch interface
|
||||
*
|
||||
* IDispatch.GetTypeInfoCount 12 IDispatch.GetTypeInfo 16
|
||||
* IDispatch.GetIDsOfNames 20 IDispatch.Invoke 24
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class Dispatch extends Unknown implements IDispatch {
|
||||
|
||||
public static class ByReference extends Dispatch implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
public Dispatch() {
|
||||
}
|
||||
|
||||
public Dispatch(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info count.
|
||||
*
|
||||
* @param pctinfo
|
||||
* the pctinfo
|
||||
* @return the hresult
|
||||
*
|
||||
* Virtual
|
||||
*/
|
||||
public HRESULT GetTypeInfoCount(UINTByReference pctinfo) {
|
||||
return (HRESULT) this._invokeNativeObject(3,
|
||||
new Object[] { this.getPointer(), pctinfo }, HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info.
|
||||
*
|
||||
* @param iTInfo
|
||||
* the i t info
|
||||
* @param lcid
|
||||
* the lcid
|
||||
* @param ppTInfo
|
||||
* the pp t info
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetTypeInfo(UINT iTInfo, LCID lcid,
|
||||
PointerByReference ppTInfo) {
|
||||
return (HRESULT) this._invokeNativeObject(4,
|
||||
new Object[] { this.getPointer(), iTInfo, lcid, ppTInfo },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ids of names.
|
||||
*
|
||||
* @param riid
|
||||
* the riid
|
||||
* @param rgszNames
|
||||
* the rgsz names
|
||||
* @param cNames
|
||||
* the c names
|
||||
* @param lcid
|
||||
* the lcid
|
||||
* @param rgDispId
|
||||
* the rg disp id
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetIDsOfNames(IID riid, WString[] rgszNames, int cNames,
|
||||
LCID lcid, DISPIDByReference rgDispId) {
|
||||
return (HRESULT) this._invokeNativeObject(5,
|
||||
new Object[] { this.getPointer(), riid, rgszNames, cNames,
|
||||
lcid, rgDispId }, HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke.
|
||||
*
|
||||
* @param dispIdMember
|
||||
* the disp id member
|
||||
* @param riid
|
||||
* the riid
|
||||
* @param lcid
|
||||
* the lcid
|
||||
* @param wFlags
|
||||
* the w flags
|
||||
* @param pDispParams
|
||||
* the disp params
|
||||
* @param pVarResult
|
||||
* the var result
|
||||
* @param pExcepInfo
|
||||
* the excep info
|
||||
* @param puArgErr
|
||||
* the pu arg err
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT Invoke(DISPID dispIdMember, IID riid, LCID lcid,
|
||||
DISPID wFlags, DISPPARAMS pDispParams,
|
||||
VARIANT.ByReference pVarResult, EXCEPINFO.ByReference pExcepInfo,
|
||||
IntByReference puArgErr) {
|
||||
return (HRESULT) this
|
||||
._invokeNativeObject(6, new Object[] { this.getPointer(),
|
||||
dispIdMember, riid, lcid, wFlags, pDispParams,
|
||||
pVarResult, pExcepInfo, puArgErr }, HRESULT.class);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.IID;
|
||||
import com.sun.jna.platform.win32.OaIdl.DISPID;
|
||||
import com.sun.jna.platform.win32.OaIdl.DISPIDByReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WinDef.LCID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.UINTByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the IDispatch interface
|
||||
*
|
||||
* IDispatch.GetTypeInfoCount 12 IDispatch.GetTypeInfo 16
|
||||
* IDispatch.GetIDsOfNames 20 IDispatch.Invoke 24
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public interface IDispatch extends IUnknown {
|
||||
|
||||
public final static IID IID_IDISPATCH = new IID(
|
||||
"00020400-0000-0000-C000-000000000046");
|
||||
|
||||
public HRESULT GetTypeInfoCount(UINTByReference pctinfo);
|
||||
|
||||
public HRESULT GetTypeInfo(UINT iTInfo, LCID lcid,
|
||||
PointerByReference ppTInfo);
|
||||
|
||||
public HRESULT GetIDsOfNames(IID riid, WString[] rgszNames, int cNames,
|
||||
LCID lcid, DISPIDByReference rgDispId);
|
||||
|
||||
public HRESULT Invoke(DISPID dispIdMember, IID riid, LCID lcid,
|
||||
DISPID wFlags, DISPPARAMS pDispParams,
|
||||
VARIANT.ByReference pVarResult, EXCEPINFO.ByReference pExcepInfo,
|
||||
IntByReference puArgErr);
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.Guid.IID;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WinDef.BOOL;
|
||||
import com.sun.jna.platform.win32.WinDef.PVOID;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONG;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the IRecordInfo interface.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public interface IRecordInfo extends IUnknown {
|
||||
|
||||
public final static IID IID_IRecordInfo = new IID(
|
||||
"{0000002F-0000-0000-C000-000000000046}");
|
||||
|
||||
public HRESULT RecordInit(/* [out] */PVOID pvNew);
|
||||
|
||||
public HRESULT RecordClear(
|
||||
/* [in] */PVOID pvExisting);
|
||||
|
||||
public HRESULT RecordCopy(/* [in] */PVOID pvExisting,
|
||||
/* [out] */PVOID pvNew);
|
||||
|
||||
public HRESULT GetGuid(
|
||||
/* [out] */GUID pguid);
|
||||
|
||||
public HRESULT GetName(
|
||||
/* [out] */BSTR pbstrName);
|
||||
|
||||
public HRESULT GetSize(
|
||||
/* [out] */ULONG pcbSize);
|
||||
|
||||
public HRESULT GetTypeInfo(
|
||||
/* [out] */ITypeInfo ppTypeInfo);
|
||||
|
||||
public HRESULT GetField(
|
||||
/* [in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [out] */VARIANT pvarField);
|
||||
|
||||
public HRESULT GetFieldNoCopy(
|
||||
/* [in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [out] */VARIANT pvarField,
|
||||
/* [out] */PVOID ppvDataCArray);
|
||||
|
||||
public HRESULT PutField(
|
||||
/* [in] */ULONG wFlags,
|
||||
/* [out][in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [in] */VARIANT pvarField);
|
||||
|
||||
public HRESULT PutFieldNoCopy(
|
||||
/* [in] */ULONG wFlags,
|
||||
/* [out][in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [in] */VARIANT pvarField);
|
||||
|
||||
public HRESULT GetFieldNames(
|
||||
/* [out][in] */ULONG pcNames,
|
||||
/* [length_is][size_is][out] */BSTR rgBstrNames);
|
||||
|
||||
public BOOL IsMatchingType(
|
||||
/* [in] */IRecordInfo pRecordInfo);
|
||||
|
||||
public PVOID RecordCreate();
|
||||
|
||||
public HRESULT RecordCreateCopy(
|
||||
/* [in] */PVOID pvSource,
|
||||
/* [out] */PVOID ppvDest);
|
||||
|
||||
public HRESULT RecordDestroy(
|
||||
/* [in] */PVOID pvRecord);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.OaIdl.BINDPTR;
|
||||
import com.sun.jna.platform.win32.OaIdl.DESCKIND;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONG;
|
||||
import com.sun.jna.platform.win32.WinDef.WORD;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the ITypeComp interface.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public interface ITypeComp extends IUnknown {
|
||||
|
||||
public HRESULT Bind(
|
||||
/* [annotation][in] */
|
||||
WString szName,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [in] */WORD wFlags,
|
||||
/* [out] */PointerByReference ppTInfo,
|
||||
/* [out] */DESCKIND.ByReference pDescKind,
|
||||
/* [out] */BINDPTR.ByReference pBindPtr);
|
||||
|
||||
public HRESULT BindType(
|
||||
/* [annotation][in] */
|
||||
WString szName,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [out] */PointerByReference ppTInfo,
|
||||
/* [out] */PointerByReference ppTComp);
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.platform.win32.Guid.REFIID;
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPE;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPEByReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPEByReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.INVOKEKIND;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEATTR;
|
||||
import com.sun.jna.platform.win32.OaIdl.VARDESC;
|
||||
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTRByReference;
|
||||
import com.sun.jna.platform.win32.WTypes.LPOLESTR;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORDByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.PVOID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.UINTByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.WORD;
|
||||
import com.sun.jna.platform.win32.WinDef.WORDByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the ITypeInfo interface.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public interface ITypeInfo extends IUnknown {
|
||||
|
||||
public HRESULT GetTypeAttr(
|
||||
/* [out] */PointerByReference ppTypeAttr);
|
||||
|
||||
public HRESULT GetTypeComp(
|
||||
/* [out] */PointerByReference ppTComp);
|
||||
|
||||
public/* [local] */HRESULT GetFuncDesc(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */PointerByReference ppFuncDesc);
|
||||
|
||||
public/* [local] */HRESULT GetVarDesc(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */PointerByReference ppVarDesc);
|
||||
|
||||
public/* [local] */HRESULT GetNames(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [length_is][size_is][out] */BSTR[] rgBstrNames,
|
||||
/* [in] */UINT cMaxNames,
|
||||
/* [out] */UINTByReference pcNames);
|
||||
|
||||
public HRESULT GetRefTypeOfImplType(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */HREFTYPEByReference pRefType);
|
||||
|
||||
public HRESULT GetImplTypeFlags(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */IntByReference pImplTypeFlags);
|
||||
|
||||
public/* [local] */HRESULT GetIDsOfNames(
|
||||
/* [size_is][in] */LPOLESTR[] rgszNames,
|
||||
/* [in] */UINT cNames,
|
||||
/* [size_is][out] */MEMBERID[] pMemId);
|
||||
|
||||
public/* [local] */HRESULT Invoke(
|
||||
/* [in] */PVOID pvInstance,
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [in] */WORD wFlags,
|
||||
/* [out][in] */DISPPARAMS.ByReference pDispParams,
|
||||
/* [out] */VARIANT.ByReference pVarResult,
|
||||
/* [out] */EXCEPINFO.ByReference pExcepInfo,
|
||||
/* [out] */UINTByReference puArgErr);
|
||||
|
||||
public/* [local] */HRESULT GetDocumentation(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [out] */BSTRByReference pBstrName,
|
||||
/* [out] */BSTRByReference pBstrDocString,
|
||||
/* [out] */DWORDByReference pdwHelpContext,
|
||||
/* [out] */BSTRByReference pBstrHelpFile);
|
||||
|
||||
public/* [local] */HRESULT GetDllEntry(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [in] */INVOKEKIND invKind,
|
||||
/* [out] */BSTRByReference pBstrDllName,
|
||||
/* [out] */BSTRByReference pBstrName,
|
||||
/* [out] */WORDByReference pwOrdinal);
|
||||
|
||||
public HRESULT GetRefTypeInfo(
|
||||
/* [in] */HREFTYPE hRefType,
|
||||
/* [out] */PointerByReference ppTInfo);
|
||||
|
||||
public/* [local] */HRESULT AddressOfMember(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [in] */INVOKEKIND invKind,
|
||||
/* [out] */PointerByReference ppv);
|
||||
|
||||
public/* [local] */HRESULT CreateInstance(
|
||||
/* [in] */IUnknown pUnkOuter,
|
||||
/* [in] */REFIID riid,
|
||||
/* [iid_is][out] */PointerByReference ppvObj);
|
||||
|
||||
public HRESULT GetMops(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [out] */BSTRByReference pBstrMops);
|
||||
|
||||
public/* [local] */HRESULT GetContainingTypeLib(
|
||||
/* [out] */PointerByReference ppTLib,
|
||||
/* [out] */UINTByReference pIndex);
|
||||
|
||||
public/* [local] */void ReleaseTypeAttr(
|
||||
/* [in] */TYPEATTR pTypeAttr);
|
||||
|
||||
public/* [local] */void ReleaseFuncDesc(
|
||||
/* [in] */FUNCDESC pFuncDesc);
|
||||
|
||||
public/* [local] */void ReleaseVarDesc(
|
||||
/* [in] */VARDESC pVarDesc);
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.TLIBATTR;
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEKIND;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTRByReference;
|
||||
import com.sun.jna.platform.win32.WTypes.LPOLESTR;
|
||||
import com.sun.jna.platform.win32.WinDef.BOOLByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORDByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONG;
|
||||
import com.sun.jna.platform.win32.WinDef.USHORTByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the ITypeLib interface.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public interface ITypeLib extends IUnknown {
|
||||
|
||||
public UINT GetTypeInfoCount();
|
||||
|
||||
public HRESULT GetTypeInfo(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */PointerByReference pTInfo);
|
||||
|
||||
public HRESULT GetTypeInfoType(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */TYPEKIND.ByReference pTKind);
|
||||
|
||||
public HRESULT GetTypeInfoOfGuid(
|
||||
/* [in] */GUID guid,
|
||||
/* [out] */PointerByReference pTinfo);
|
||||
|
||||
public HRESULT GetLibAttr(
|
||||
/* [out] */PointerByReference ppTLibAttr);
|
||||
|
||||
public HRESULT GetTypeComp(
|
||||
/* [out] */PointerByReference ppTComp);
|
||||
|
||||
public HRESULT GetDocumentation(
|
||||
/* [in] */int index,
|
||||
/* [out] */BSTRByReference pBstrName,
|
||||
/* [out] */BSTRByReference pBstrDocString,
|
||||
/* [out] */DWORDByReference pdwHelpContext,
|
||||
/* [out] */BSTRByReference pBstrHelpFile);
|
||||
|
||||
public HRESULT IsName(
|
||||
/* [annotation][out][in] */
|
||||
LPOLESTR szNameBuf,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [out] */BOOLByReference pfName);
|
||||
|
||||
public HRESULT FindName(
|
||||
/* [annotation][out][in] */
|
||||
BSTRByReference szNameBuf,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [length_is][size_is][out] */ITypeInfo[] ppTInfo,
|
||||
/* [length_is][size_is][out] */MEMBERID[] rgMemId,
|
||||
/* [out][in] */USHORTByReference pcFound);
|
||||
|
||||
public void ReleaseTLibAttr(/* [in] */TLIBATTR pTLibAttr);
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.platform.win32.Guid.IID;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the ITypeInfo interface
|
||||
*
|
||||
* Method Name V-Table Offset IUnknown.QueryInterface 0 IUnknown.AddRef 4
|
||||
* IUnknown.Release 8
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public interface IUnknown {
|
||||
|
||||
/** The Constant IID_IDispatch. */
|
||||
public final static IID IID_IUNKNOWN = new IID(
|
||||
"{00000000-0000-0000-C000-000000000046}");
|
||||
|
||||
public HRESULT QueryInterface(IID riid, PointerByReference ppvObject);
|
||||
|
||||
public int AddRef();
|
||||
|
||||
public int Release();
|
||||
}
|
||||
@@ -1,283 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WinDef.BOOL;
|
||||
import com.sun.jna.platform.win32.WinDef.PVOID;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONG;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the IRecordInfo interface.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class RecordInfo extends Unknown implements IRecordInfo {
|
||||
|
||||
public static class ByReference extends RecordInfo implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new i record info.
|
||||
*/
|
||||
public RecordInfo() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new i record info.
|
||||
*
|
||||
* @param pvInstance
|
||||
* the pv instance
|
||||
*/
|
||||
public RecordInfo(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Record init.
|
||||
*
|
||||
* @param pvNew
|
||||
* the pv new
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT RecordInit(/* [out] */PVOID pvNew) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record clear.
|
||||
*
|
||||
* @param pvExisting
|
||||
* the pv existing
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT RecordClear(
|
||||
/* [in] */PVOID pvExisting) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record copy.
|
||||
*
|
||||
* @param pvExisting
|
||||
* the pv existing
|
||||
* @param pvNew
|
||||
* the pv new
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT RecordCopy(
|
||||
/* [in] */PVOID pvExisting,
|
||||
/* [out] */PVOID pvNew) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the guid.
|
||||
*
|
||||
* @param pguid
|
||||
* the pguid
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetGuid(
|
||||
/* [out] */GUID pguid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @param pbstrName
|
||||
* the pbstr name
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetName(
|
||||
/* [out] */BSTR pbstrName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the size.
|
||||
*
|
||||
* @param pcbSize
|
||||
* the pcb size
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetSize(
|
||||
/* [out] */ULONG pcbSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info.
|
||||
*
|
||||
* @param ppTypeInfo
|
||||
* the pp type info
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetTypeInfo(
|
||||
/* [out] */ITypeInfo ppTypeInfo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field.
|
||||
*
|
||||
* @param pvData
|
||||
* the pv data
|
||||
* @param szFieldName
|
||||
* the sz field name
|
||||
* @param pvarField
|
||||
* the pvar field
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetField(
|
||||
/* [in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [out] */VARIANT pvarField) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field no copy.
|
||||
*
|
||||
* @param pvData
|
||||
* the pv data
|
||||
* @param szFieldName
|
||||
* the sz field name
|
||||
* @param pvarField
|
||||
* the pvar field
|
||||
* @param ppvDataCArray
|
||||
* the ppv data c array
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetFieldNoCopy(
|
||||
/* [in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [out] */VARIANT pvarField,
|
||||
/* [out] */PVOID ppvDataCArray) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put field.
|
||||
*
|
||||
* @param wFlags
|
||||
* the w flags
|
||||
* @param pvData
|
||||
* the pv data
|
||||
* @param szFieldName
|
||||
* the sz field name
|
||||
* @param pvarField
|
||||
* the pvar field
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT PutField(
|
||||
/* [in] */ULONG wFlags,
|
||||
/* [out][in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [in] */VARIANT pvarField) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put field no copy.
|
||||
*
|
||||
* @param wFlags
|
||||
* the w flags
|
||||
* @param pvData
|
||||
* the pv data
|
||||
* @param szFieldName
|
||||
* the sz field name
|
||||
* @param pvarField
|
||||
* the pvar field
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT PutFieldNoCopy(
|
||||
/* [in] */ULONG wFlags,
|
||||
/* [out][in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [in] */VARIANT pvarField) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field names.
|
||||
*
|
||||
* @param pcNames
|
||||
* the pc names
|
||||
* @param rgBstrNames
|
||||
* the rg bstr names
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetFieldNames(
|
||||
/* [out][in] */ULONG pcNames,
|
||||
/* [length_is][size_is][out] */BSTR rgBstrNames) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is matching type.
|
||||
*
|
||||
* @param pRecordInfo
|
||||
* the record info
|
||||
* @return the bool
|
||||
*/
|
||||
public BOOL IsMatchingType(
|
||||
/* [in] */IRecordInfo pRecordInfo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record create.
|
||||
*
|
||||
* @return the pvoid
|
||||
*/
|
||||
public PVOID RecordCreate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record create copy.
|
||||
*
|
||||
* @param pvSource
|
||||
* the pv source
|
||||
* @param ppvDest
|
||||
* the ppv dest
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT RecordCreateCopy(
|
||||
/* [in] */PVOID pvSource,
|
||||
/* [out] */PVOID ppvDest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record destroy.
|
||||
*
|
||||
* @param pvRecord
|
||||
* the pv record
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT RecordDestroy(
|
||||
/* [in] */PVOID pvRecord) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.OaIdl.BINDPTR;
|
||||
import com.sun.jna.platform.win32.OaIdl.DESCKIND;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONG;
|
||||
import com.sun.jna.platform.win32.WinDef.WORD;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the ITypeComp interface.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TypeComp extends Unknown {
|
||||
|
||||
public static class ByReference extends TypeComp implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new i type comp.
|
||||
*/
|
||||
public TypeComp() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new i type comp.
|
||||
*
|
||||
* @param pvInstance
|
||||
* the pv instance
|
||||
*/
|
||||
public TypeComp(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind.
|
||||
*
|
||||
* @param szName
|
||||
* the sz name
|
||||
* @param lHashVal
|
||||
* the l hash val
|
||||
* @param wFlags
|
||||
* the w flags
|
||||
* @param ppTInfo
|
||||
* the pp t info
|
||||
* @param pDescKind
|
||||
* the desc kind
|
||||
* @param pBindPtr
|
||||
* the bind ptr
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT Bind(
|
||||
/* [annotation][in] */
|
||||
WString szName,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [in] */WORD wFlags,
|
||||
/* [out] */PointerByReference ppTInfo,
|
||||
/* [out] */DESCKIND.ByReference pDescKind,
|
||||
/* [out] */BINDPTR.ByReference pBindPtr) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(3,
|
||||
new Object[] { this.getPointer(), szName, lHashVal, wFlags,
|
||||
ppTInfo, pDescKind, pBindPtr }, HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind type.
|
||||
*
|
||||
* @param szName
|
||||
* the sz name
|
||||
* @param lHashVal
|
||||
* the l hash val
|
||||
* @param ppTInfo
|
||||
* the pp t info
|
||||
* @param ppTComp
|
||||
* the pp t comp
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT BindType(
|
||||
/* [annotation][in] */
|
||||
WString szName,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [out] */PointerByReference ppTInfo,
|
||||
/* [out] */PointerByReference ppTComp) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(4,
|
||||
new Object[] { this.getPointer(), szName, lHashVal, ppTInfo,
|
||||
ppTComp }, HRESULT.class);
|
||||
}
|
||||
}
|
||||
@@ -1,431 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.Guid.REFIID;
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPE;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPEByReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.INVOKEKIND;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEATTR;
|
||||
import com.sun.jna.platform.win32.OaIdl.VARDESC;
|
||||
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTRByReference;
|
||||
import com.sun.jna.platform.win32.WTypes.LPOLESTR;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORDByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.PVOID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.UINTByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.WORD;
|
||||
import com.sun.jna.platform.win32.WinDef.WORDByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the ITypeInfo interface.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TypeInfo extends Unknown implements ITypeInfo {
|
||||
|
||||
public static class ByReference extends TypeInfo implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new i type info.
|
||||
*/
|
||||
public TypeInfo() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new i type info.
|
||||
*
|
||||
* @param pvInstance
|
||||
* the pv instance
|
||||
*/
|
||||
public TypeInfo(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type attr.
|
||||
*
|
||||
* @param ppTypeAttr
|
||||
* the pp type attr
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetTypeAttr(
|
||||
/* [out] */PointerByReference ppTypeAttr) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(3,
|
||||
new Object[] { this.getPointer(), ppTypeAttr }, HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type comp.
|
||||
*
|
||||
* @param ppTComp
|
||||
* the pp t comp
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetTypeComp(
|
||||
/* [out] */PointerByReference ppTComp) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(4,
|
||||
new Object[] { this.getPointer(), ppTComp }, HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the func desc.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param ppFuncDesc
|
||||
* the pp func desc
|
||||
* @return the hresult
|
||||
*/
|
||||
public/* [local] */HRESULT GetFuncDesc(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */PointerByReference ppFuncDesc) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(5,
|
||||
new Object[] { this.getPointer(), index, ppFuncDesc },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the var desc.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param ppVarDesc
|
||||
* the pp var desc
|
||||
* @return the hresult
|
||||
*/
|
||||
public/* [local] */HRESULT GetVarDesc(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */PointerByReference ppVarDesc) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(6,
|
||||
new Object[] { this.getPointer(), index, ppVarDesc },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the names.
|
||||
*
|
||||
* @param memid
|
||||
* the memid
|
||||
* @param rgBstrNames
|
||||
* the rg bstr names
|
||||
* @param cMaxNames
|
||||
* the c max names
|
||||
* @param pcNames
|
||||
* the pc names
|
||||
* @return the hresult
|
||||
*/
|
||||
public/* [local] */HRESULT GetNames(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [length_is][size_is][out] */BSTR[] rgBstrNames,
|
||||
/* [in] */UINT cMaxNames,
|
||||
/* [out] */UINTByReference pcNames) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(7,
|
||||
new Object[] { this.getPointer(), memid, rgBstrNames,
|
||||
cMaxNames, pcNames }, HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ref type of impl type.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param pRefType
|
||||
* the ref type
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetRefTypeOfImplType(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */HREFTYPEByReference pRefType) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(8,
|
||||
new Object[] { this.getPointer(), index, pRefType },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the impl type flags.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param pImplTypeFlags
|
||||
* the impl type flags
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetImplTypeFlags(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */IntByReference pImplTypeFlags) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(9,
|
||||
new Object[] { this.getPointer(), index, pImplTypeFlags },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the i ds of names.
|
||||
*
|
||||
* @param rgszNames
|
||||
* the rgsz names
|
||||
* @param cNames
|
||||
* the c names
|
||||
* @param pMemId
|
||||
* the mem id
|
||||
* @return the hresult
|
||||
*/
|
||||
public/* [local] */HRESULT GetIDsOfNames(
|
||||
/* [size_is][in] */LPOLESTR[] rgszNames,
|
||||
/* [in] */UINT cNames,
|
||||
/* [size_is][out] */MEMBERID[] pMemId) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(10,
|
||||
new Object[] { this.getPointer(), rgszNames, cNames, pMemId },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke.
|
||||
*
|
||||
* @param pvInstance
|
||||
* the pv instance
|
||||
* @param memid
|
||||
* the memid
|
||||
* @param wFlags
|
||||
* the w flags
|
||||
* @param pDispParams
|
||||
* the disp params
|
||||
* @param pVarResult
|
||||
* the var result
|
||||
* @param pExcepInfo
|
||||
* the excep info
|
||||
* @param puArgErr
|
||||
* the pu arg err
|
||||
* @return the hresult
|
||||
*/
|
||||
public/* [local] */HRESULT Invoke(
|
||||
/* [in] */PVOID pvInstance,
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [in] */WORD wFlags,
|
||||
/* [out][in] */DISPPARAMS.ByReference pDispParams,
|
||||
/* [out] */VARIANT.ByReference pVarResult,
|
||||
/* [out] */EXCEPINFO.ByReference pExcepInfo,
|
||||
/* [out] */UINTByReference puArgErr) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(11,
|
||||
new Object[] { this.getPointer(), pvInstance, memid, wFlags,
|
||||
pDispParams, pVarResult, pExcepInfo, puArgErr },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the documentation.
|
||||
*
|
||||
* @param memid
|
||||
* the memid
|
||||
* @param pBstrName
|
||||
* the bstr name
|
||||
* @param pBstrDocString
|
||||
* the bstr doc string
|
||||
* @param pdwHelpContext
|
||||
* the pdw help context
|
||||
* @param pBstrHelpFile
|
||||
* the bstr help file
|
||||
* @return the hresult
|
||||
*/
|
||||
public/* [local] */HRESULT GetDocumentation(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [out] */BSTRByReference pBstrName,
|
||||
/* [out] */BSTRByReference pBstrDocString,
|
||||
/* [out] */DWORDByReference pdwHelpContext,
|
||||
/* [out] */BSTRByReference pBstrHelpFile) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(12,
|
||||
new Object[] { this.getPointer(), memid, pBstrName,
|
||||
pBstrDocString, pdwHelpContext, pBstrHelpFile },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dll entry.
|
||||
*
|
||||
* @param memid
|
||||
* the memid
|
||||
* @param invKind
|
||||
* the inv kind
|
||||
* @param pBstrDllName
|
||||
* the bstr dll name
|
||||
* @param pBstrName
|
||||
* the bstr name
|
||||
* @param pwOrdinal
|
||||
* the pw ordinal
|
||||
* @return the hresult
|
||||
*/
|
||||
public/* [local] */HRESULT GetDllEntry(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [in] */INVOKEKIND invKind,
|
||||
/* [out] */BSTRByReference pBstrDllName,
|
||||
/* [out] */BSTRByReference pBstrName,
|
||||
/* [out] */WORDByReference pwOrdinal) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(13,
|
||||
new Object[] { this.getPointer(), memid, invKind, pBstrDllName,
|
||||
pBstrName, pwOrdinal }, HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ref type info.
|
||||
*
|
||||
* @param hRefType
|
||||
* the h ref type
|
||||
* @param ppTInfo
|
||||
* the pp t info
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetRefTypeInfo(
|
||||
/* [in] */HREFTYPE hRefType,
|
||||
/* [out] */PointerByReference ppTInfo) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(14,
|
||||
new Object[] { this.getPointer(), hRefType, ppTInfo },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Address of member.
|
||||
*
|
||||
* @param memid
|
||||
* the memid
|
||||
* @param invKind
|
||||
* the inv kind
|
||||
* @param ppv
|
||||
* the ppv
|
||||
* @return the hresult
|
||||
*/
|
||||
public/* [local] */HRESULT AddressOfMember(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [in] */INVOKEKIND invKind,
|
||||
/* [out] */PointerByReference ppv) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(15,
|
||||
new Object[] { this.getPointer(), memid, invKind, ppv },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the instance.
|
||||
*
|
||||
* @param pUnkOuter
|
||||
* the unk outer
|
||||
* @param riid
|
||||
* the riid
|
||||
* @param ppvObj
|
||||
* the ppv obj
|
||||
* @return the hresult
|
||||
*/
|
||||
public/* [local] */HRESULT CreateInstance(
|
||||
/* [in] */IUnknown pUnkOuter,
|
||||
/* [in] */REFIID riid,
|
||||
/* [iid_is][out] */PointerByReference ppvObj) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(16,
|
||||
new Object[] { this.getPointer(), pUnkOuter, riid, ppvObj },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mops.
|
||||
*
|
||||
* @param memid
|
||||
* the memid
|
||||
* @param pBstrMops
|
||||
* the bstr mops
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetMops(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [out] */BSTRByReference pBstrMops) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(17,
|
||||
new Object[] { this.getPointer(), memid, pBstrMops },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the containing type lib.
|
||||
*
|
||||
* @param ppTLib
|
||||
* the pp t lib
|
||||
* @param pIndex
|
||||
* the index
|
||||
* @return the hresult
|
||||
*/
|
||||
public/* [local] */HRESULT GetContainingTypeLib(
|
||||
/* [out] */PointerByReference ppTLib,
|
||||
/* [out] */UINTByReference pIndex) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(18,
|
||||
new Object[] { this.getPointer(), ppTLib, pIndex },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release type attr.
|
||||
*
|
||||
* @param pTypeAttr
|
||||
* the type attr
|
||||
*/
|
||||
public/* [local] */void ReleaseTypeAttr(
|
||||
/* [in] */TYPEATTR pTypeAttr) {
|
||||
this._invokeNativeVoid(19, new Object[] { this.getPointer(), pTypeAttr });
|
||||
}
|
||||
|
||||
/**
|
||||
* Release func desc.
|
||||
*
|
||||
* @param pFuncDesc
|
||||
* the func desc
|
||||
*/
|
||||
public/* [local] */void ReleaseFuncDesc(
|
||||
/* [in] */FUNCDESC pFuncDesc) {
|
||||
this._invokeNativeVoid(20, new Object[] { this.getPointer(), pFuncDesc });
|
||||
}
|
||||
|
||||
/**
|
||||
* Release var desc.
|
||||
*
|
||||
* @param pVarDesc
|
||||
* the var desc
|
||||
*/
|
||||
public/* [local] */void ReleaseVarDesc(
|
||||
/* [in] */VARDESC pVarDesc) {
|
||||
this._invokeNativeVoid(21, new Object[] { this.getPointer(), pVarDesc });
|
||||
}
|
||||
}
|
||||
@@ -1,681 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.platform.win32.Guid.REFIID;
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPE;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPEByReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.INVOKEKIND;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEATTR;
|
||||
import com.sun.jna.platform.win32.OaIdl.VARDESC;
|
||||
import com.sun.jna.platform.win32.OleAuto;
|
||||
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTRByReference;
|
||||
import com.sun.jna.platform.win32.WTypes.LPOLESTR;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORDByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.PVOID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.UINTByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.WORD;
|
||||
import com.sun.jna.platform.win32.WinDef.WORDByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ITypeInfoUtil.
|
||||
*
|
||||
* @author wolf.tobias@gmx.net The Class ITypeInfoUtil.
|
||||
*/
|
||||
public class TypeInfoUtil {
|
||||
|
||||
/** The Constant OLEAUTO. */
|
||||
public final static OleAuto OLEAUTO = OleAuto.INSTANCE;
|
||||
|
||||
/** The type info. */
|
||||
private ITypeInfo typeInfo;
|
||||
|
||||
/**
|
||||
* Instantiates a new i type info util.
|
||||
*
|
||||
* @param typeInfo
|
||||
* the type info
|
||||
*/
|
||||
public TypeInfoUtil(ITypeInfo typeInfo) {
|
||||
this.typeInfo = typeInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type attr.
|
||||
*
|
||||
* @return the type attr
|
||||
*/
|
||||
public TYPEATTR getTypeAttr() {
|
||||
PointerByReference ppTypeAttr = new PointerByReference();
|
||||
HRESULT hr = this.typeInfo.GetTypeAttr(ppTypeAttr);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return new TYPEATTR(ppTypeAttr.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type comp.
|
||||
*
|
||||
* @return the type comp
|
||||
*/
|
||||
public TypeComp getTypeComp() {
|
||||
PointerByReference ppTypeAttr = new PointerByReference();
|
||||
HRESULT hr = this.typeInfo.GetTypeComp(ppTypeAttr);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return new TypeComp(ppTypeAttr.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the func desc.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @return the func desc
|
||||
*/
|
||||
public FUNCDESC getFuncDesc(int index) {
|
||||
PointerByReference ppFuncDesc = new PointerByReference();
|
||||
HRESULT hr = this.typeInfo.GetFuncDesc(new UINT(index), ppFuncDesc);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return new FUNCDESC(ppFuncDesc.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the var desc.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @return the var desc
|
||||
*/
|
||||
public VARDESC getVarDesc(int index) {
|
||||
PointerByReference ppVarDesc = new PointerByReference();
|
||||
HRESULT hr = this.typeInfo.GetVarDesc(new UINT(index), ppVarDesc);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return new VARDESC(ppVarDesc.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the names.
|
||||
*
|
||||
* @param memid
|
||||
* the memid
|
||||
* @param maxNames
|
||||
* the max names
|
||||
* @return the names
|
||||
*/
|
||||
public String[] getNames(MEMBERID memid, int maxNames) {
|
||||
BSTR[] rgBstrNames = new BSTR[maxNames];
|
||||
UINTByReference pcNames = new UINTByReference();
|
||||
HRESULT hr = this.typeInfo.GetNames(memid, rgBstrNames, new UINT(
|
||||
maxNames), pcNames);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
int cNames = pcNames.getValue().intValue();
|
||||
String[] result = new String[cNames];
|
||||
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = rgBstrNames[i].getValue();
|
||||
OLEAUTO.SysFreeString(rgBstrNames[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ref type of impl type.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @return the ref type of impl type
|
||||
*/
|
||||
public HREFTYPE getRefTypeOfImplType(int index) {
|
||||
HREFTYPEByReference ppTInfo = new HREFTYPEByReference();
|
||||
HRESULT hr = this.typeInfo.GetRefTypeOfImplType(new UINT(index),
|
||||
ppTInfo);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return ppTInfo.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the impl type flags.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @return the impl type flags
|
||||
*/
|
||||
public int getImplTypeFlags(int index) {
|
||||
IntByReference pImplTypeFlags = new IntByReference();
|
||||
HRESULT hr = this.typeInfo.GetImplTypeFlags(new UINT(index),
|
||||
pImplTypeFlags);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return pImplTypeFlags.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the i ds of names.
|
||||
*
|
||||
* @param rgszNames
|
||||
* the rgsz names
|
||||
* @param cNames
|
||||
* the c names
|
||||
* @return the i ds of names
|
||||
*/
|
||||
public MEMBERID[] getIDsOfNames(LPOLESTR[] rgszNames, int cNames) {
|
||||
MEMBERID[] pMemId = new MEMBERID[cNames];
|
||||
HRESULT hr = this.typeInfo.GetIDsOfNames(rgszNames, new UINT(cNames),
|
||||
pMemId);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return pMemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke.
|
||||
*
|
||||
* @param pvInstance
|
||||
* the pv instance
|
||||
* @param memid
|
||||
* the memid
|
||||
* @param wFlags
|
||||
* the w flags
|
||||
* @param pDispParams
|
||||
* the disp params
|
||||
* @return the invoke
|
||||
*/
|
||||
public Invoke Invoke(PVOID pvInstance, MEMBERID memid, WORD wFlags,
|
||||
DISPPARAMS.ByReference pDispParams) {
|
||||
|
||||
VARIANT.ByReference pVarResult = new VARIANT.ByReference();
|
||||
EXCEPINFO.ByReference pExcepInfo = new EXCEPINFO.ByReference();
|
||||
UINTByReference puArgErr = new UINTByReference();
|
||||
|
||||
HRESULT hr = this.typeInfo.Invoke(pvInstance, memid, wFlags,
|
||||
pDispParams, pVarResult, pExcepInfo, puArgErr);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return new Invoke(pVarResult, pExcepInfo, puArgErr.getValue()
|
||||
.intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class Invoke.
|
||||
*
|
||||
* @author wolf.tobias@gmx.net The Class Invoke.
|
||||
*/
|
||||
public static class Invoke {
|
||||
|
||||
/** The p var result. */
|
||||
private VARIANT.ByReference pVarResult;
|
||||
|
||||
/** The p excep info. */
|
||||
private EXCEPINFO.ByReference pExcepInfo;
|
||||
|
||||
/** The pu arg err. */
|
||||
private int puArgErr;
|
||||
|
||||
/**
|
||||
* Instantiates a new invoke.
|
||||
*
|
||||
* @param pVarResult
|
||||
* the var result
|
||||
* @param pExcepInfo
|
||||
* the excep info
|
||||
* @param puArgErr
|
||||
* the pu arg err
|
||||
*/
|
||||
public Invoke(VARIANT.ByReference pVarResult,
|
||||
EXCEPINFO.ByReference pExcepInfo, int puArgErr) {
|
||||
this.pVarResult = pVarResult;
|
||||
this.pExcepInfo = pExcepInfo;
|
||||
this.puArgErr = puArgErr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the p var result.
|
||||
*
|
||||
* @return the p var result
|
||||
*/
|
||||
public VARIANT.ByReference getpVarResult() {
|
||||
return pVarResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the p excep info.
|
||||
*
|
||||
* @return the p excep info
|
||||
*/
|
||||
public EXCEPINFO.ByReference getpExcepInfo() {
|
||||
return pExcepInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pu arg err.
|
||||
*
|
||||
* @return the pu arg err
|
||||
*/
|
||||
public int getPuArgErr() {
|
||||
return puArgErr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the documentation.
|
||||
*
|
||||
* @param memid
|
||||
* the memid
|
||||
* @return the documentation
|
||||
*/
|
||||
public TypeInfoDoc getDocumentation(MEMBERID memid) {
|
||||
BSTRByReference pBstrName = new BSTRByReference();
|
||||
BSTRByReference pBstrDocString = new BSTRByReference();
|
||||
DWORDByReference pdwHelpContext = new DWORDByReference();
|
||||
BSTRByReference pBstrHelpFile = new BSTRByReference();
|
||||
|
||||
HRESULT hr = this.typeInfo.GetDocumentation(memid, pBstrName,
|
||||
pBstrDocString, pdwHelpContext, pBstrHelpFile);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
TypeInfoDoc TypeInfoDoc = new TypeInfoDoc(pBstrName.getString(),
|
||||
pBstrDocString.getString(), pdwHelpContext.getValue()
|
||||
.intValue(), pBstrHelpFile.getString());
|
||||
|
||||
OLEAUTO.SysFreeString(pBstrName.getValue());
|
||||
OLEAUTO.SysFreeString(pBstrDocString.getValue());
|
||||
OLEAUTO.SysFreeString(pBstrHelpFile.getValue());
|
||||
|
||||
return TypeInfoDoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class TypeInfoDoc.
|
||||
*
|
||||
* @author wolf.tobias@gmx.net The Class TypeInfoDoc.
|
||||
*/
|
||||
public static class TypeInfoDoc {
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
||||
/** The doc string. */
|
||||
private String docString;
|
||||
|
||||
/** The help context. */
|
||||
private int helpContext;
|
||||
|
||||
/** The help file. */
|
||||
private String helpFile;
|
||||
|
||||
/**
|
||||
* Instantiates a new type info doc.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param docString
|
||||
* the doc string
|
||||
* @param helpContext
|
||||
* the help context
|
||||
* @param helpFile
|
||||
* the help file
|
||||
*/
|
||||
public TypeInfoDoc(String name, String docString, int helpContext,
|
||||
String helpFile) {
|
||||
this.name = name;
|
||||
this.docString = docString;
|
||||
this.helpContext = helpContext;
|
||||
this.helpFile = helpFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the doc string.
|
||||
*
|
||||
* @return the doc string
|
||||
*/
|
||||
public String getDocString() {
|
||||
return docString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the help context.
|
||||
*
|
||||
* @return the help context
|
||||
*/
|
||||
public int getHelpContext() {
|
||||
return helpContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the help file.
|
||||
*
|
||||
* @return the help file
|
||||
*/
|
||||
public String getHelpFile() {
|
||||
return helpFile;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dll entry.
|
||||
*
|
||||
* @param memid
|
||||
* the memid
|
||||
* @param invKind
|
||||
* the inv kind
|
||||
* @return the dll entry
|
||||
*/
|
||||
public DllEntry GetDllEntry(MEMBERID memid, INVOKEKIND invKind) {
|
||||
BSTRByReference pBstrDllName = new BSTRByReference();
|
||||
BSTRByReference pBstrName = new BSTRByReference();
|
||||
WORDByReference pwOrdinal = new WORDByReference();
|
||||
|
||||
HRESULT hr = this.typeInfo.GetDllEntry(memid, invKind, pBstrDllName,
|
||||
pBstrName, pwOrdinal);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
OLEAUTO.SysFreeString(pBstrDllName.getValue());
|
||||
OLEAUTO.SysFreeString(pBstrName.getValue());
|
||||
|
||||
return new DllEntry(pBstrDllName.getString(), pBstrName.getString(),
|
||||
pwOrdinal.getValue().intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class DllEntry.
|
||||
*
|
||||
* @author wolf.tobias@gmx.net The Class DllEntry.
|
||||
*/
|
||||
public static class DllEntry {
|
||||
|
||||
/** The dll name. */
|
||||
private String dllName;
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
||||
/** The ordinal. */
|
||||
private int ordinal;
|
||||
|
||||
/**
|
||||
* Instantiates a new dll entry.
|
||||
*
|
||||
* @param dllName
|
||||
* the dll name
|
||||
* @param name
|
||||
* the name
|
||||
* @param ordinal
|
||||
* the ordinal
|
||||
*/
|
||||
public DllEntry(String dllName, String name, int ordinal) {
|
||||
this.dllName = dllName;
|
||||
this.name = name;
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dll name.
|
||||
*
|
||||
* @return the dll name
|
||||
*/
|
||||
public String getDllName() {
|
||||
return dllName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dll name.
|
||||
*
|
||||
* @param dllName
|
||||
* the new dll name
|
||||
*/
|
||||
public void setDllName(String dllName) {
|
||||
this.dllName = dllName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name
|
||||
* the new name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ordinal.
|
||||
*
|
||||
* @return the ordinal
|
||||
*/
|
||||
public int getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ordinal.
|
||||
*
|
||||
* @param ordinal
|
||||
* the new ordinal
|
||||
*/
|
||||
public void setOrdinal(int ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ref type info.
|
||||
*
|
||||
* @param hreftype
|
||||
* the hreftype
|
||||
* @return the ref type info
|
||||
*/
|
||||
public ITypeInfo getRefTypeInfo(HREFTYPE hreftype) {
|
||||
PointerByReference ppTInfo = new PointerByReference();
|
||||
HRESULT hr = this.typeInfo.GetRefTypeInfo(hreftype, ppTInfo);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return new TypeInfo(ppTInfo.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Address of member.
|
||||
*
|
||||
* @param memid
|
||||
* the memid
|
||||
* @param invKind
|
||||
* the inv kind
|
||||
* @return the pointer by reference
|
||||
*/
|
||||
public PointerByReference AddressOfMember(MEMBERID memid, INVOKEKIND invKind) {
|
||||
PointerByReference ppv = new PointerByReference();
|
||||
HRESULT hr = this.typeInfo.AddressOfMember(memid, invKind, ppv);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return ppv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the instance.
|
||||
*
|
||||
* @param pUnkOuter
|
||||
* the unk outer
|
||||
* @param riid
|
||||
* the riid
|
||||
* @return the pointer by reference
|
||||
*/
|
||||
public PointerByReference CreateInstance(IUnknown pUnkOuter, REFIID riid) {
|
||||
PointerByReference ppvObj = new PointerByReference();
|
||||
HRESULT hr = this.typeInfo.CreateInstance(pUnkOuter, riid, ppvObj);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return ppvObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mops.
|
||||
*
|
||||
* @param memid
|
||||
* the memid
|
||||
* @return the string
|
||||
*/
|
||||
public String GetMops(MEMBERID memid) {
|
||||
|
||||
BSTRByReference pBstrMops = new BSTRByReference();
|
||||
HRESULT hr = this.typeInfo.GetMops(memid, pBstrMops);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return pBstrMops.getString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the containing type lib.
|
||||
*
|
||||
* @return the containing type lib
|
||||
*/
|
||||
public ContainingTypeLib GetContainingTypeLib() {
|
||||
|
||||
PointerByReference ppTLib = new PointerByReference();
|
||||
UINTByReference pIndex = new UINTByReference();
|
||||
|
||||
HRESULT hr = this.typeInfo.GetContainingTypeLib(ppTLib, pIndex);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return new ContainingTypeLib(new TypeLib(ppTLib.getValue()), pIndex
|
||||
.getValue().intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class ContainingTypeLib.
|
||||
*
|
||||
* @author wolf.tobias@gmx.net The Class ContainingTypeLib.
|
||||
*/
|
||||
public static class ContainingTypeLib {
|
||||
|
||||
/** The type lib. */
|
||||
private ITypeLib typeLib;
|
||||
|
||||
/** The index. */
|
||||
private int index;
|
||||
|
||||
/**
|
||||
* Instantiates a new containing type lib.
|
||||
*
|
||||
* @param typeLib
|
||||
* the type lib
|
||||
* @param index
|
||||
* the index
|
||||
*/
|
||||
public ContainingTypeLib(ITypeLib typeLib, int index) {
|
||||
this.typeLib = typeLib;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type lib.
|
||||
*
|
||||
* @return the type lib
|
||||
*/
|
||||
public ITypeLib getTypeLib() {
|
||||
return typeLib;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type lib.
|
||||
*
|
||||
* @param typeLib
|
||||
* the new type lib
|
||||
*/
|
||||
public void setTypeLib(ITypeLib typeLib) {
|
||||
this.typeLib = typeLib;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index.
|
||||
*
|
||||
* @return the index
|
||||
*/
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the index.
|
||||
*
|
||||
* @param index
|
||||
* the new index
|
||||
*/
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Release type attr.
|
||||
*
|
||||
* @param pTypeAttr
|
||||
* the type attr
|
||||
*/
|
||||
public void ReleaseTypeAttr(TYPEATTR pTypeAttr) {
|
||||
this.typeInfo.ReleaseTypeAttr(pTypeAttr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release func desc.
|
||||
*
|
||||
* @param pFuncDesc
|
||||
* the func desc
|
||||
*/
|
||||
public void ReleaseFuncDesc(FUNCDESC pFuncDesc) {
|
||||
this.typeInfo.ReleaseFuncDesc(pFuncDesc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release var desc.
|
||||
*
|
||||
* @param pVarDesc
|
||||
* the var desc
|
||||
*/
|
||||
public void ReleaseVarDesc(VARDESC pVarDesc) {
|
||||
this.typeInfo.ReleaseVarDesc(pVarDesc);
|
||||
}
|
||||
}
|
||||
@@ -1,239 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.TLIBATTR;
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEKIND;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTRByReference;
|
||||
import com.sun.jna.platform.win32.WTypes.LPOLESTR;
|
||||
import com.sun.jna.platform.win32.WinDef.BOOLByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORDByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONG;
|
||||
import com.sun.jna.platform.win32.WinDef.USHORTByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the ITypeLib interface.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TypeLib extends Unknown implements ITypeLib {
|
||||
|
||||
public static class ByReference extends TypeLib implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new i type lib.
|
||||
*/
|
||||
public TypeLib() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new i type lib.
|
||||
*
|
||||
* @param pvInstance
|
||||
* the pv instance
|
||||
*/
|
||||
public TypeLib(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info count.
|
||||
*
|
||||
* @return the uint
|
||||
*/
|
||||
public UINT GetTypeInfoCount() {
|
||||
return (UINT) this._invokeNativeObject(3,
|
||||
new Object[] { this.getPointer() }, UINT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param pTInfo
|
||||
* the t info
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetTypeInfo(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */PointerByReference pTInfo) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(4,
|
||||
new Object[] { this.getPointer(), index, pTInfo },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info type.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param pTKind
|
||||
* the t kind
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetTypeInfoType(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */TYPEKIND.ByReference pTKind) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(5,
|
||||
new Object[] { this.getPointer(), index, pTKind },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info of guid.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
* @param pTinfo
|
||||
* the tinfo
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetTypeInfoOfGuid(
|
||||
/* [in] */GUID guid,
|
||||
/* [out] */PointerByReference pTinfo) {
|
||||
|
||||
return (HRESULT) this
|
||||
._invokeNativeObject(6, new Object[] { this.getPointer(), guid,
|
||||
pTinfo }, HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the lib attr.
|
||||
*
|
||||
* @param ppTLibAttr
|
||||
* the pp t lib attr
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetLibAttr(
|
||||
/* [out] */PointerByReference ppTLibAttr) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(7,
|
||||
new Object[] { this.getPointer(), ppTLibAttr }, HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type comp.
|
||||
*
|
||||
* @param pTComp
|
||||
* the t comp
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetTypeComp(
|
||||
/* [out] */PointerByReference pTComp) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(8,
|
||||
new Object[] { this.getPointer(), pTComp }, HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the documentation.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param pBstrName
|
||||
* the bstr name
|
||||
* @param pBstrDocString
|
||||
* the bstr doc string
|
||||
* @param pdwHelpContext
|
||||
* the pdw help context
|
||||
* @param pBstrHelpFile
|
||||
* the bstr help file
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetDocumentation(
|
||||
/* [in] */int index,
|
||||
/* [out] */BSTRByReference pBstrName,
|
||||
/* [out] */BSTRByReference pBstrDocString,
|
||||
/* [out] */DWORDByReference pdwHelpContext,
|
||||
/* [out] */BSTRByReference pBstrHelpFile) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(9,
|
||||
new Object[] { this.getPointer(), index, pBstrName,
|
||||
pBstrDocString, pdwHelpContext, pBstrHelpFile },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is name.
|
||||
*
|
||||
* @param szNameBuf
|
||||
* the sz name buf
|
||||
* @param lHashVal
|
||||
* the l hash val
|
||||
* @param pfName
|
||||
* the pf name
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT IsName(
|
||||
/* [annotation][out][in] */
|
||||
LPOLESTR szNameBuf,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [out] */BOOLByReference pfName) {
|
||||
|
||||
return (HRESULT) this
|
||||
._invokeNativeObject(10, new Object[] { this.getPointer(),
|
||||
szNameBuf, lHashVal, pfName }, HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find name.
|
||||
*
|
||||
* @param szNameBuf
|
||||
* the sz name buf
|
||||
* @param lHashVal
|
||||
* the l hash val
|
||||
* @param ppTInfo
|
||||
* the pp t info
|
||||
* @param rgMemId
|
||||
* the rg mem id
|
||||
* @param pcFound
|
||||
* the pc found
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT FindName(
|
||||
/* [annotation][out][in] */
|
||||
BSTRByReference szNameBuf,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [length_is][size_is][out] */ITypeInfo[] ppTInfo,
|
||||
/* [length_is][size_is][out] */MEMBERID[] rgMemId,
|
||||
/* [out][in] */USHORTByReference pcFound) {
|
||||
|
||||
return (HRESULT) this._invokeNativeObject(11,
|
||||
new Object[] { this.getPointer(), szNameBuf, lHashVal, ppTInfo,
|
||||
rgMemId, pcFound }, HRESULT.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release t lib attr.
|
||||
*
|
||||
* @param pTLibAttr
|
||||
* the t lib attr
|
||||
*/
|
||||
public void ReleaseTLibAttr(/* [in] */TLIBATTR pTLibAttr) {
|
||||
this._invokeNativeObject(12, new Object[] { this.getPointer() },
|
||||
HRESULT.class);
|
||||
}
|
||||
}
|
||||
@@ -1,536 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.CLSID;
|
||||
import com.sun.jna.platform.win32.Kernel32;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.TLIBATTR;
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEKIND;
|
||||
import com.sun.jna.platform.win32.Ole32;
|
||||
import com.sun.jna.platform.win32.OleAuto;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTRByReference;
|
||||
import com.sun.jna.platform.win32.WTypes.LPOLESTR;
|
||||
import com.sun.jna.platform.win32.WinDef.BOOLByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORDByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.LCID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONG;
|
||||
import com.sun.jna.platform.win32.WinDef.USHORTByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the class ITypeLibUtil.
|
||||
*
|
||||
* @author wolf.tobias@gmx.net The Class ITypeLibUtil.
|
||||
*/
|
||||
public class TypeLibUtil {
|
||||
|
||||
/** The Constant OLEAUTO. */
|
||||
public final static OleAuto OLEAUTO = OleAuto.INSTANCE;
|
||||
|
||||
/** The typelib. */
|
||||
private ITypeLib typelib;
|
||||
// get user default lcid
|
||||
/** The lcid. */
|
||||
private LCID lcid = Kernel32.INSTANCE.GetUserDefaultLCID();
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
||||
/** The doc string. */
|
||||
private String docString;
|
||||
|
||||
/** The help context. */
|
||||
private int helpContext;
|
||||
|
||||
/** The help file. */
|
||||
private String helpFile;
|
||||
|
||||
/**
|
||||
* Instantiates a new i type lib util.
|
||||
*
|
||||
* @param clsidStr
|
||||
* the clsid str
|
||||
* @param wVerMajor
|
||||
* the w ver major
|
||||
* @param wVerMinor
|
||||
* the w ver minor
|
||||
*/
|
||||
public TypeLibUtil(String clsidStr, int wVerMajor, int wVerMinor) {
|
||||
CLSID.ByReference clsid = new CLSID.ByReference();
|
||||
// get CLSID from string
|
||||
HRESULT hr = Ole32.INSTANCE.CLSIDFromString(new WString(clsidStr),
|
||||
clsid);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
// load typelib
|
||||
PointerByReference pTypeLib = new PointerByReference();
|
||||
hr = OleAuto.INSTANCE.LoadRegTypeLib(clsid, wVerMajor, wVerMinor, lcid,
|
||||
pTypeLib);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
// init type lib class
|
||||
this.typelib = new TypeLib(pTypeLib.getValue());
|
||||
|
||||
this.initTypeLibInfo();
|
||||
}
|
||||
|
||||
public TypeLibUtil(String file) {
|
||||
// load typelib
|
||||
PointerByReference pTypeLib = new PointerByReference();
|
||||
HRESULT hr = OleAuto.INSTANCE.LoadTypeLib(new WString(file), pTypeLib);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
// init type lib class
|
||||
this.typelib = new TypeLib(pTypeLib.getValue());
|
||||
|
||||
this.initTypeLibInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the type lib info.
|
||||
*/
|
||||
private void initTypeLibInfo() {
|
||||
TypeLibDoc documentation = this.getDocumentation(-1);
|
||||
this.name = documentation.getName();
|
||||
this.docString = documentation.getDocString();
|
||||
this.helpContext = documentation.getHelpContext();
|
||||
this.helpFile = documentation.getHelpFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info count.
|
||||
*
|
||||
* @return the type info count
|
||||
*/
|
||||
public int getTypeInfoCount() {
|
||||
return this.typelib.GetTypeInfoCount().intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info type.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @return the type info type
|
||||
*/
|
||||
public TYPEKIND getTypeInfoType(int index) {
|
||||
TYPEKIND.ByReference typekind = new TYPEKIND.ByReference();
|
||||
HRESULT hr = this.typelib.GetTypeInfoType(new UINT(index), typekind);
|
||||
COMUtils.checkRC(hr);
|
||||
return typekind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @return the type info
|
||||
*/
|
||||
public ITypeInfo getTypeInfo(int index) {
|
||||
PointerByReference ppTInfo = new PointerByReference();
|
||||
HRESULT hr = this.typelib.GetTypeInfo(new UINT(index), ppTInfo);
|
||||
COMUtils.checkRC(hr);
|
||||
return new TypeInfo(ppTInfo.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info util.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @return the type info util
|
||||
*/
|
||||
public TypeInfoUtil getTypeInfoUtil(int index) {
|
||||
return new TypeInfoUtil(this.getTypeInfo(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the lib attr.
|
||||
*
|
||||
* @return the lib attr
|
||||
*/
|
||||
public TLIBATTR getLibAttr() {
|
||||
PointerByReference ppTLibAttr = new PointerByReference();
|
||||
HRESULT hr = typelib.GetLibAttr(ppTLibAttr);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return new TLIBATTR(ppTLibAttr.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type comp.
|
||||
*
|
||||
* @return the i type comp. by reference
|
||||
*/
|
||||
public TypeComp GetTypeComp() {
|
||||
PointerByReference ppTComp = new PointerByReference();
|
||||
HRESULT hr = this.typelib.GetTypeComp(ppTComp);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return new TypeComp(ppTComp.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the documentation.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @return the documentation
|
||||
*/
|
||||
public TypeLibDoc getDocumentation(int index) {
|
||||
BSTRByReference pBstrName = new BSTRByReference();
|
||||
BSTRByReference pBstrDocString = new BSTRByReference();
|
||||
DWORDByReference pdwHelpContext = new DWORDByReference();
|
||||
BSTRByReference pBstrHelpFile = new BSTRByReference();
|
||||
|
||||
HRESULT hr = typelib.GetDocumentation(index, pBstrName, pBstrDocString,
|
||||
pdwHelpContext, pBstrHelpFile);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
TypeLibDoc typeLibDoc = new TypeLibDoc(pBstrName.getString(),
|
||||
pBstrDocString.getString(), pdwHelpContext.getValue()
|
||||
.intValue(), pBstrHelpFile.getString());
|
||||
|
||||
OLEAUTO.SysFreeString(pBstrName.getValue());
|
||||
OLEAUTO.SysFreeString(pBstrDocString.getValue());
|
||||
OLEAUTO.SysFreeString(pBstrHelpFile.getValue());
|
||||
|
||||
return typeLibDoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class TypeLibDoc.
|
||||
*
|
||||
* @author wolf.tobias@gmx.net The Class TypeLibDoc.
|
||||
*/
|
||||
public static class TypeLibDoc {
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
||||
/** The doc string. */
|
||||
private String docString;
|
||||
|
||||
/** The help context. */
|
||||
private int helpContext;
|
||||
|
||||
/** The help file. */
|
||||
private String helpFile;
|
||||
|
||||
/**
|
||||
* Instantiates a new type lib doc.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param docString
|
||||
* the doc string
|
||||
* @param helpContext
|
||||
* the help context
|
||||
* @param helpFile
|
||||
* the help file
|
||||
*/
|
||||
public TypeLibDoc(String name, String docString, int helpContext,
|
||||
String helpFile) {
|
||||
this.name = name;
|
||||
this.docString = docString;
|
||||
this.helpContext = helpContext;
|
||||
this.helpFile = helpFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the doc string.
|
||||
*
|
||||
* @return the doc string
|
||||
*/
|
||||
public String getDocString() {
|
||||
return docString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the help context.
|
||||
*
|
||||
* @return the help context
|
||||
*/
|
||||
public int getHelpContext() {
|
||||
return helpContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the help file.
|
||||
*
|
||||
* @return the help file
|
||||
*/
|
||||
public String getHelpFile() {
|
||||
return helpFile;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is name.
|
||||
*
|
||||
* @param nameBuf
|
||||
* the name buf
|
||||
* @param hashVal
|
||||
* the hash val
|
||||
* @return the checks if is name
|
||||
*/
|
||||
public IsName IsName(String nameBuf, int hashVal) {
|
||||
|
||||
LPOLESTR szNameBuf = new LPOLESTR(nameBuf);
|
||||
ULONG lHashVal = new ULONG(hashVal);
|
||||
BOOLByReference pfName = new BOOLByReference();
|
||||
|
||||
HRESULT hr = this.typelib.IsName(szNameBuf, lHashVal, pfName);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
return new IsName(szNameBuf.getValue(), pfName.getValue()
|
||||
.booleanValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class IsName.
|
||||
*
|
||||
* @author wolf.tobias@gmx.net The Class IsName.
|
||||
*/
|
||||
public static class IsName {
|
||||
|
||||
/** The name buf. */
|
||||
private String nameBuf;
|
||||
|
||||
/** The name. */
|
||||
private boolean name;
|
||||
|
||||
/**
|
||||
* Instantiates a new checks if is name.
|
||||
*
|
||||
* @param nameBuf
|
||||
* the name buf
|
||||
* @param name
|
||||
* the name
|
||||
*/
|
||||
public IsName(String nameBuf, boolean name) {
|
||||
this.nameBuf = nameBuf;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name buf.
|
||||
*
|
||||
* @return the name buf
|
||||
*/
|
||||
public String getNameBuf() {
|
||||
return nameBuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is name.
|
||||
*
|
||||
* @return true, if is name
|
||||
*/
|
||||
public boolean isName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find name.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param hashVal
|
||||
* the hash val
|
||||
* @param found
|
||||
* the found
|
||||
* @return the find name
|
||||
*/
|
||||
public FindName FindName(String name, int hashVal, short found) {
|
||||
/* [annotation][out][in] */
|
||||
BSTRByReference szNameBuf = new BSTRByReference(
|
||||
OleAuto.INSTANCE.SysAllocString(name));
|
||||
/* [in] */ULONG lHashVal = new ULONG(hashVal);
|
||||
/* [out][in] */USHORTByReference pcFound = new USHORTByReference(found);
|
||||
|
||||
HRESULT hr = this.typelib.FindName(szNameBuf, lHashVal, null, null,
|
||||
pcFound);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
found = pcFound.getValue().shortValue();
|
||||
/* [length_is][size_is][out] */ITypeInfo[] ppTInfo = new ITypeInfo[found];
|
||||
/* [length_is][size_is][out] */MEMBERID[] rgMemId = new MEMBERID[found];
|
||||
hr = this.typelib.FindName(szNameBuf, lHashVal, ppTInfo, rgMemId,
|
||||
pcFound);
|
||||
COMUtils.checkRC(hr);
|
||||
|
||||
FindName findName = new FindName(szNameBuf.getString(), ppTInfo,
|
||||
rgMemId, found);
|
||||
OLEAUTO.SysFreeString(szNameBuf.getValue());
|
||||
|
||||
return findName;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class FindName.
|
||||
*
|
||||
* @author wolf.tobias@gmx.net The Class FindName.
|
||||
*/
|
||||
public static class FindName {
|
||||
|
||||
/** The name buf. */
|
||||
private String nameBuf;
|
||||
|
||||
/** The p t info. */
|
||||
private ITypeInfo[] pTInfo;
|
||||
|
||||
/** The rg mem id. */
|
||||
private MEMBERID[] rgMemId;
|
||||
|
||||
/** The pc found. */
|
||||
private short pcFound;
|
||||
|
||||
/**
|
||||
* Instantiates a new find name.
|
||||
*
|
||||
* @param nameBuf
|
||||
* the name buf
|
||||
* @param pTInfo
|
||||
* the t info
|
||||
* @param rgMemId
|
||||
* the rg mem id
|
||||
* @param pcFound
|
||||
* the pc found
|
||||
*/
|
||||
public FindName(String nameBuf, ITypeInfo[] pTInfo, MEMBERID[] rgMemId,
|
||||
short pcFound) {
|
||||
this.nameBuf = nameBuf;
|
||||
this.pTInfo = pTInfo;
|
||||
this.rgMemId = rgMemId;
|
||||
this.pcFound = pcFound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name buf.
|
||||
*
|
||||
* @return the name buf
|
||||
*/
|
||||
public String getNameBuf() {
|
||||
return nameBuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the t info.
|
||||
*
|
||||
* @return the t info
|
||||
*/
|
||||
public ITypeInfo[] getTInfo() {
|
||||
return pTInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mem id.
|
||||
*
|
||||
* @return the mem id
|
||||
*/
|
||||
public MEMBERID[] getMemId() {
|
||||
return rgMemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the found.
|
||||
*
|
||||
* @return the found
|
||||
*/
|
||||
public short getFound() {
|
||||
return pcFound;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Release t lib attr.
|
||||
*
|
||||
* @param pTLibAttr
|
||||
* the t lib attr
|
||||
*/
|
||||
public void ReleaseTLibAttr(/* [in] */TLIBATTR pTLibAttr) {
|
||||
this.typelib.ReleaseTLibAttr(pTLibAttr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the lcid.
|
||||
*
|
||||
* @return the lcid
|
||||
*/
|
||||
public LCID getLcid() {
|
||||
return lcid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the typelib.
|
||||
*
|
||||
* @return the typelib
|
||||
*/
|
||||
public ITypeLib getTypelib() {
|
||||
return typelib;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the doc string.
|
||||
*
|
||||
* @return the doc string
|
||||
*/
|
||||
public String getDocString() {
|
||||
return docString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the help context.
|
||||
*
|
||||
* @return the help context
|
||||
*/
|
||||
public long getHelpContext() {
|
||||
return helpContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the help file.
|
||||
*
|
||||
* @return the help file
|
||||
*/
|
||||
public String getHelpFile() {
|
||||
return helpFile;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.Guid.IID;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the ITypeInfo interface
|
||||
*
|
||||
* Method Name V-Table Offset IUnknown.QueryInterface 0 IUnknown.AddRef 4
|
||||
* IUnknown.Release 8
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class Unknown extends COMInvoker implements IUnknown {
|
||||
|
||||
public static class ByReference extends Unknown implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
public Unknown() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new i unknown.
|
||||
*
|
||||
* @param pvInstance
|
||||
* the pv instance
|
||||
*/
|
||||
public Unknown(Pointer pvInstance) {
|
||||
this.setPointer(pvInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query interface.
|
||||
*
|
||||
* @param riid
|
||||
* the riid
|
||||
* @param ppvObject
|
||||
* the ppv object
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT QueryInterface(IID riid, PointerByReference ppvObject) {
|
||||
return (HRESULT) this._invokeNativeObject(0,
|
||||
new Object[] { this.getPointer(), riid, ppvObject },
|
||||
HRESULT.class);
|
||||
}
|
||||
|
||||
public int AddRef() {
|
||||
return this._invokeNativeInt(1, new Object[] { this.getPointer() });
|
||||
}
|
||||
|
||||
public int Release() {
|
||||
return this._invokeNativeInt(2, new Object[] { this.getPointer() });
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
Provides...
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,231 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEKIND;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil;
|
||||
import com.sun.jna.platform.win32.COM.tlb.imp.TlbBase;
|
||||
import com.sun.jna.platform.win32.COM.tlb.imp.TlbCmdlineArgs;
|
||||
import com.sun.jna.platform.win32.COM.tlb.imp.TlbCoClass;
|
||||
import com.sun.jna.platform.win32.COM.tlb.imp.TlbConst;
|
||||
import com.sun.jna.platform.win32.COM.tlb.imp.TlbDispInterface;
|
||||
import com.sun.jna.platform.win32.COM.tlb.imp.TlbEnum;
|
||||
import com.sun.jna.platform.win32.COM.tlb.imp.TlbInterface;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TlbImp.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TlbImp implements TlbConst {
|
||||
|
||||
/** The type lib util. */
|
||||
private TypeLibUtil typeLibUtil;
|
||||
|
||||
/** The out. */
|
||||
private File comRootDir;
|
||||
|
||||
private File outputDir;
|
||||
|
||||
private TlbCmdlineArgs cmdlineArgs;
|
||||
|
||||
/**
|
||||
* The main method.
|
||||
*
|
||||
* @param args
|
||||
* the arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
new TlbImp(args);
|
||||
}
|
||||
|
||||
public TlbImp(String[] args) {
|
||||
this.cmdlineArgs = new TlbCmdlineArgs(args);
|
||||
|
||||
if (this.cmdlineArgs.isTlbId()) {
|
||||
String clsid = this.cmdlineArgs.getRequiredParam(CMD_ARG_TYPELIB_ID);
|
||||
int majorVersion = this.cmdlineArgs
|
||||
.getIntParam(CMD_ARG_TYPELIB_MAJOR_VERSION);
|
||||
int minorVersion = this.cmdlineArgs
|
||||
.getIntParam(CMD_ARG_TYPELIB_MINOR_VERSION);
|
||||
|
||||
// initialize typelib
|
||||
// check version numbers with registry entries!!!
|
||||
this.typeLibUtil = new TypeLibUtil(clsid, majorVersion,
|
||||
minorVersion);
|
||||
this.startCOM2Java();
|
||||
} else if (this.cmdlineArgs.isTlbFile()) {
|
||||
String file = this.cmdlineArgs.getRequiredParam(CMD_ARG_TYPELIB_FILE);
|
||||
// initialize typelib
|
||||
// check version numbers with registry entries!!!
|
||||
this.typeLibUtil = new TypeLibUtil(file);
|
||||
this.startCOM2Java();
|
||||
} else
|
||||
this.cmdlineArgs.showCmdHelp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start startCOM2Java.
|
||||
*/
|
||||
public void startCOM2Java() {
|
||||
try {
|
||||
// create output Dir
|
||||
this.createDir();
|
||||
|
||||
String bindingMode = this.cmdlineArgs.getBindingMode();
|
||||
|
||||
int typeInfoCount = typeLibUtil.getTypeInfoCount();
|
||||
for (int i = 0; i < typeInfoCount; ++i) {
|
||||
TYPEKIND typekind = typeLibUtil.getTypeInfoType(i);
|
||||
|
||||
if (typekind.value == TYPEKIND.TKIND_ENUM) {
|
||||
this.createCOMEnum(i, this.getPackageName(), typeLibUtil);
|
||||
} else if (typekind.value == TYPEKIND.TKIND_RECORD) {
|
||||
this.logInfo("'TKIND_RECORD' objects are currently not supported!");
|
||||
} else if (typekind.value == TYPEKIND.TKIND_MODULE) {
|
||||
this.logInfo("'TKIND_MODULE' objects are currently not supported!");
|
||||
} else if (typekind.value == TYPEKIND.TKIND_INTERFACE) {
|
||||
this.createCOMInterface(i, this.getPackageName(),
|
||||
typeLibUtil);
|
||||
} else if (typekind.value == TYPEKIND.TKIND_DISPATCH) {
|
||||
this.createCOMDispInterface(i, this.getPackageName(),
|
||||
typeLibUtil);
|
||||
} else if (typekind.value == TYPEKIND.TKIND_COCLASS) {
|
||||
this.createCOMCoClass(i, this.getPackageName(),
|
||||
typeLibUtil, bindingMode);
|
||||
} else if (typekind.value == TYPEKIND.TKIND_ALIAS) {
|
||||
this.logInfo("'TKIND_ALIAS' objects are currently not supported!");
|
||||
} else if (typekind.value == TYPEKIND.TKIND_UNION) {
|
||||
this.logInfo("'TKIND_UNION' objects are currently not supported!");
|
||||
}
|
||||
}
|
||||
|
||||
logInfo(typeInfoCount + " files sucessfully written to: "
|
||||
+ this.comRootDir.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void createDir() throws FileNotFoundException {
|
||||
String _outputDir = this.cmdlineArgs.getParam(CMD_ARG_OUTPUT_DIR);
|
||||
String path = "_jnaCOM_" + System.currentTimeMillis() + "\\myPackage\\"
|
||||
+ this.typeLibUtil.getName().toLowerCase() + "\\";
|
||||
|
||||
if (_outputDir != null) {
|
||||
this.comRootDir = new File(_outputDir + "\\" + path);
|
||||
} else {
|
||||
String tmp = System.getProperty("java.io.tmpdir");
|
||||
this.comRootDir = new File(tmp + "\\" + path);
|
||||
}
|
||||
|
||||
if (this.comRootDir.exists())
|
||||
this.comRootDir.delete();
|
||||
|
||||
if (this.comRootDir.mkdirs()) {
|
||||
logInfo("Output directory sucessfully created.");
|
||||
} else {
|
||||
throw new FileNotFoundException(
|
||||
"Output directory NOT sucessfully created to: "
|
||||
+ this.comRootDir.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private String getPackageName() {
|
||||
return "myPackage." + this.typeLibUtil.getName().toLowerCase();
|
||||
}
|
||||
|
||||
private void writeTextFile(String filename, String str) throws IOException {
|
||||
String file = this.comRootDir + File.separator + filename;
|
||||
BufferedOutputStream bos = new BufferedOutputStream(
|
||||
new FileOutputStream(file));
|
||||
bos.write(str.getBytes());
|
||||
bos.close();
|
||||
}
|
||||
|
||||
private void writeTlbClass(TlbBase tlbBase) throws IOException {
|
||||
StringBuffer classBuffer = tlbBase.getClassBuffer();
|
||||
this.writeTextFile(tlbBase.getFilename(), classBuffer.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the com enum.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
* @return the string buffer
|
||||
*/
|
||||
private void createCOMEnum(int index, String packagename,
|
||||
TypeLibUtil typeLibUtil) throws IOException {
|
||||
TlbEnum tlbEnum = new TlbEnum(index, packagename, typeLibUtil);
|
||||
this.writeTlbClass(tlbEnum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the com interface.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
* @return the string buffer
|
||||
*/
|
||||
private void createCOMInterface(int index, String packagename,
|
||||
TypeLibUtil typeLibUtil) throws IOException {
|
||||
TlbInterface tlbInterface = new TlbInterface(index, packagename,
|
||||
typeLibUtil);
|
||||
this.writeTlbClass(tlbInterface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the com dispatch.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
* @return the string buffer
|
||||
*/
|
||||
private void createCOMDispInterface(int index, String packagename,
|
||||
TypeLibUtil typeLibUtil) throws IOException {
|
||||
TlbDispInterface tlbDispatch = new TlbDispInterface(index, packagename,
|
||||
typeLibUtil);
|
||||
this.writeTlbClass(tlbDispatch);
|
||||
}
|
||||
|
||||
private void createCOMCoClass(int index, String packagename,
|
||||
TypeLibUtil typeLibUtil, String bindingMode) throws IOException {
|
||||
TlbCoClass tlbCoClass = new TlbCoClass(index, this.getPackageName(),
|
||||
typeLibUtil, bindingMode);
|
||||
this.writeTlbClass(tlbCoClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log info.
|
||||
*
|
||||
* @param msg
|
||||
* the msg
|
||||
*/
|
||||
public static void logInfo(String msg) {
|
||||
System.out.println(msg);
|
||||
}
|
||||
}
|
||||
@@ -1,285 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.Guid.CLSID;
|
||||
import com.sun.jna.platform.win32.OaIdl;
|
||||
import com.sun.jna.platform.win32.OaIdl.CURRENCY;
|
||||
import com.sun.jna.platform.win32.OaIdl.DATE;
|
||||
import com.sun.jna.platform.win32.OaIdl.DECIMAL;
|
||||
import com.sun.jna.platform.win32.OaIdl.ELEMDESC;
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPE;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEDESC;
|
||||
import com.sun.jna.platform.win32.Variant;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WTypes.LPSTR;
|
||||
import com.sun.jna.platform.win32.WTypes.LPWSTR;
|
||||
import com.sun.jna.platform.win32.WTypes.VARTYPE;
|
||||
import com.sun.jna.platform.win32.WinBase.FILETIME;
|
||||
import com.sun.jna.platform.win32.WinDef.BOOL;
|
||||
import com.sun.jna.platform.win32.WinDef.CHAR;
|
||||
import com.sun.jna.platform.win32.WinDef.INT_PTR;
|
||||
import com.sun.jna.platform.win32.WinDef.LONG;
|
||||
import com.sun.jna.platform.win32.WinDef.PVOID;
|
||||
import com.sun.jna.platform.win32.WinDef.SCODE;
|
||||
import com.sun.jna.platform.win32.WinDef.UCHAR;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT_PTR;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONG;
|
||||
import com.sun.jna.platform.win32.WinDef.USHORT;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.COM.IDispatch;
|
||||
import com.sun.jna.platform.win32.COM.ITypeInfo;
|
||||
import com.sun.jna.platform.win32.COM.IUnknown;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil.TypeInfoDoc;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TlbFunction.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public abstract class TlbAbstractMethod extends TlbBase implements Variant {
|
||||
|
||||
protected TypeInfoDoc typeInfoDoc;
|
||||
|
||||
protected String methodName;
|
||||
|
||||
protected String docStr;
|
||||
|
||||
protected short vtableId;
|
||||
|
||||
protected MEMBERID memberid;
|
||||
|
||||
protected short paramCount;
|
||||
|
||||
protected String returnType;
|
||||
|
||||
protected String methodparams = "";
|
||||
|
||||
protected String methodvariables = "";
|
||||
|
||||
/**
|
||||
* Instantiates a new tlb function.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
* @param funcDesc
|
||||
* the func desc
|
||||
* @param typeInfoUtil
|
||||
* the type info util
|
||||
*/
|
||||
public TlbAbstractMethod(int index, TypeLibUtil typeLibUtil,
|
||||
FUNCDESC funcDesc, TypeInfoUtil typeInfoUtil) {
|
||||
super(index, typeLibUtil, typeInfoUtil);
|
||||
this.typeInfoDoc = typeInfoUtil.getDocumentation(funcDesc.memid);
|
||||
this.methodName = typeInfoDoc.getName();
|
||||
this.docStr = typeInfoDoc.getDocString();
|
||||
|
||||
// get function values
|
||||
this.vtableId = funcDesc.oVft.shortValue();
|
||||
this.memberid = funcDesc.memid;
|
||||
this.paramCount = funcDesc.cParams.shortValue();
|
||||
this.returnType = this.getType(funcDesc);
|
||||
}
|
||||
|
||||
public TypeInfoDoc getTypeInfoDoc() {
|
||||
return typeInfoDoc;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return methodName;
|
||||
}
|
||||
|
||||
public String getDocStr() {
|
||||
return docStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the var type.
|
||||
*
|
||||
* @param vt
|
||||
* the vt
|
||||
* @return the var type
|
||||
*/
|
||||
protected String getVarType(VARTYPE vt) {
|
||||
switch (vt.intValue()) {
|
||||
case VT_EMPTY:
|
||||
return "";
|
||||
case VT_NULL:
|
||||
return "null";
|
||||
case VT_I2:
|
||||
return "short";
|
||||
case VT_I4:
|
||||
return "int";
|
||||
case VT_R4:
|
||||
return "float";
|
||||
case VT_R8:
|
||||
return "double";
|
||||
case VT_CY:
|
||||
return CURRENCY.class.getSimpleName();
|
||||
case VT_DATE:
|
||||
return DATE.class.getSimpleName();
|
||||
case VT_BSTR:
|
||||
return BSTR.class.getSimpleName();
|
||||
case VT_DISPATCH:
|
||||
return IDispatch.class.getSimpleName();
|
||||
case VT_ERROR:
|
||||
return SCODE.class.getSimpleName();
|
||||
case VT_BOOL:
|
||||
return BOOL.class.getSimpleName();
|
||||
case VT_VARIANT:
|
||||
return VARIANT.class.getSimpleName();
|
||||
case VT_UNKNOWN:
|
||||
return IUnknown.class.getSimpleName();
|
||||
case VT_DECIMAL:
|
||||
return DECIMAL.class.getSimpleName();
|
||||
case VT_I1:
|
||||
return CHAR.class.getSimpleName();
|
||||
case VT_UI1:
|
||||
return UCHAR.class.getSimpleName();
|
||||
case VT_UI2:
|
||||
return USHORT.class.getSimpleName();
|
||||
case VT_UI4:
|
||||
return UINT.class.getSimpleName();
|
||||
case VT_I8:
|
||||
return LONG.class.getSimpleName();
|
||||
case VT_UI8:
|
||||
return ULONG.class.getSimpleName();
|
||||
case VT_INT:
|
||||
return "int";
|
||||
case VT_UINT:
|
||||
return UINT.class.getSimpleName();
|
||||
case VT_VOID:
|
||||
return PVOID.class.getSimpleName();
|
||||
case VT_HRESULT:
|
||||
return HRESULT.class.getSimpleName();
|
||||
case VT_PTR:
|
||||
return Pointer.class.getSimpleName();
|
||||
case VT_SAFEARRAY:
|
||||
return "safearray";
|
||||
case VT_CARRAY:
|
||||
return "carray";
|
||||
case VT_USERDEFINED:
|
||||
return "userdefined";
|
||||
case VT_LPSTR:
|
||||
return LPSTR.class.getSimpleName();
|
||||
case VT_LPWSTR:
|
||||
return LPWSTR.class.getSimpleName();
|
||||
case VT_RECORD:
|
||||
return "record";
|
||||
case VT_INT_PTR:
|
||||
return INT_PTR.class.getSimpleName();
|
||||
case VT_UINT_PTR:
|
||||
return UINT_PTR.class.getSimpleName();
|
||||
case VT_FILETIME:
|
||||
return FILETIME.class.getSimpleName();
|
||||
case VT_STREAM:
|
||||
return "steam";
|
||||
case VT_STORAGE:
|
||||
return "storage";
|
||||
case VT_STREAMED_OBJECT:
|
||||
return "steamed_object";
|
||||
case VT_STORED_OBJECT:
|
||||
return "stored_object";
|
||||
case VT_BLOB_OBJECT:
|
||||
return "blob_object";
|
||||
case VT_CF:
|
||||
return "cf";
|
||||
case VT_CLSID:
|
||||
return CLSID.class.getSimpleName();
|
||||
case VT_VERSIONED_STREAM:
|
||||
return "";
|
||||
// case VT_BSTR_BLOB:
|
||||
// return "";
|
||||
case VT_VECTOR:
|
||||
return "";
|
||||
case VT_ARRAY:
|
||||
return "";
|
||||
case VT_BYREF:
|
||||
return PVOID.class.getSimpleName();
|
||||
case VT_RESERVED:
|
||||
return "";
|
||||
case VT_ILLEGAL:
|
||||
return "illegal";
|
||||
/*
|
||||
* case VT_ILLEGALMASKED: return "illegal_masked"; case VT_TYPEMASK:
|
||||
* return "typemask";
|
||||
*/default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getUserdefinedType(HREFTYPE hreftype) {
|
||||
ITypeInfo refTypeInfo = this.typeInfoUtil.getRefTypeInfo(hreftype);
|
||||
TypeInfoUtil typeInfoUtil = new TypeInfoUtil(refTypeInfo);
|
||||
TypeInfoDoc documentation = typeInfoUtil
|
||||
.getDocumentation(OaIdl.MEMBERID_NIL);
|
||||
return documentation.getName();
|
||||
}
|
||||
|
||||
protected String getType(FUNCDESC funcDesc) {
|
||||
ELEMDESC elemDesc = funcDesc.elemdescFunc;
|
||||
return this.getType(elemDesc);
|
||||
}
|
||||
|
||||
protected String getType(ELEMDESC elemDesc) {
|
||||
TYPEDESC _typeDesc = elemDesc.tdesc;
|
||||
return this.getType(_typeDesc);
|
||||
}
|
||||
|
||||
protected String getType(TYPEDESC typeDesc) {
|
||||
VARTYPE vt = typeDesc.vt;
|
||||
String type = "not_defined";
|
||||
|
||||
if (vt.intValue() == Variant.VT_PTR) {
|
||||
TYPEDESC lptdesc = typeDesc._typedesc.getLptdesc();
|
||||
type = this.getType(lptdesc);
|
||||
} else if (vt.intValue() == Variant.VT_SAFEARRAY
|
||||
|| vt.intValue() == Variant.VT_CARRAY) {
|
||||
TYPEDESC tdescElem = typeDesc._typedesc.getLpadesc().tdescElem;
|
||||
type = this.getType(tdescElem);
|
||||
} else if (vt.intValue() == Variant.VT_USERDEFINED) {
|
||||
HREFTYPE hreftype = typeDesc._typedesc.hreftype;
|
||||
type = this.getUserdefinedType(hreftype);
|
||||
} else {
|
||||
type = this.getVarType(vt);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
protected String replaceJavaKeyword(String name) {
|
||||
if (name.equals("final"))
|
||||
return "_" + name;
|
||||
else if (name.equals("default"))
|
||||
return "_" + name;
|
||||
else if (name.equals("case"))
|
||||
return "_" + name;
|
||||
else if (name.equals("char"))
|
||||
return "_" + name;
|
||||
else if (name.equals("private"))
|
||||
return "_" + name;
|
||||
else if (name.equals("default"))
|
||||
return "_" + name;
|
||||
else
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -1,281 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TlbBase.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public abstract class TlbBase {
|
||||
|
||||
/** The Constant CR. */
|
||||
public final static String CR = "\n";
|
||||
|
||||
/** The Constant CRCR. */
|
||||
public final static String CRCR = "\n\n";
|
||||
|
||||
/** The Constant TAB. */
|
||||
public final static String TAB = "\t";
|
||||
|
||||
/** The Constant TABTAB. */
|
||||
public final static String TABTAB = "\t\t";
|
||||
|
||||
/** The type lib util. */
|
||||
protected TypeLibUtil typeLibUtil;
|
||||
|
||||
protected TypeInfoUtil typeInfoUtil;
|
||||
|
||||
/** The index. */
|
||||
protected int index;
|
||||
|
||||
/** The template buffer. */
|
||||
protected StringBuffer templateBuffer;
|
||||
|
||||
/** The class buffer. */
|
||||
protected StringBuffer classBuffer;
|
||||
|
||||
/** The content. */
|
||||
protected String content = "";
|
||||
|
||||
protected String filename = "DefaultFilename";
|
||||
|
||||
protected String name = "DefaultName";
|
||||
|
||||
/** The iunknown methods. */
|
||||
public static String[] IUNKNOWN_METHODS = { "QueryInterface", "AddRef",
|
||||
"Release" };
|
||||
|
||||
/** The idispatch methods. */
|
||||
public static String[] IDISPATCH_METHODS = { "GetTypeInfoCount",
|
||||
"GetTypeInfo", "GetIDsOfNames", "Invoke" };
|
||||
|
||||
protected String bindingMode = TlbConst.BINDING_MODE_DISPID;
|
||||
|
||||
public TlbBase(int index, TypeLibUtil typeLibUtil, TypeInfoUtil typeInfoUtil) {
|
||||
this(index, typeLibUtil, typeInfoUtil, TlbConst.BINDING_MODE_DISPID);
|
||||
}
|
||||
|
||||
public TlbBase(int index, TypeLibUtil typeLibUtil, TypeInfoUtil typeInfoUtil, String bindingMode) {
|
||||
this.index = index;
|
||||
this.typeLibUtil = typeLibUtil;
|
||||
this.typeInfoUtil = typeInfoUtil;
|
||||
this.bindingMode = bindingMode;
|
||||
|
||||
String filename = this.getClassTemplate();
|
||||
try {
|
||||
this.readTemplateFile(filename);
|
||||
this.classBuffer = templateBuffer;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log error.
|
||||
*
|
||||
* @param msg
|
||||
* the msg
|
||||
*/
|
||||
public void logError(String msg) {
|
||||
this.log("ERROR", msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log info.
|
||||
*
|
||||
* @param msg
|
||||
* the msg
|
||||
*/
|
||||
public void logInfo(String msg) {
|
||||
this.log("INFO", msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the class buffer.
|
||||
*
|
||||
* @return the class buffer
|
||||
*/
|
||||
public StringBuffer getClassBuffer() {
|
||||
return classBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the content.
|
||||
*
|
||||
* @param content
|
||||
* the content
|
||||
*/
|
||||
public void createContent(String content) {
|
||||
this.replaceVariable("content", content);
|
||||
}
|
||||
|
||||
public void setFilename(String filename) {
|
||||
if (!filename.endsWith("java"))
|
||||
filename += ".java";
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return this.filename;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log.
|
||||
*
|
||||
* @param level
|
||||
* the level
|
||||
* @param msg
|
||||
* the msg
|
||||
*/
|
||||
protected void log(String level, String msg) {
|
||||
String _msg = level + " " + this.getTime() + " : " + msg;
|
||||
System.out.println(_msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time.
|
||||
*
|
||||
* @return the time
|
||||
*/
|
||||
private String getTime() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
return sdf.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the class template.
|
||||
*
|
||||
* @return the class template
|
||||
*/
|
||||
abstract protected String getClassTemplate();
|
||||
|
||||
/**
|
||||
* Read template file.
|
||||
*
|
||||
* @param filename
|
||||
* the filename
|
||||
* @throws IOException
|
||||
* Signals that an I/O exception has occurred.
|
||||
*/
|
||||
protected void readTemplateFile(String filename) throws IOException {
|
||||
this.templateBuffer = new StringBuffer();
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
InputStream is = this.getClass().getClassLoader()
|
||||
.getResourceAsStream(filename);
|
||||
reader = new BufferedReader(new InputStreamReader(is));
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null)
|
||||
this.templateBuffer.append(line + "\n");
|
||||
} finally {
|
||||
if (reader != null)
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace variable.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
protected void replaceVariable(String name, String value) {
|
||||
if (value == null)
|
||||
value = "";
|
||||
|
||||
Pattern pattern = Pattern.compile("\\$\\{" + name + "\\}");
|
||||
Matcher matcher = pattern.matcher(this.classBuffer);
|
||||
String replacement = value;
|
||||
String result = "";
|
||||
|
||||
while (matcher.find()) {
|
||||
result = matcher.replaceAll(replacement);
|
||||
}
|
||||
|
||||
if (result.length() > 0)
|
||||
this.classBuffer = new StringBuffer(result);
|
||||
}
|
||||
|
||||
protected void createPackageName(String packagename) {
|
||||
this.replaceVariable("packagename", packagename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the class name.
|
||||
*
|
||||
* @param name
|
||||
* the name
|
||||
*/
|
||||
protected void createClassName(String name) {
|
||||
this.replaceVariable("classname", name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is reserved method.
|
||||
*
|
||||
* @param method
|
||||
* the method
|
||||
* @return true, if is reserved method
|
||||
*/
|
||||
protected boolean isReservedMethod(String method) {
|
||||
for (int i = 0; i < IUNKNOWN_METHODS.length; i++) {
|
||||
if (IUNKNOWN_METHODS[i].equalsIgnoreCase(method))
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < IDISPATCH_METHODS.length; i++) {
|
||||
if (IDISPATCH_METHODS[i].equalsIgnoreCase(method))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isVTableMode() {
|
||||
if(this.bindingMode.equalsIgnoreCase(TlbConst.BINDING_MODE_VTABLE))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isDispIdMode() {
|
||||
if(this.bindingMode.equalsIgnoreCase(TlbConst.BINDING_MODE_DISPID))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class TlbCmdlineArgs extends Hashtable<String, String> implements
|
||||
TlbConst {
|
||||
|
||||
public TlbCmdlineArgs(String[] args) {
|
||||
this.readCmdArgs(args);
|
||||
}
|
||||
|
||||
public int getIntParam(String key) {
|
||||
String param = this.getRequiredParam(key);
|
||||
return new Integer(param).intValue();
|
||||
}
|
||||
|
||||
public String getParam(String key) {
|
||||
return this.get(key);
|
||||
}
|
||||
|
||||
public String getRequiredParam(String key) {
|
||||
String param = this.getParam(key);
|
||||
if (param == null)
|
||||
throw new TlbParameterNotFoundException(
|
||||
"Commandline parameter not found: " + key);
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
private void readCmdArgs(String[] args) {
|
||||
if (args.length < 2)
|
||||
this.showCmdHelp();
|
||||
|
||||
for (int i = 0; i < args.length;) {
|
||||
String cmdName = args[i];
|
||||
String cmdValue = args[i+1];
|
||||
if (cmdName.startsWith("-") && !cmdValue.startsWith("-")) {
|
||||
this.put(cmdName.substring(1), cmdValue);
|
||||
i+=2;
|
||||
}else {
|
||||
this.showCmdHelp();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTlbFile() {
|
||||
return this.containsKey(CMD_ARG_TYPELIB_FILE);
|
||||
}
|
||||
|
||||
public boolean isTlbId() {
|
||||
return this.containsKey(CMD_ARG_TYPELIB_ID);
|
||||
}
|
||||
|
||||
public String getBindingMode() {
|
||||
if(this.containsKey(CMD_ARG_BINDING_MODE))
|
||||
return this.getParam(CMD_ARG_BINDING_MODE);
|
||||
else
|
||||
return BINDING_MODE_VTABLE;
|
||||
}
|
||||
|
||||
public void showCmdHelp() {
|
||||
String helpStr = "usage: TlbImp [-tlb.id -tlb.major.version -tlb.minor.version] [-tlb.file] [-bind.mode vTable, dispId] [-output.dir]"
|
||||
+ CRCR
|
||||
+ "options:"
|
||||
+ CR
|
||||
+ "-tlb.id The guid of the type library."
|
||||
+ CR
|
||||
+ "-tlb.major.version The major version of the type library."
|
||||
+ CR
|
||||
+ "-tlb.minor.version The minor version of the type library."
|
||||
+ CR
|
||||
+ "-tlb.file The file name containing the type library."
|
||||
+ CR
|
||||
+ "-bind.mode The binding mode used to create the Java code."
|
||||
+ CR
|
||||
+ "-output.dir The optional output directory, default is the user temp directory."
|
||||
+ CRCR
|
||||
+ "samples:"
|
||||
+ CR
|
||||
+ "Microsoft Shell Controls And Automation:"
|
||||
+ CR
|
||||
+ "-tlb.file shell32.dll"
|
||||
+ CR
|
||||
+ "-tlb.id {50A7E9B0-70EF-11D1-B75A-00A0C90564FE} -tlb.major.version 1 -tlb.minor.version 0"
|
||||
+ CRCR
|
||||
+ "Microsoft Word 12.0 Object Library:"
|
||||
+ CR
|
||||
+ "-tlb.id {00020905-0000-0000-C000-000000000046} -tlb.major.version 8 -tlb.minor.version 4"
|
||||
+ CRCR;
|
||||
|
||||
System.out.println(helpStr);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPE;
|
||||
import com.sun.jna.platform.win32.OaIdl.INVOKEKIND;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEATTR;
|
||||
import com.sun.jna.platform.win32.COM.ITypeInfo;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil.TypeInfoDoc;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil.TypeLibDoc;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TlbClass.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TlbCoClass extends TlbBase {
|
||||
|
||||
/**
|
||||
* Instantiates a new tlb class.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
*/
|
||||
public TlbCoClass(int index, String packagename, TypeLibUtil typeLibUtil, String bindingMode) {
|
||||
super(index, typeLibUtil, null);
|
||||
|
||||
TypeInfoUtil typeInfoUtil = typeLibUtil.getTypeInfoUtil(index);
|
||||
|
||||
TypeLibDoc typeLibDoc = this.typeLibUtil.getDocumentation(index);
|
||||
String docString = typeLibDoc.getDocString();
|
||||
|
||||
if(typeLibDoc.getName().length() > 0)
|
||||
this.name = typeLibDoc.getName();
|
||||
|
||||
this.logInfo("Type of kind 'CoClass' found: " + this.name);
|
||||
|
||||
this.createPackageName(packagename);
|
||||
this.createClassName(this.name);
|
||||
this.setFilename(this.name);
|
||||
|
||||
String guidStr = this.typeLibUtil.getLibAttr().guid.toGuidString();
|
||||
int majorVerNum = this.typeLibUtil.getLibAttr().wMajorVerNum.intValue();
|
||||
int minorVerNum = this.typeLibUtil.getLibAttr().wMinorVerNum.intValue();
|
||||
String version = majorVerNum + "." + minorVerNum;
|
||||
String clsid = typeInfoUtil.getTypeAttr().guid.toGuidString();
|
||||
|
||||
this.createJavaDocHeader(guidStr, version, docString);
|
||||
this.createCLSID(clsid);
|
||||
this.createCLSIDName(this.name);
|
||||
|
||||
// Get the TypeAttributes
|
||||
TYPEATTR typeAttr = typeInfoUtil.getTypeAttr();
|
||||
int cImplTypes = typeAttr.cImplTypes.intValue();
|
||||
String interfaces = "";
|
||||
|
||||
for (int i = 0; i < cImplTypes; i++) {
|
||||
HREFTYPE refTypeOfImplType = typeInfoUtil.getRefTypeOfImplType(i);
|
||||
ITypeInfo refTypeInfo = typeInfoUtil
|
||||
.getRefTypeInfo(refTypeOfImplType);
|
||||
TypeInfoUtil refTypeInfoUtil = new TypeInfoUtil(refTypeInfo);
|
||||
this.createFunctions(refTypeInfoUtil, bindingMode);
|
||||
TypeInfoDoc documentation = refTypeInfoUtil
|
||||
.getDocumentation(new MEMBERID(-1));
|
||||
interfaces += documentation.getName();
|
||||
|
||||
if (i < cImplTypes - 1)
|
||||
interfaces += ", ";
|
||||
}
|
||||
|
||||
this.createInterfaces(interfaces);
|
||||
this.createContent(this.content);
|
||||
}
|
||||
|
||||
protected void createFunctions(TypeInfoUtil typeInfoUtil, String bindingMode) {
|
||||
TYPEATTR typeAttr = typeInfoUtil.getTypeAttr();
|
||||
int cFuncs = typeAttr.cFuncs.intValue();
|
||||
for (int i = 0; i < cFuncs; i++) {
|
||||
// Get the function description
|
||||
FUNCDESC funcDesc = typeInfoUtil.getFuncDesc(i);
|
||||
|
||||
TlbAbstractMethod method = null;
|
||||
if (funcDesc.invkind.equals(INVOKEKIND.INVOKE_FUNC)) {
|
||||
if(this.isVTableMode())
|
||||
method = new TlbFunctionVTable(i, index, typeLibUtil, funcDesc, typeInfoUtil);
|
||||
else
|
||||
method = new TlbFunctionDispId(i, index, typeLibUtil, funcDesc, typeInfoUtil);
|
||||
} else if (funcDesc.invkind.equals(INVOKEKIND.INVOKE_PROPERTYGET)) {
|
||||
method = new TlbPropertyGet(i, index, typeLibUtil, funcDesc,
|
||||
typeInfoUtil);
|
||||
} else if (funcDesc.invkind.equals(INVOKEKIND.INVOKE_PROPERTYPUT)) {
|
||||
method = new TlbPropertyPut(i, index, typeLibUtil, funcDesc,
|
||||
typeInfoUtil);
|
||||
} else if (funcDesc.invkind
|
||||
.equals(INVOKEKIND.INVOKE_PROPERTYPUTREF)) {
|
||||
method = new TlbPropertyPut(i, index, typeLibUtil, funcDesc,
|
||||
typeInfoUtil);
|
||||
}
|
||||
|
||||
if(!isReservedMethod(method.getMethodName()))
|
||||
{
|
||||
this.content += method.getClassBuffer();
|
||||
|
||||
if (i < cFuncs - 1)
|
||||
this.content += CR;
|
||||
}
|
||||
|
||||
// Release our function description stuff
|
||||
typeInfoUtil.ReleaseFuncDesc(funcDesc);
|
||||
}
|
||||
}
|
||||
|
||||
protected void createJavaDocHeader(String guid, String version,
|
||||
String helpstring) {
|
||||
this.replaceVariable("uuid", guid);
|
||||
this.replaceVariable("version", version);
|
||||
this.replaceVariable("helpstring", helpstring);
|
||||
}
|
||||
|
||||
protected void createCLSIDName(String clsidName) {
|
||||
this.replaceVariable("clsidname", clsidName.toUpperCase());
|
||||
}
|
||||
|
||||
protected void createCLSID(String clsid) {
|
||||
this.replaceVariable("clsid", clsid);
|
||||
}
|
||||
|
||||
protected void createInterfaces(String interfaces) {
|
||||
this.replaceVariable("interfaces", interfaces);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.platform.win32.COM.tlb.imp.TlbBase#getClassTemplate()
|
||||
*/
|
||||
@Override
|
||||
protected String getClassTemplate() {
|
||||
return "com/sun/jna/platform/win32/COM/tlb/imp/TlbCoClass.template";
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package ${packagename};
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.jna.*;
|
||||
import com.sun.jna.platform.win32.*;
|
||||
import com.sun.jna.platform.win32.WinNT.*;
|
||||
import com.sun.jna.platform.win32.OaIdl.*;
|
||||
import com.sun.jna.platform.win32.WinDef.*;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.*;
|
||||
import com.sun.jna.platform.win32.COM.*;
|
||||
import com.sun.jna.platform.win32.Guid.*;
|
||||
|
||||
/**
|
||||
* uuid(${uuid})
|
||||
* version(${version})
|
||||
* helpstring(${helpstring})
|
||||
* clsid(${clsid})
|
||||
*
|
||||
*/
|
||||
public class ${classname} extends COMEarlyBindingObject implements ${interfaces} {
|
||||
|
||||
public static final CLSID ${clsidname}_CLSID = new CLSID("${clsid}");
|
||||
|
||||
public ${classname}() {
|
||||
super(${clsidname}_CLSID, false, WTypes.CLSCTX_SERVER);
|
||||
}
|
||||
|
||||
public ${classname}(CLSID clsid, boolean useActiveInstance, int dwClsContext) {
|
||||
super(clsid, useActiveInstance, dwClsContext);
|
||||
}
|
||||
|
||||
${content}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
public interface TlbConst {
|
||||
|
||||
public final static String CR = "\n";
|
||||
|
||||
public final static String CRCR = "\n\n";
|
||||
|
||||
public final static String TYPELIB_ID_SHELL = "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}";
|
||||
|
||||
public final static String TYPELIB_MAJOR_VERSION_SHELL = "1";
|
||||
|
||||
public final static String TYPELIB_MINOR_VERSION_SHELL = "0";
|
||||
|
||||
public final static String TYPELIB_ID_WORD = "{00020905-0000-0000-C000-000000000046}";
|
||||
|
||||
public final static String TYPELIB_MAJOR_VERSION_WORD = "8";
|
||||
|
||||
public final static String TYPELIB_MINOR_VERSION_WORD = "4";
|
||||
|
||||
public final static String TYPELIB_ID_OFFICE = "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}";
|
||||
|
||||
public final static String TYPELIB_MAJOR_VERSION_OFFICE = "2";
|
||||
|
||||
public final static String TYPELIB_MINOR_VERSION_OFFICE = "5";
|
||||
|
||||
public final static String CMD_ARG_TYPELIB_ID = "tlb.id";
|
||||
|
||||
public final static String CMD_ARG_BINDING_MODE = "bind.mode";
|
||||
|
||||
public final static String BINDING_MODE_VTABLE = "vtable";
|
||||
|
||||
public final static String BINDING_MODE_DISPID = "dispid";
|
||||
|
||||
public final static String CMD_ARG_TYPELIB_MAJOR_VERSION = "tlb.major.version";
|
||||
|
||||
public final static String CMD_ARG_TYPELIB_MINOR_VERSION = "tlb.minor.version";
|
||||
|
||||
public final static String CMD_ARG_TYPELIB_FILE = "tlb.file";
|
||||
|
||||
public final static String CMD_ARG_OUTPUT_DIR = "output.dir";
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPE;
|
||||
import com.sun.jna.platform.win32.OaIdl.INVOKEKIND;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEATTR;
|
||||
import com.sun.jna.platform.win32.WinDef.WORD;
|
||||
import com.sun.jna.platform.win32.COM.ITypeInfo;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil.TypeInfoDoc;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil.TypeLibDoc;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TlbDispatch.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TlbDispInterface extends TlbBase {
|
||||
|
||||
/**
|
||||
* Instantiates a new tlb dispatch.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
*/
|
||||
public TlbDispInterface(int index, String packagename,
|
||||
TypeLibUtil typeLibUtil) {
|
||||
super(index, typeLibUtil, null);
|
||||
|
||||
TypeLibDoc typeLibDoc = this.typeLibUtil.getDocumentation(index);
|
||||
String docString = typeLibDoc.getDocString();
|
||||
|
||||
if(typeLibDoc.getName().length() > 0)
|
||||
this.name = typeLibDoc.getName();
|
||||
|
||||
this.logInfo("Type of kind 'DispInterface' found: " + this.name);
|
||||
|
||||
this.createPackageName(packagename);
|
||||
this.createClassName(this.name);
|
||||
this.setFilename(this.name);
|
||||
|
||||
// Get the TypeAttributes
|
||||
TypeInfoUtil typeInfoUtil = typeLibUtil.getTypeInfoUtil(index);
|
||||
TYPEATTR typeAttr = typeInfoUtil.getTypeAttr();
|
||||
|
||||
this.createJavaDocHeader(typeAttr.guid.toGuidString(), docString);
|
||||
|
||||
int cFuncs = typeAttr.cFuncs.intValue();
|
||||
for (int i = 0; i < cFuncs; i++) {
|
||||
// Get the function description
|
||||
FUNCDESC funcDesc = typeInfoUtil.getFuncDesc(i);
|
||||
|
||||
// Get the member ID
|
||||
MEMBERID memberID = funcDesc.memid;
|
||||
|
||||
// Get the name of the method
|
||||
TypeInfoDoc typeInfoDoc2 = typeInfoUtil.getDocumentation(memberID);
|
||||
String methodName = typeInfoDoc2.getName();
|
||||
TlbAbstractMethod method = null;
|
||||
|
||||
if (!isReservedMethod(methodName)) {
|
||||
if (funcDesc.invkind.equals(INVOKEKIND.INVOKE_FUNC)) {
|
||||
method = new TlbFunctionStub(index, typeLibUtil, funcDesc,
|
||||
typeInfoUtil);
|
||||
} else if (funcDesc.invkind
|
||||
.equals(INVOKEKIND.INVOKE_PROPERTYGET)) {
|
||||
method = new TlbPropertyGetStub(index, typeLibUtil,
|
||||
funcDesc, typeInfoUtil);
|
||||
} else if (funcDesc.invkind
|
||||
.equals(INVOKEKIND.INVOKE_PROPERTYPUT)) {
|
||||
method = new TlbPropertyPutStub(index, typeLibUtil,
|
||||
funcDesc, typeInfoUtil);
|
||||
} else if (funcDesc.invkind
|
||||
.equals(INVOKEKIND.INVOKE_PROPERTYPUTREF)) {
|
||||
method = new TlbPropertyPutStub(index, typeLibUtil,
|
||||
funcDesc, typeInfoUtil);
|
||||
}
|
||||
|
||||
this.content += method.getClassBuffer();
|
||||
|
||||
if (i < cFuncs - 1)
|
||||
this.content += CR;
|
||||
}
|
||||
|
||||
// Release our function description stuff
|
||||
typeInfoUtil.ReleaseFuncDesc(funcDesc);
|
||||
}
|
||||
|
||||
this.createContent(this.content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the java doc header.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
* @param helpstring
|
||||
* the helpstring
|
||||
*/
|
||||
protected void createJavaDocHeader(String guid, String helpstring) {
|
||||
this.replaceVariable("uuid", guid);
|
||||
this.replaceVariable("helpstring", helpstring);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.platform.win32.COM.tlb.imp.TlbBase#getClassTemplate()
|
||||
*/
|
||||
@Override
|
||||
protected String getClassTemplate() {
|
||||
return "com/sun/jna/platform/win32/COM/tlb/imp/TlbDispInterface.template";
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package ${packagename};
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.jna.*;
|
||||
import com.sun.jna.platform.win32.*;
|
||||
import com.sun.jna.platform.win32.WinNT.*;
|
||||
import com.sun.jna.platform.win32.OaIdl.*;
|
||||
import com.sun.jna.platform.win32.WinDef.*;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.*;
|
||||
import com.sun.jna.platform.win32.COM.*;
|
||||
import com.sun.jna.platform.win32.Guid.*;
|
||||
|
||||
/**
|
||||
* uuid(${uuid})
|
||||
* version(${version})
|
||||
* helpstring(${helpstring})
|
||||
*
|
||||
*/
|
||||
public interface ${classname} extends IDispatch {
|
||||
|
||||
${content}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEATTR;
|
||||
import com.sun.jna.platform.win32.OaIdl.VARDESC;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil.TypeInfoDoc;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil.TypeLibDoc;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TlbEnum.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TlbEnum extends TlbBase {
|
||||
|
||||
/**
|
||||
* Instantiates a new tlb enum.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
*/
|
||||
public TlbEnum(int index, String packagename, TypeLibUtil typeLibUtil) {
|
||||
super(index, typeLibUtil, null);
|
||||
|
||||
TypeLibDoc typeLibDoc = this.typeLibUtil.getDocumentation(index);
|
||||
String docString = typeLibDoc.getDocString();
|
||||
|
||||
if (typeLibDoc.getName().length() > 0)
|
||||
this.name = typeLibDoc.getName();
|
||||
|
||||
this.logInfo("Type of kind 'Enum' found: " + this.name);
|
||||
|
||||
this.createPackageName(packagename);
|
||||
this.createClassName(this.name);
|
||||
this.setFilename(this.name);
|
||||
|
||||
// Get the TypeAttributes
|
||||
TypeInfoUtil typeInfoUtil = typeLibUtil.getTypeInfoUtil(index);
|
||||
TYPEATTR typeAttr = typeInfoUtil.getTypeAttr();
|
||||
|
||||
this.createJavaDocHeader(typeAttr.guid.toGuidString(), docString);
|
||||
|
||||
int cVars = typeAttr.cVars.intValue();
|
||||
for (int i = 0; i < cVars; i++) {
|
||||
// Get the property description
|
||||
VARDESC varDesc = typeInfoUtil.getVarDesc(i);
|
||||
VARIANT constValue = varDesc._vardesc.lpvarValue;
|
||||
Object value = constValue.getValue();
|
||||
|
||||
// Get the member ID
|
||||
MEMBERID memberID = varDesc.memid;
|
||||
|
||||
// Get the name of the property
|
||||
TypeInfoDoc typeInfoDoc2 = typeInfoUtil.getDocumentation(memberID);
|
||||
this.content += TABTAB + "//" + typeInfoDoc2.getName() + CR;
|
||||
this.content += TABTAB + "public static final int "
|
||||
+ typeInfoDoc2.getName() + " = " + value.toString() + ";";
|
||||
|
||||
if (i < cVars - 1)
|
||||
this.content += CR;
|
||||
|
||||
// release the pointer
|
||||
typeInfoUtil.ReleaseVarDesc(varDesc);
|
||||
}
|
||||
|
||||
this.createContent(this.content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the java doc header.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
* @param helpstring
|
||||
* the helpstring
|
||||
*/
|
||||
protected void createJavaDocHeader(String guid, String helpstring) {
|
||||
this.replaceVariable("uuid", guid);
|
||||
this.replaceVariable("helpstring", helpstring);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.platform.win32.COM.tlb.imp.TlbBase#getClassTemplate()
|
||||
*/
|
||||
@Override
|
||||
protected String getClassTemplate() {
|
||||
return "com/sun/jna/platform/win32/COM/tlb/imp/TlbEnum.template";
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package ${packagename};
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.sun.jna.*;
|
||||
import com.sun.jna.platform.win32.*;
|
||||
import com.sun.jna.platform.win32.WinNT.*;
|
||||
import com.sun.jna.platform.win32.OaIdl.*;
|
||||
import com.sun.jna.platform.win32.WinDef.*;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.*;
|
||||
import com.sun.jna.platform.win32.COM.*;
|
||||
import com.sun.jna.platform.win32.Guid.*;
|
||||
|
||||
/**
|
||||
* uuid(${uuid})
|
||||
* helpstring(${helpstring})
|
||||
*
|
||||
*/
|
||||
public class ${classname} extends Structure {
|
||||
public static class ByReference extends ${classname} implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
public int value;
|
||||
|
||||
public ${classname}() {
|
||||
}
|
||||
|
||||
public ${classname}(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public ${classname}(Pointer pointer) {
|
||||
super(pointer);
|
||||
this.read();
|
||||
}
|
||||
|
||||
${content}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "value" });
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.ELEMDESC;
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TlbFunction.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TlbFunctionDispId extends TlbAbstractMethod {
|
||||
|
||||
/**
|
||||
* Instantiates a new tlb function.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
* @param funcDesc
|
||||
* the func desc
|
||||
* @param typeInfoUtil
|
||||
* the type info util
|
||||
*/
|
||||
public TlbFunctionDispId(int count, int index, TypeLibUtil typeLibUtil,
|
||||
FUNCDESC funcDesc, TypeInfoUtil typeInfoUtil) {
|
||||
super(index, typeLibUtil, funcDesc, typeInfoUtil);
|
||||
|
||||
String[] names = typeInfoUtil.getNames(funcDesc.memid, paramCount + 1);
|
||||
|
||||
for (int i = 0; i < paramCount; i++) {
|
||||
ELEMDESC elemdesc = funcDesc.lprgelemdescParam.elemDescArg[i];
|
||||
String methodName = names[i + 1].toLowerCase();
|
||||
String type = this.getType(elemdesc.tdesc);
|
||||
String _methodName = this.replaceJavaKeyword(methodName);
|
||||
methodparams += type + " " + _methodName;
|
||||
|
||||
//wrap all in a VARIANT
|
||||
if(type.equals("VARIANT"))
|
||||
methodvariables += _methodName;
|
||||
else
|
||||
methodvariables += "new VARIANT(" + _methodName + ")";
|
||||
|
||||
// if there is more than 1 param
|
||||
if (i < (paramCount - 1)) {
|
||||
methodparams += ", ";
|
||||
methodvariables += ", ";
|
||||
}
|
||||
}
|
||||
|
||||
String returnValue;
|
||||
if(this.returnType.equalsIgnoreCase("VARIANT"))
|
||||
returnValue = "pResult";
|
||||
else
|
||||
returnValue = "((" + returnType + ") pResult.getValue())";
|
||||
|
||||
this.replaceVariable("helpstring", docStr);
|
||||
this.replaceVariable("returntype", returnType);
|
||||
this.replaceVariable("returnvalue", returnValue);
|
||||
this.replaceVariable("methodname", methodName);
|
||||
this.replaceVariable("methodparams", methodparams);
|
||||
this.replaceVariable("methodvariables", methodvariables);
|
||||
this.replaceVariable("vtableid", String.valueOf(vtableId));
|
||||
this.replaceVariable("memberid", String.valueOf(memberid));
|
||||
this.replaceVariable("functionCount", String.valueOf(count));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.platform.win32.COM.tlb.imp.TlbBase#getClassTemplate()
|
||||
*/
|
||||
@Override
|
||||
protected String getClassTemplate() {
|
||||
return "com/sun/jna/platform/win32/COM/tlb/imp/TlbFunctionDispId.template";
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
/**
|
||||
* ${helpstring}
|
||||
* Virtual table id: ${vtableid}
|
||||
* Member id: ${memberid}
|
||||
*/
|
||||
public ${returntype} ${methodname}(${methodparams}) {
|
||||
VARIANT.ByReference pResult = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_METHOD, pResult, getIDispatch(), new DISPID(${memberid}), new VARIANT[] {${methodvariables}});
|
||||
return ${returnvalue};
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.ELEMDESC;
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil.TypeInfoDoc;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TlbFunction.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TlbFunctionStub extends TlbAbstractMethod {
|
||||
|
||||
/**
|
||||
* Instantiates a new tlb function.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
* @param funcDesc
|
||||
* the func desc
|
||||
* @param typeInfoUtil
|
||||
* the type info util
|
||||
*/
|
||||
public TlbFunctionStub(int index, TypeLibUtil typeLibUtil,
|
||||
FUNCDESC funcDesc, TypeInfoUtil typeInfoUtil) {
|
||||
super(index, typeLibUtil, funcDesc, typeInfoUtil);
|
||||
|
||||
TypeInfoDoc typeInfoDoc = typeInfoUtil.getDocumentation(funcDesc.memid);
|
||||
String methodname = typeInfoDoc.getName();
|
||||
String docStr = typeInfoDoc.getDocString();
|
||||
String[] names = typeInfoUtil.getNames(funcDesc.memid, paramCount + 1);
|
||||
|
||||
// if there is at least one param we need a comma
|
||||
if (paramCount > 0)
|
||||
methodvariables = ", ";
|
||||
|
||||
for (int i = 0; i < paramCount; i++) {
|
||||
ELEMDESC elemdesc = funcDesc.lprgelemdescParam.elemDescArg[i];
|
||||
String methodName = names[i + 1].toLowerCase();
|
||||
methodparams += this.getType(elemdesc.tdesc) + " "
|
||||
+ this.replaceJavaKeyword(methodName);
|
||||
methodvariables += methodName;
|
||||
|
||||
// if there is more than 1 param
|
||||
if (i < (paramCount - 1)) {
|
||||
methodparams += ", ";
|
||||
methodvariables += ", ";
|
||||
}
|
||||
}
|
||||
|
||||
this.replaceVariable("helpstring", docStr);
|
||||
this.replaceVariable("returntype", returnType);
|
||||
this.replaceVariable("methodname", methodname);
|
||||
this.replaceVariable("methodparams", methodparams);
|
||||
this.replaceVariable("vtableid", String.valueOf(vtableId));
|
||||
this.replaceVariable("memberid", String.valueOf(memberid));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.platform.win32.COM.tlb.imp.TlbBase#getClassTemplate()
|
||||
*/
|
||||
@Override
|
||||
protected String getClassTemplate() {
|
||||
return "com/sun/jna/platform/win32/COM/tlb/imp/TlbFunctionStub.template";
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
/**
|
||||
* ${helpstring}
|
||||
* Virtual table id: ${vtableid}
|
||||
* Member id: ${memberid}
|
||||
*/
|
||||
public ${returntype} ${methodname}(${methodparams});
|
||||
@@ -1,83 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.ELEMDESC;
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TlbFunction.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TlbFunctionVTable extends TlbAbstractMethod {
|
||||
|
||||
/**
|
||||
* Instantiates a new tlb function.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
* @param funcDesc
|
||||
* the func desc
|
||||
* @param typeInfoUtil
|
||||
* the type info util
|
||||
*/
|
||||
public TlbFunctionVTable(int count, int index, TypeLibUtil typeLibUtil,
|
||||
FUNCDESC funcDesc, TypeInfoUtil typeInfoUtil) {
|
||||
super(index, typeLibUtil, funcDesc, typeInfoUtil);
|
||||
|
||||
String[] names = typeInfoUtil.getNames(funcDesc.memid, paramCount + 1);
|
||||
|
||||
// if there is at least one param we need a comma
|
||||
if (paramCount > 0)
|
||||
methodvariables = ", ";
|
||||
|
||||
for (int i = 0; i < paramCount; i++) {
|
||||
ELEMDESC elemdesc = funcDesc.lprgelemdescParam.elemDescArg[i];
|
||||
String methodName = names[i + 1].toLowerCase();
|
||||
methodparams += this.getType(elemdesc.tdesc) + " "
|
||||
+ this.replaceJavaKeyword(methodName);
|
||||
methodvariables += methodName;
|
||||
|
||||
// if there is more than 1 param
|
||||
if (i < (paramCount - 1)) {
|
||||
methodparams += ", ";
|
||||
methodvariables += ", ";
|
||||
}
|
||||
}
|
||||
|
||||
this.replaceVariable("helpstring", docStr);
|
||||
this.replaceVariable("returntype", returnType);
|
||||
this.replaceVariable("methodname", methodName);
|
||||
this.replaceVariable("methodparams", methodparams);
|
||||
this.replaceVariable("methodvariables", methodvariables);
|
||||
this.replaceVariable("vtableid", String.valueOf(vtableId));
|
||||
this.replaceVariable("memberid", String.valueOf(memberid));
|
||||
this.replaceVariable("functionCount", String.valueOf(count));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.platform.win32.COM.tlb.imp.TlbBase#getClassTemplate()
|
||||
*/
|
||||
@Override
|
||||
protected String getClassTemplate() {
|
||||
return "com/sun/jna/platform/win32/COM/tlb/imp/TlbFunctionVTable.template";
|
||||
}
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* ${helpstring}
|
||||
* Virtual table id: ${vtableid}
|
||||
* Member id: ${memberid}
|
||||
*/
|
||||
public ${returntype} ${methodname}(${methodparams}) {
|
||||
return (${returntype})this._invokeNativeObject(${functionCount}, new Object[] { this.getPointer()${methodvariables}}, ${returntype}.class);
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEATTR;
|
||||
import com.sun.jna.platform.win32.OaIdl.VARDESC;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil.TypeInfoDoc;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil.TypeLibDoc;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TlbInterface.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TlbInterface extends TlbBase {
|
||||
|
||||
/**
|
||||
* Instantiates a new tlb interface.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
*/
|
||||
public TlbInterface(int index, String packagename, TypeLibUtil typeLibUtil) {
|
||||
super(index, typeLibUtil, null);
|
||||
|
||||
TypeLibDoc typeLibDoc = this.typeLibUtil.getDocumentation(index);
|
||||
String docString = typeLibDoc.getDocString();
|
||||
|
||||
if (typeLibDoc.getName().length() > 0)
|
||||
this.name = typeLibDoc.getName();
|
||||
|
||||
this.logInfo("Type of kind 'Interface' found: " + this.name);
|
||||
|
||||
this.createPackageName(packagename);
|
||||
this.createClassName(this.name);
|
||||
this.setFilename(this.name);
|
||||
|
||||
// Get the TypeAttributes
|
||||
TypeInfoUtil typeInfoUtil = typeLibUtil.getTypeInfoUtil(index);
|
||||
TYPEATTR typeAttr = typeInfoUtil.getTypeAttr();
|
||||
|
||||
this.createJavaDocHeader(typeAttr.guid.toGuidString(), docString);
|
||||
|
||||
int cVars = typeAttr.cVars.intValue();
|
||||
for (int i = 0; i < cVars; i++) {
|
||||
// Get the property description
|
||||
VARDESC varDesc = typeInfoUtil.getVarDesc(i);
|
||||
VARIANT constValue = varDesc._vardesc.lpvarValue;
|
||||
Object value = constValue.getValue();
|
||||
|
||||
// Get the member ID
|
||||
MEMBERID memberID = varDesc.memid;
|
||||
|
||||
// Get the name of the property
|
||||
TypeInfoDoc typeInfoDoc2 = typeInfoUtil.getDocumentation(memberID);
|
||||
this.content += TABTAB + "//" + typeInfoDoc2.getName() + CR;
|
||||
this.content += TABTAB + "public static final int "
|
||||
+ typeInfoDoc2.getName() + " = " + value.toString() + ";";
|
||||
|
||||
if (i < cVars - 1)
|
||||
this.content += CR;
|
||||
}
|
||||
|
||||
this.createContent(this.content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the java doc header.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
* @param helpstring
|
||||
* the helpstring
|
||||
*/
|
||||
protected void createJavaDocHeader(String guid, String helpstring) {
|
||||
this.replaceVariable("uuid", guid);
|
||||
this.replaceVariable("helpstring", helpstring);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.platform.win32.COM.tlb.imp.TlbBase#getClassTemplate()
|
||||
*/
|
||||
@Override
|
||||
protected String getClassTemplate() {
|
||||
return "com/sun/jna/platform/win32/COM/tlb/imp/TlbInterface.template";
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package ${packagename};
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.jna.*;
|
||||
import com.sun.jna.platform.win32.*;
|
||||
import com.sun.jna.platform.win32.OaIdl.*;
|
||||
import com.sun.jna.platform.win32.WinDef.*;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.*;
|
||||
import com.sun.jna.platform.win32.COM.*;
|
||||
import com.sun.jna.platform.win32.Guid.*;
|
||||
|
||||
/**
|
||||
* uuid(${uuid})
|
||||
* version(${version})
|
||||
* helpstring(${helpstring})
|
||||
*
|
||||
*/
|
||||
public interface ${classname} extends IUnknown {
|
||||
|
||||
${content}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
public class TlbParameterNotFoundException extends RuntimeException {
|
||||
|
||||
public TlbParameterNotFoundException() {
|
||||
}
|
||||
|
||||
public TlbParameterNotFoundException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public TlbParameterNotFoundException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public TlbParameterNotFoundException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TlbPropertyGet.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TlbPropertyGet extends TlbAbstractMethod {
|
||||
|
||||
/**
|
||||
* Instantiates a new tlb property get.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
* @param funcDesc
|
||||
* the func desc
|
||||
* @param typeInfoUtil
|
||||
* the type info util
|
||||
*/
|
||||
public TlbPropertyGet(int count, int index, TypeLibUtil typeLibUtil,
|
||||
FUNCDESC funcDesc, TypeInfoUtil typeInfoUtil) {
|
||||
super(index, typeLibUtil, funcDesc, typeInfoUtil);
|
||||
|
||||
this.methodName = "get" + this.getMethodName();
|
||||
|
||||
this.replaceVariable("helpstring", docStr);
|
||||
this.replaceVariable("returntype", returnType);
|
||||
this.replaceVariable("methodname", methodName);
|
||||
this.replaceVariable("vtableid", String.valueOf(vtableId));
|
||||
this.replaceVariable("memberid", String.valueOf(memberid));
|
||||
this.replaceVariable("functionCount", String.valueOf(count));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.platform.win32.COM.tlb.imp.TlbBase#getClassTemplate()
|
||||
*/
|
||||
@Override
|
||||
protected String getClassTemplate() {
|
||||
return "com/sun/jna/platform/win32/COM/tlb/imp/TlbPropertyGet.template";
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* ${helpstring}
|
||||
* Virtual table id: ${vtableid}
|
||||
* Member id: ${memberid}
|
||||
*/
|
||||
public ${returntype} ${methodname}() {
|
||||
return (${returntype})this._invokeNativeObject(${functionCount}, new Object[] { this.getPointer() }, ${returntype}.class);
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil.TypeInfoDoc;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TlbPropertyGet.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TlbPropertyGetStub extends TlbAbstractMethod {
|
||||
|
||||
/**
|
||||
* Instantiates a new tlb property get.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
* @param funcDesc
|
||||
* the func desc
|
||||
* @param typeInfoUtil
|
||||
* the type info util
|
||||
*/
|
||||
public TlbPropertyGetStub(int index, TypeLibUtil typeLibUtil,
|
||||
FUNCDESC funcDesc, TypeInfoUtil typeInfoUtil) {
|
||||
super(index, typeLibUtil, funcDesc, typeInfoUtil);
|
||||
|
||||
TypeInfoDoc typeInfoDoc = typeInfoUtil.getDocumentation(funcDesc.memid);
|
||||
String docStr = typeInfoDoc.getDocString();
|
||||
String methodname = "get" + typeInfoDoc.getName();
|
||||
|
||||
this.replaceVariable("helpstring", docStr);
|
||||
this.replaceVariable("returntype", returnType);
|
||||
this.replaceVariable("methodname", methodname);
|
||||
this.replaceVariable("vtableid", String.valueOf(vtableId));
|
||||
this.replaceVariable("memberid", String.valueOf(memberid));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.platform.win32.COM.tlb.imp.TlbBase#getClassTemplate()
|
||||
*/
|
||||
@Override
|
||||
protected String getClassTemplate() {
|
||||
return "com/sun/jna/platform/win32/COM/tlb/imp/TlbPropertyGetStub.template";
|
||||
}
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
/**
|
||||
* ${helpstring}
|
||||
* Virtual table id: ${vtableid}
|
||||
* Member id: ${memberid}
|
||||
*/
|
||||
public ${returntype} ${methodname}();
|
||||
@@ -1,82 +0,0 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM.tlb.imp;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.ELEMDESC;
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.COM.TypeInfoUtil;
|
||||
import com.sun.jna.platform.win32.COM.TypeLibUtil;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TlbPropertyPut.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TlbPropertyPut extends TlbAbstractMethod {
|
||||
|
||||
/**
|
||||
* Instantiates a new tlb property set.
|
||||
*
|
||||
* @param index
|
||||
* the index
|
||||
* @param typeLibUtil
|
||||
* the type lib util
|
||||
* @param funcDesc
|
||||
* the func desc
|
||||
* @param typeInfoUtil
|
||||
* the type info util
|
||||
*/
|
||||
public TlbPropertyPut(int count, int index, TypeLibUtil typeLibUtil,
|
||||
FUNCDESC funcDesc, TypeInfoUtil typeInfoUtil) {
|
||||
super(index, typeLibUtil, funcDesc, typeInfoUtil);
|
||||
|
||||
this.methodName = "set" + getMethodName();
|
||||
String[] names = typeInfoUtil.getNames(funcDesc.memid, paramCount + 1);
|
||||
|
||||
if (paramCount > 0)
|
||||
methodvariables += ", ";
|
||||
|
||||
for (int i = 0; i < paramCount; i++) {
|
||||
ELEMDESC elemdesc = funcDesc.lprgelemdescParam.elemDescArg[i];
|
||||
String varType = this.getType(elemdesc);
|
||||
methodparams += varType + " "
|
||||
+ this.replaceJavaKeyword(names[i].toLowerCase());
|
||||
methodvariables += this.replaceJavaKeyword(names[i].toLowerCase());
|
||||
|
||||
// if there is more than 1 param
|
||||
if (i < (paramCount - 1)) {
|
||||
methodparams += ", ";
|
||||
methodvariables += ", ";
|
||||
}
|
||||
}
|
||||
|
||||
this.replaceVariable("helpstring", docStr);
|
||||
this.replaceVariable("methodname", methodName);
|
||||
this.replaceVariable("methodparams", methodparams);
|
||||
this.replaceVariable("methodvariables", methodvariables);
|
||||
this.replaceVariable("vtableid", String.valueOf(vtableId));
|
||||
this.replaceVariable("memberid", String.valueOf(memberid));
|
||||
this.replaceVariable("functionCount", String.valueOf(count));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.platform.win32.COM.tlb.imp.TlbBase#getClassTemplate()
|
||||
*/
|
||||
@Override
|
||||
protected String getClassTemplate() {
|
||||
return "com/sun/jna/platform/win32/COM/tlb/imp/TlbPropertyPut.template";
|
||||
}
|
||||
}
|
||||
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário