Comparar commits
119 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| 2e4c4349dd | |||
| 5d4e9b14fd | |||
| 75a532b088 | |||
| 8aa8a2e090 | |||
| 4836f05059 | |||
| ed35e7b973 | |||
| 4e4dbda6f0 | |||
| 6756267f48 | |||
| 87200e8006 | |||
| 35c743df72 | |||
| c94c3b9ee0 | |||
| 1d0988127d | |||
| e736b45a35 | |||
| e67a50c904 | |||
| 6f37195ce2 | |||
| 9785311050 | |||
| ed5dac53cc | |||
| 6b25643334 | |||
| 667fdd1e32 | |||
| a0c486f826 | |||
| a41d97d9e8 | |||
| 30b64fb78c | |||
| f277c9dce2 | |||
| c7dcf61bb6 | |||
| 438d1313fc | |||
| e465dca4ce | |||
| 99bd756eab | |||
| b2e16d4f6c | |||
| 6f13f2e6d9 | |||
| f5d7955f41 | |||
| 0aab1f52a5 | |||
| 8dd1592f70 | |||
| eaf9e25461 | |||
| deb7cc68f4 | |||
| 5b3a782ab7 | |||
| 66fcd236cf | |||
| 487dab42de | |||
| bb27c09164 | |||
| f6ceaf3355 | |||
| cb8f9dd7df | |||
| 395bffcf72 | |||
| 35cc5e2e31 | |||
| 4df5e827a7 | |||
| 8de77d3df3 | |||
| 8a4a7e1b1a | |||
| 7dc7547271 | |||
| 4ee5e0efec | |||
| e79f6e0e04 | |||
| 9de200502a | |||
| 57197d3cc8 | |||
| e4a1158b50 | |||
| 23a7cbaf11 | |||
| 21765f9a9c | |||
| bc0b30fec5 | |||
| 6883010c0f | |||
| 3fc7603da8 | |||
| 79c3521c94 | |||
| 1d6fa14851 | |||
| ddecf09700 | |||
| e9d3793b61 | |||
| 5ec1f87113 | |||
| f35fe81b40 | |||
| 4d0f5ab5d5 | |||
| 919a31f16e | |||
| 938ee0ddd8 | |||
| 4f9260b35e | |||
| 6e0690aa70 | |||
| 854165453a | |||
| 04d74c8ba5 | |||
| 0ddf39c979 | |||
| 842904ad44 | |||
| 20b582e97b | |||
| 2553a95c95 | |||
| f989080691 | |||
| 02230ef692 | |||
| d8d9c62de1 | |||
| c1ac91e00f | |||
| 4f1f03346f | |||
| 8c9e2e67ef | |||
| 2c32c5596e | |||
| af8c85428d | |||
| 2bb0ac91d1 | |||
| 8f24f1d82a | |||
| 6762c42a18 | |||
| f1903d903c | |||
| 2ee9962838 | |||
| 9f4155a150 | |||
| 44f6e5ab76 | |||
| b10c508a6b | |||
| 70f3c4757f | |||
| 15b2df4acf | |||
| 3157243deb | |||
| 95526ab823 | |||
| cf6b5e4dce | |||
| 4b245b9053 | |||
| 923cd5a937 | |||
| 342afd7221 | |||
| 91a9bd6ab3 | |||
| b980a28c91 | |||
| 3f182664be | |||
| 327b429d79 | |||
| 55cca7220a | |||
| 528036e9e3 | |||
| 7ae490a393 | |||
| 4c114f7796 | |||
| 4f84e1b325 | |||
| d7ed79ea07 | |||
| 68010b6752 | |||
| d74598979a | |||
| 6166a169e3 | |||
| 2a51bbfba5 | |||
| d56c74724c | |||
| 27e9f0f005 | |||
| 832845535a | |||
| fcf1f5c283 | |||
| 47d1f3cc89 | |||
| 58b89ebc55 | |||
| bbc1d4b432 | |||
| e00752087b |
@@ -1,8 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="jna/build.eclipse/test-classes" path="contrib/platform/test"/>
|
||||
<classpathentry kind="src" path="contrib/platform/src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/test-classes" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
#Wed Aug 29 20:43:29 EDT 2007
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
@@ -1,3 +0,0 @@
|
||||
#Tue Mar 27 21:18:08 EDT 2007
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
||||
+28
-3
@@ -1,10 +1,34 @@
|
||||
Release 4.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 (4.0.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).
|
||||
|
||||
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).
|
||||
@@ -676,3 +700,4 @@ Bug Fixes
|
||||
* 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
|
||||
|
||||
|
||||
+5
-3
@@ -21,7 +21,7 @@ Download
|
||||
Version 4.0
|
||||
|
||||
* [jna.jar](https://maven.java.net/content/repositories/releases/net/java/dev/jna/jna/4.0.0/jna-4.0.0.jar)
|
||||
* [jna-platform.jar](https://maven.java.net/content/repositories/releases/net/java/dev/jna/platform/4.0.0/jna-platform-4.0.0.jar)
|
||||
* [jna-platform.jar](https://maven.java.net/content/repositories/releases/net/java/dev/jna/jna-platform/4.0.0/jna-platform-4.0.0.jar)
|
||||
|
||||
Features
|
||||
========
|
||||
@@ -46,6 +46,8 @@ Features
|
||||
* 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
|
||||
=====================
|
||||
@@ -79,12 +81,12 @@ Using the Library
|
||||
* [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.0.0/javadoc/overview-summary.html#crash-protection)
|
||||
* [Avoiding Crashes](http://twall.github.com/jna/4.0/javadoc/overview-summary.html#crash-protection)
|
||||
|
||||
Primary Documentation (JavaDoc)
|
||||
===============================
|
||||
|
||||
The definitive JNA reference is in the [JavaDoc](http://twall.github.com/jna/4.0.0/javadoc/).
|
||||
The definitive JNA reference is in the [JavaDoc](http://twall.github.com/jna/4.0/javadoc/).
|
||||
|
||||
Developers
|
||||
==========
|
||||
|
||||
+25
-3
@@ -57,7 +57,7 @@
|
||||
<!-- JNA library release version -->
|
||||
<property name="jna.major" value="4"/>
|
||||
<property name="jna.minor" value="0"/>
|
||||
<property name="jna.revision" value="0"/>
|
||||
<property name="jna.revision" value="1"/>
|
||||
<property name="jna.build" value="${build.number}"/>
|
||||
<condition property="version.suffix" value="" else="-SNAPSHOT">
|
||||
<or>
|
||||
@@ -356,7 +356,7 @@
|
||||
<attribute name="Bundle-Name" value="jna"/>
|
||||
<attribute name="Bundle-Description" value="JNA Library"/>
|
||||
<attribute name="Bundle-SymbolicName" value="com.sun.jna"/>
|
||||
<attribute name="Bundle-Version" value="${spec.version}"/>
|
||||
<attribute name="Bundle-Version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
|
||||
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
|
||||
<attribute name="Bundle-Vendor" value="${vendor}"/>
|
||||
<attribute name="Bundle-ActivationPolicy" value="lazy"/>
|
||||
@@ -489,6 +489,14 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
|
||||
<property name="libs.junit.classpath" location="lib/junit.jar"/>
|
||||
<property name="javac.source" value="${platform.compatibility}"/>
|
||||
<property name="javac.target" value="${platform.compatibility}"/>
|
||||
<!-- OSGi manifest properties -->
|
||||
<property name="vendor" value="${vendor}"/>
|
||||
<property name="impl.title" value="${impl.title}.platform"/>
|
||||
<property name="impl.version" value="${impl.version}"/>
|
||||
<property name="spec.title" value="${spec.title}"/>
|
||||
<property name="spec.vendor" value="${spec.vendor}"/>
|
||||
<property name="spec.version" value="${spec.version}"/>
|
||||
<property name="osgi.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
|
||||
<fileset dir="${contrib}" includes="platform/build.xml" />
|
||||
</subant>
|
||||
<!-- Sources package as required by maven -->
|
||||
@@ -760,6 +768,20 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="compile-some-tests" depends="compile,jar"
|
||||
description="Compile test code which does not have additional native
|
||||
dependencies">
|
||||
<javac classpathref="compile-test.path"
|
||||
source="${test.compatibility}"
|
||||
target="${test.compatibility}"
|
||||
destdir="${test.classes}"
|
||||
includeantruntime="false"
|
||||
includes="**/StructureFieldOrderInspector.java"
|
||||
deprecation="on" debug="${debug}">
|
||||
<src path="${test.src}"/>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="compile-tests" depends="compile,native,jar"
|
||||
description="Compile all test code">
|
||||
<javac classpathref="compile-test.path"
|
||||
@@ -906,7 +928,7 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
|
||||
<fail if="testfailure" unless="clover">One or more tests failed</fail>
|
||||
</target>
|
||||
|
||||
<target name="test-platform" depends="compile-tests,platform-jar">
|
||||
<target name="test-platform" depends="compile-some-tests,platform-jar">
|
||||
<subant target="test" failonerror="true" inheritall="true" inheritrefs="true">
|
||||
<property name="file.reference.jna.build" location="${build}"/>
|
||||
<property name="file.reference.jna.jar" location="${build}/${jar}"/>
|
||||
|
||||
@@ -72,7 +72,7 @@ import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION;
|
||||
import com.sun.jna.platform.win32.WinUser.POINT;
|
||||
import com.sun.jna.platform.win32.WinDef.POINT;
|
||||
import com.sun.jna.platform.win32.WinUser.SIZE;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
@@ -438,7 +438,7 @@ public class AlphaMaskDemo implements Runnable {
|
||||
if (flavor != null) {
|
||||
Reader reader = flavor.getReaderForText(t);
|
||||
char[] buf = new char[512];
|
||||
StringBuffer b = new StringBuffer();
|
||||
StringBuilder b = new StringBuilder();
|
||||
int count;
|
||||
// excise excess NUL characters (bug in firefox, java
|
||||
// or my code, not sure which). someone got the
|
||||
|
||||
@@ -200,7 +200,7 @@ public class AlphaMaskDemo2 implements Runnable {
|
||||
if (flavor != null) {
|
||||
Reader reader = flavor.getReaderForText(t);
|
||||
char[] buf = new char[512];
|
||||
StringBuffer b = new StringBuffer();
|
||||
StringBuilder b = new StringBuilder();
|
||||
int count;
|
||||
// excise excess NUL characters (bug in firefox,
|
||||
// java
|
||||
|
||||
@@ -256,8 +256,8 @@ public class FilteredTextField extends JTextField {
|
||||
balloon.hide();
|
||||
}
|
||||
}
|
||||
StringBuffer buffer =
|
||||
new StringBuffer(FilteredTextField.this.getText());
|
||||
StringBuilder buffer =
|
||||
new StringBuilder(FilteredTextField.this.getText());
|
||||
if (offset >= 0 && offset <= buffer.length()) {
|
||||
buffer.insert(offset, str);
|
||||
String strBuf = buffer.toString();
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
<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="lib" path="C:/GitHub/jna-3.5.1.jar"/>
|
||||
<classpathentry kind="var" path="JNA_LIB"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/com/sun/jna/platform/win32/office/MSWord.java=UTF-8
|
||||
Arquivo binário não exibido.
Arquivo binário não exibido.
+9
-2
@@ -1,4 +1,4 @@
|
||||
package com.sun.jna.platform.win32.office;
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
@@ -10,10 +10,11 @@ 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();
|
||||
FileWriter writer = new FileWriter(filename);
|
||||
writer = new FileWriter(filename);
|
||||
|
||||
for (COMInfo comInfo : comInfos) {
|
||||
String result = "CLSID: " + comInfo.clsid + "\n";
|
||||
@@ -31,6 +32,12 @@ public class COMInfoUtil {
|
||||
+ comInfos.size());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
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;
|
||||
LONG wdFormatPDF = new LONG(17); // PDF format.
|
||||
LONG wdFormatRTF = new LONG(6); // Rich text format (RTF).
|
||||
LONG wdFormatHTML = new LONG(8); // Standard HTML 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!");
|
||||
// wait 10sec. before closing
|
||||
Thread.currentThread().sleep(10000);
|
||||
// save in different formats
|
||||
// pdf format is only supported in MSWord 2007 and above
|
||||
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(true);
|
||||
msWord.setVisible(true);
|
||||
msWord.newDocument();
|
||||
// msWord.openDocument(currentWorkingDir + "jnatest.doc", true);
|
||||
msWord.insertText("Hello from JNA!");
|
||||
// close and save the document
|
||||
msWord.closeActiveDocument(true);
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
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 SaveAs(String FileName, LONG FileFormat) throws COMException {
|
||||
VARIANT vtFileName = new VARIANT(FileName);
|
||||
VARIANT vtFileFormat = new VARIANT(FileFormat);
|
||||
|
||||
this.invokeNoReply("SaveAs", this.getActiveDocument().getIDispatch(),
|
||||
vtFileName, vtFileFormat);
|
||||
}
|
||||
|
||||
public ActiveDocument getActiveDocument() {
|
||||
return new ActiveDocument(this.getAutomationProperty("ActiveDocument"));
|
||||
}
|
||||
|
||||
public Documents getDocuments() {
|
||||
// GetDocuments
|
||||
return new Documents(this.getAutomationProperty("Documents"));
|
||||
}
|
||||
|
||||
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,162 +0,0 @@
|
||||
package com.sun.jna.platform.win32.office;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.VARIANT_BOOL;
|
||||
import com.sun.jna.platform.win32.OleAuto;
|
||||
import com.sun.jna.platform.win32.Variant;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.COM.COMException;
|
||||
import com.sun.jna.platform.win32.COM.COMObject;
|
||||
import com.sun.jna.platform.win32.COM.COMUtils;
|
||||
import com.sun.jna.platform.win32.COM.IDispatch;
|
||||
|
||||
public class MSExcel extends COMObject {
|
||||
|
||||
public MSExcel() throws COMException {
|
||||
super("Excel.Application", false);
|
||||
}
|
||||
|
||||
public MSExcel(boolean visible) throws COMException {
|
||||
this();
|
||||
this.setVisible(Variant.VARIANT_TRUE);
|
||||
}
|
||||
|
||||
public void setVisible(VARIANT_BOOL bVisible) throws COMException {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, result, this.iDispatch,
|
||||
"Visible", new VARIANT(bVisible));
|
||||
}
|
||||
|
||||
public String getVersion() throws COMException {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
|
||||
"Version");
|
||||
|
||||
return result.getValue().toString();
|
||||
}
|
||||
|
||||
public HRESULT newExcelBook() throws COMException {
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null, getWorkbooks()
|
||||
.getIDispatch(), "Add");
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT openExcelBook(String filename, boolean bVisible)
|
||||
throws COMException {
|
||||
// OpenDocument
|
||||
BSTR bstrFilename = OleAuto.INSTANCE.SysAllocString(filename);
|
||||
VARIANT varFilename = new VARIANT(bstrFilename);
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null, getWorkbooks()
|
||||
.getIDispatch(), "Open", varFilename);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT closeActiveWorkbook(VARIANT_BOOL bSave) throws COMException {
|
||||
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
getActiveWorkbook().getIDispatch(), "Close", new VARIANT(bSave));
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT quit() throws COMException {
|
||||
HRESULT hr = this.oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
this.iDispatch, "Quit");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT insertValue(String range, String value) throws COMException {
|
||||
HRESULT hr;
|
||||
|
||||
BSTR bstrRange = OleAuto.INSTANCE.SysAllocString(range);
|
||||
VARIANT varRange = new VARIANT(bstrRange);
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this
|
||||
.getActiveSheet().getIDispatch(), "Range", varRange);
|
||||
Range pRange = new Range((IDispatch) result.getValue());
|
||||
|
||||
BSTR bstrValue = OleAuto.INSTANCE.SysAllocString(value);
|
||||
VARIANT varText = new VARIANT(bstrValue);
|
||||
hr = oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null,
|
||||
pRange.getIDispatch(), "Value", varText);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public Application getApplication() {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.iDispatch, "Application");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new Application((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public ActiveWorkbook getActiveWorkbook() {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.iDispatch, "ActiveWorkbook");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new ActiveWorkbook((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public Workbooks getWorkbooks() {
|
||||
// GetDocuments
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.iDispatch, "WorkBooks");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new Workbooks((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public ActiveSheet getActiveSheet() {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.iDispatch, "ActiveSheet");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new ActiveSheet((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public class Application extends COMObject {
|
||||
|
||||
public Application(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class Workbooks extends COMObject {
|
||||
|
||||
public Workbooks(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class ActiveWorkbook extends COMObject {
|
||||
|
||||
public ActiveWorkbook(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class ActiveSheet extends COMObject {
|
||||
|
||||
public ActiveSheet(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class Range extends COMObject {
|
||||
|
||||
public Range(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package com.sun.jna.platform.win32.office;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.sun.jna.platform.win32.Variant;
|
||||
import com.sun.jna.platform.win32.COM.COMException;
|
||||
|
||||
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;
|
||||
|
||||
try {
|
||||
msWord = new MSWord();
|
||||
System.out.println("MSWord version: " + msWord.getVersion());
|
||||
msWord.setVisible(Variant.VARIANT_TRUE);
|
||||
msWord.newDocument();
|
||||
//msWord.openDocument(currentWorkingDir + "jnatest.doc", true);
|
||||
msWord.insertText("Hello from JNA!");
|
||||
// close and save the document
|
||||
msWord.closeActiveDocument(Variant.VARIANT_TRUE);
|
||||
// wait then close word
|
||||
msWord.quit();
|
||||
} catch (COMException e) {
|
||||
if (e.getExcepInfo() != null) {
|
||||
System.out
|
||||
.println("bstrSource: " + e.getExcepInfo().bstrSource);
|
||||
System.out.println("bstrDescription: "
|
||||
+ e.getExcepInfo().bstrDescription);
|
||||
} else
|
||||
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(Variant.VARIANT_TRUE);
|
||||
//msExcel.newExcelBook();
|
||||
msExcel.openExcelBook(currentWorkingDir + "jnatest.xls", true);
|
||||
msExcel.insertValue("A1", "Hello from JNA!");
|
||||
// close and save the active sheet
|
||||
msExcel.closeActiveWorkbook(Variant.VARIANT_TRUE);
|
||||
// wait then close excel
|
||||
msExcel.quit();
|
||||
} catch (COMException e) {
|
||||
if (e.getExcepInfo() != null) {
|
||||
System.out
|
||||
.println("bstrSource: " + e.getExcepInfo().bstrSource);
|
||||
System.out.println("bstrDescription: "
|
||||
+ e.getExcepInfo().bstrDescription);
|
||||
} else
|
||||
e.printStackTrace();
|
||||
|
||||
if(msExcel != null)
|
||||
msExcel.quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
package com.sun.jna.platform.win32.office;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.VARIANT_BOOL;
|
||||
import com.sun.jna.platform.win32.OleAuto;
|
||||
import com.sun.jna.platform.win32.Variant;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.COM.COMException;
|
||||
import com.sun.jna.platform.win32.COM.COMObject;
|
||||
import com.sun.jna.platform.win32.COM.COMUtils;
|
||||
import com.sun.jna.platform.win32.COM.IDispatch;
|
||||
|
||||
public class MSWord extends COMObject {
|
||||
|
||||
public MSWord() throws COMException {
|
||||
super("Word.Application", false);
|
||||
}
|
||||
|
||||
public MSWord(boolean visible) throws COMException {
|
||||
this();
|
||||
this.setVisible(Variant.VARIANT_TRUE);
|
||||
}
|
||||
|
||||
public void setVisible(VARIANT_BOOL bVisible) throws COMException {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, result, this.iDispatch,
|
||||
"Visible", new VARIANT(bVisible));
|
||||
}
|
||||
|
||||
public String getVersion() throws COMException {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
|
||||
"Version");
|
||||
|
||||
return result.getValue().toString();
|
||||
}
|
||||
|
||||
public HRESULT newDocument() throws COMException {
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
getDocuments().getIDispatch(), "Add");
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT openDocument(String filename, boolean bVisible)
|
||||
throws COMException {
|
||||
// OpenDocument
|
||||
BSTR bstrFilename = OleAuto.INSTANCE.SysAllocString(filename);
|
||||
VARIANT varFilename = new VARIANT(bstrFilename);
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
getDocuments().getIDispatch(), "Open", varFilename);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT closeActiveDocument(VARIANT_BOOL bSave)
|
||||
throws COMException {
|
||||
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
getActiveDocument().getIDispatch(), "Close", new VARIANT(bSave));
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT quit() throws COMException {
|
||||
HRESULT hr = this.oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
this.iDispatch, "Quit");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT insertText(String text) throws COMException {
|
||||
HRESULT hr;
|
||||
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.iDispatch, "Selection");
|
||||
Selection pSelection = new Selection((IDispatch) result.getValue());
|
||||
|
||||
BSTR bstrText = OleAuto.INSTANCE.SysAllocString(text);
|
||||
VARIANT varText = new VARIANT(bstrText);
|
||||
hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
pSelection.getIDispatch(), "TypeText", varText);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public ActiveDocument getActiveDocument() {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
|
||||
"ActiveDocument");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new ActiveDocument((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public Documents getDocuments() {
|
||||
// GetDocuments
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
|
||||
"Documents");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new Documents((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public Application getApplication() {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
|
||||
"Application");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new Application((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public class Application extends COMObject {
|
||||
|
||||
public Application(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class Documents extends COMObject {
|
||||
|
||||
public Documents(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class ActiveDocument extends COMObject {
|
||||
|
||||
public ActiveDocument(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class Selection extends COMObject {
|
||||
|
||||
public Selection(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,11 @@ 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;
|
||||
@@ -59,7 +64,9 @@ public class Win32WindowDemo implements WindowProc {
|
||||
User32.WS_EX_TOPMOST,
|
||||
windowClass,
|
||||
"My hidden helper window, used only to catch the windows events",
|
||||
0, 0, 0, 0, 0, WinUser.HWND_MESSAGE, null, hInst, null);
|
||||
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: "
|
||||
@@ -74,6 +81,7 @@ public class Win32WindowDemo implements WindowProc {
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -125,8 +133,9 @@ public class Win32WindowDemo implements WindowProc {
|
||||
return new LRESULT(0);
|
||||
}
|
||||
case WinUser.WM_DEVICECHANGE: {
|
||||
this.onDeviceChange(wParam, lParam);
|
||||
return new LRESULT(0);
|
||||
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);
|
||||
@@ -251,42 +260,101 @@ public class Win32WindowDemo implements WindowProc {
|
||||
* the w param
|
||||
* @param lParam
|
||||
* the l param
|
||||
* @return the result. Null if the message is not processed.
|
||||
*/
|
||||
protected void onDeviceChange(WPARAM wParam, LPARAM lParam) {
|
||||
//
|
||||
// This is the actual message from the interface via Windows messaging.
|
||||
// This code includes some additional decoding for this particular
|
||||
// device type
|
||||
// and some common validation checks.
|
||||
//
|
||||
// Note that not all devices utilize these optional parameters in the
|
||||
// same
|
||||
// way. Refer to the extended information for your particular device
|
||||
// type
|
||||
// specified by your GUID.
|
||||
//
|
||||
DEV_BROADCAST_DEVICEINTERFACE bdif = new DEV_BROADCAST_DEVICEINTERFACE(
|
||||
lParam.longValue());
|
||||
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());
|
||||
|
||||
// Output some messages to the window.
|
||||
protected LRESULT onDeviceChange(WPARAM wParam, LPARAM lParam) {
|
||||
switch (wParam.intValue()) {
|
||||
case DBT.DBT_DEVICEARRIVAL:
|
||||
System.out.println("Message DBT_DEVICEARRIVAL");
|
||||
break;
|
||||
case DBT.DBT_DEVICEREMOVECOMPLETE:
|
||||
System.out.println("Message DBT_DEVICEREMOVECOMPLETE");
|
||||
break;
|
||||
case DBT.DBT_DEVNODES_CHANGED:
|
||||
System.out.println("Message DBT_DEVNODES_CHANGED");
|
||||
break;
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,12 +57,54 @@
|
||||
</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
|
||||
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.
|
||||
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"/>
|
||||
@@ -106,7 +148,7 @@
|
||||
<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}"/></classpath>
|
||||
<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}">
|
||||
|
||||
@@ -21,7 +21,8 @@ file.reference.jna-test.jar=../../build/jna-test.jar
|
||||
libs.junit.classpath=../../lib/junit.jar
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jna.jar}
|
||||
${file.reference.jna.jar}:\
|
||||
${file.reference.jna.build}/test-classes
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
|
||||
@@ -80,7 +80,7 @@ import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION;
|
||||
import com.sun.jna.platform.win32.WinUser.POINT;
|
||||
import com.sun.jna.platform.win32.WinDef.POINT;
|
||||
import com.sun.jna.platform.win32.WinUser.SIZE;
|
||||
import com.sun.jna.ptr.ByteByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
@@ -258,7 +258,7 @@ public abstract class Advapi32Util {
|
||||
if (!Advapi32.INSTANCE.ConvertSidToStringSid(sid, stringSid)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
String result = stringSid.getValue().getString(0, true);
|
||||
String result = stringSid.getValue().getWideString(0);
|
||||
Kernel32.INSTANCE.LocalFree(stringSid.getValue());
|
||||
return result;
|
||||
}
|
||||
@@ -544,28 +544,7 @@ public abstract class Advapi32Util {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0,
|
||||
lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_SZ
|
||||
&& lpType.getValue() != WinNT.REG_EXPAND_SZ) {
|
||||
throw new RuntimeException("Unexpected registry type "
|
||||
+ lpType.getValue()
|
||||
+ ", expected REG_SZ or REG_EXPAND_SZ");
|
||||
}
|
||||
char[] data = new char[lpcbData.getValue()];
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0,
|
||||
lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return Native.toString(data);
|
||||
return registryGetStringValue(phkKey.getValue(), value);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
@@ -574,6 +553,40 @@ public abstract class Advapi32Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry REG_SZ value.
|
||||
*
|
||||
* @param hKey
|
||||
* Parent Key.
|
||||
* @param value
|
||||
* Name of the value to retrieve.
|
||||
* @return String value.
|
||||
*/
|
||||
public static String registryGetStringValue(HKEY hKey, String value) {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
int rc = Advapi32.INSTANCE.RegQueryValueEx(hKey, value, 0,
|
||||
lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_SZ
|
||||
&& lpType.getValue() != WinNT.REG_EXPAND_SZ) {
|
||||
throw new RuntimeException("Unexpected registry type "
|
||||
+ lpType.getValue()
|
||||
+ ", expected REG_SZ or REG_EXPAND_SZ");
|
||||
}
|
||||
char[] data = new char[lpcbData.getValue()];
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(hKey, value, 0,
|
||||
lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return Native.toString(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry REG_EXPAND_SZ value.
|
||||
*
|
||||
@@ -594,26 +607,7 @@ public abstract class Advapi32Util {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0,
|
||||
lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_EXPAND_SZ) {
|
||||
throw new RuntimeException("Unexpected registry type "
|
||||
+ lpType.getValue() + ", expected REG_SZ");
|
||||
}
|
||||
char[] data = new char[lpcbData.getValue()];
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0,
|
||||
lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return Native.toString(data);
|
||||
return registryGetExpandableStringValue(phkKey.getValue(), value);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
@@ -622,6 +616,38 @@ public abstract class Advapi32Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry REG_EXPAND_SZ value.
|
||||
*
|
||||
* @param hKey
|
||||
* Parent Key.
|
||||
* @param value
|
||||
* Name of the value to retrieve.
|
||||
* @return String value.
|
||||
*/
|
||||
public static String registryGetExpandableStringValue(HKEY hKey, String value) {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
int rc = Advapi32.INSTANCE.RegQueryValueEx(hKey, value, 0,
|
||||
lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_EXPAND_SZ) {
|
||||
throw new RuntimeException("Unexpected registry type "
|
||||
+ lpType.getValue() + ", expected REG_SZ");
|
||||
}
|
||||
char[] data = new char[lpcbData.getValue()];
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(hKey, value, 0,
|
||||
lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return Native.toString(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry REG_MULTI_SZ value.
|
||||
*
|
||||
@@ -642,38 +668,7 @@ public abstract class Advapi32Util {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0,
|
||||
lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_MULTI_SZ) {
|
||||
throw new RuntimeException("Unexpected registry type "
|
||||
+ lpType.getValue() + ", expected REG_SZ");
|
||||
}
|
||||
Memory data = new Memory(lpcbData.getValue());
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0,
|
||||
lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
int offset = 0;
|
||||
while (offset < data.size()) {
|
||||
String s = data.getString(offset, true);
|
||||
offset += s.length() * Native.WCHAR_SIZE;
|
||||
offset += Native.WCHAR_SIZE;
|
||||
if (s.length() == 0 && offset == data.size()) {
|
||||
// skip the final NULL
|
||||
} else {
|
||||
result.add(s);
|
||||
}
|
||||
}
|
||||
return result.toArray(new String[0]);
|
||||
return registryGetStringArray(phkKey.getValue(), value);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
@@ -682,6 +677,50 @@ public abstract class Advapi32Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry REG_MULTI_SZ value.
|
||||
*
|
||||
* @param hKey
|
||||
* Parent Key.
|
||||
* @param value
|
||||
* Name of the value to retrieve.
|
||||
* @return String value.
|
||||
*/
|
||||
public static String[] registryGetStringArray(HKEY hKey, String value) {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
int rc = Advapi32.INSTANCE.RegQueryValueEx(hKey, value, 0,
|
||||
lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_MULTI_SZ) {
|
||||
throw new RuntimeException("Unexpected registry type "
|
||||
+ lpType.getValue() + ", expected REG_SZ");
|
||||
}
|
||||
Memory data = new Memory(lpcbData.getValue());
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(hKey, value, 0,
|
||||
lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
int offset = 0;
|
||||
while (offset < data.size()) {
|
||||
String s = data.getWideString(offset);
|
||||
offset += s.length() * Native.WCHAR_SIZE;
|
||||
offset += Native.WCHAR_SIZE;
|
||||
if (s.length() == 0 && offset == data.size()) {
|
||||
// skip the final NULL
|
||||
} else {
|
||||
result.add(s);
|
||||
}
|
||||
}
|
||||
return result.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry REG_BINARY value.
|
||||
*
|
||||
@@ -702,26 +741,7 @@ public abstract class Advapi32Util {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0,
|
||||
lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_BINARY) {
|
||||
throw new RuntimeException("Unexpected registry type "
|
||||
+ lpType.getValue() + ", expected REG_BINARY");
|
||||
}
|
||||
byte[] data = new byte[lpcbData.getValue()];
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0,
|
||||
lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return data;
|
||||
return registryGetBinaryValue(phkKey.getValue(), value);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
@@ -730,6 +750,38 @@ public abstract class Advapi32Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry REG_BINARY value.
|
||||
*
|
||||
* @param hKey
|
||||
* Parent Key.
|
||||
* @param value
|
||||
* Name of the value to retrieve.
|
||||
* @return String value.
|
||||
*/
|
||||
public static byte[] registryGetBinaryValue(HKEY hKey, String value) {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
int rc = Advapi32.INSTANCE.RegQueryValueEx(hKey, value, 0,
|
||||
lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_BINARY) {
|
||||
throw new RuntimeException("Unexpected registry type "
|
||||
+ lpType.getValue() + ", expected REG_BINARY");
|
||||
}
|
||||
byte[] data = new byte[lpcbData.getValue()];
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(hKey, value, 0,
|
||||
lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry DWORD value.
|
||||
*
|
||||
@@ -749,26 +801,7 @@ public abstract class Advapi32Util {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0,
|
||||
lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_DWORD) {
|
||||
throw new RuntimeException("Unexpected registry type "
|
||||
+ lpType.getValue() + ", expected REG_DWORD");
|
||||
}
|
||||
IntByReference data = new IntByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0,
|
||||
lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return data.getValue();
|
||||
return registryGetIntValue(phkKey.getValue(), value);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
@@ -777,6 +810,38 @@ public abstract class Advapi32Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry DWORD value.
|
||||
*
|
||||
* @param hKey
|
||||
* Parent key.
|
||||
* @param value
|
||||
* Name of the value to retrieve.
|
||||
* @return Integer value.
|
||||
*/
|
||||
public static int registryGetIntValue(HKEY hKey, String value) {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
int rc = Advapi32.INSTANCE.RegQueryValueEx(hKey, value, 0,
|
||||
lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_DWORD) {
|
||||
throw new RuntimeException("Unexpected registry type "
|
||||
+ lpType.getValue() + ", expected REG_DWORD");
|
||||
}
|
||||
IntByReference data = new IntByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(hKey, value, 0,
|
||||
lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return data.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry QWORD value.
|
||||
*
|
||||
@@ -796,26 +861,7 @@ public abstract class Advapi32Util {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0,
|
||||
lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_QWORD) {
|
||||
throw new RuntimeException("Unexpected registry type "
|
||||
+ lpType.getValue() + ", expected REG_QWORD");
|
||||
}
|
||||
LongByReference data = new LongByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0,
|
||||
lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return data.getValue();
|
||||
return registryGetLongValue(phkKey.getValue(), value);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
@@ -823,6 +869,38 @@ public abstract class Advapi32Util {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry QWORD value.
|
||||
*
|
||||
* @param hKey
|
||||
* Parent key.
|
||||
* @param value
|
||||
* Name of the value to retrieve.
|
||||
* @return Integer value.
|
||||
*/
|
||||
public static long registryGetLongValue(HKEY hKey, String value) {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
int rc = Advapi32.INSTANCE.RegQueryValueEx(hKey, value, 0,
|
||||
lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_QWORD) {
|
||||
throw new RuntimeException("Unexpected registry type "
|
||||
+ lpType.getValue() + ", expected REG_QWORD");
|
||||
}
|
||||
LongByReference data = new LongByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(hKey, value, 0,
|
||||
lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS
|
||||
&& rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return data.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry value and returns a java object depending on the value
|
||||
@@ -866,7 +944,7 @@ public abstract class Advapi32Util {
|
||||
result = byteData.getByteArray(0, lpcbData.getValue());
|
||||
} else if ((lpType.getValue() == WinNT.REG_SZ)
|
||||
|| (lpType.getValue() == WinNT.REG_EXPAND_SZ)) {
|
||||
result = byteData.getString(0, true);
|
||||
result = byteData.getWideString(0);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -1158,7 +1236,7 @@ public abstract class Advapi32Util {
|
||||
int offset = 0;
|
||||
Memory data = new Memory(size);
|
||||
for (String s : arr) {
|
||||
data.setString(offset, s, true);
|
||||
data.setWideString(offset, s);
|
||||
offset += s.length() * Native.WCHAR_SIZE;
|
||||
offset += Native.WCHAR_SIZE;
|
||||
}
|
||||
@@ -1420,6 +1498,19 @@ public abstract class Advapi32Util {
|
||||
|
||||
return phkKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the registry key
|
||||
*
|
||||
* @param hKey
|
||||
* Registry key.
|
||||
*/
|
||||
public static void registryCloseKey(HKEY hKey) {
|
||||
int rc = Advapi32.INSTANCE.RegCloseKey(hKey);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a table of registry values.
|
||||
@@ -1495,7 +1586,7 @@ public abstract class Advapi32Util {
|
||||
}
|
||||
case WinNT.REG_SZ:
|
||||
case WinNT.REG_EXPAND_SZ: {
|
||||
keyValues.put(nameString, byteData.getString(0, true));
|
||||
keyValues.put(nameString, byteData.getWideString(0));
|
||||
break;
|
||||
}
|
||||
case WinNT.REG_BINARY: {
|
||||
@@ -1509,7 +1600,7 @@ public abstract class Advapi32Util {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
int offset = 0;
|
||||
while (offset < stringData.size()) {
|
||||
String s = stringData.getString(offset, true);
|
||||
String s = stringData.getWideString(offset);
|
||||
offset += s.length() * Native.WCHAR_SIZE;
|
||||
offset += Native.WCHAR_SIZE;
|
||||
if (s.length() == 0 && offset == stringData.size()) {
|
||||
@@ -1656,7 +1747,7 @@ public abstract class Advapi32Util {
|
||||
* @return A environment block
|
||||
*/
|
||||
public static String getEnvironmentBlock(Map<String, String> environment) {
|
||||
StringBuffer out = new StringBuffer();
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (Entry<String, String> entry : environment.entrySet()) {
|
||||
if (entry.getValue() != null) {
|
||||
out.append(entry.getKey() + "=" + entry.getValue() + "\0");
|
||||
@@ -1781,7 +1872,7 @@ public abstract class Advapi32Util {
|
||||
|
||||
public EventLogRecord(Pointer pevlr) {
|
||||
_record = new EVENTLOGRECORD(pevlr);
|
||||
_source = pevlr.getString(_record.size(), true);
|
||||
_source = pevlr.getWideString(_record.size());
|
||||
// data
|
||||
if (_record.DataLength.intValue() > 0) {
|
||||
_data = pevlr.getByteArray(_record.DataOffset.intValue(),
|
||||
@@ -1793,7 +1884,7 @@ public abstract class Advapi32Util {
|
||||
int count = _record.NumStrings.intValue();
|
||||
long offset = _record.StringOffset.intValue();
|
||||
while (count > 0) {
|
||||
String s = pevlr.getString(offset, true);
|
||||
String s = pevlr.getWideString(0);
|
||||
strings.add(s);
|
||||
offset += s.length() * Native.WCHAR_SIZE;
|
||||
offset += Native.WCHAR_SIZE;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/* 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.
|
||||
*/
|
||||
*
|
||||
* 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;
|
||||
@@ -18,15 +18,15 @@ import com.sun.jna.ptr.ByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Based on basetsd.h (various types)
|
||||
* @author dblock[at]dblock[dot]org
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
* 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);
|
||||
@@ -40,10 +40,10 @@ public interface BaseTSD extends StdCallLibrary {
|
||||
return Pointer.createConstant(longValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Signed SIZE_T.
|
||||
*/
|
||||
* Signed SIZE_T.
|
||||
*/
|
||||
public static class SSIZE_T extends LONG_PTR {
|
||||
public SSIZE_T() {
|
||||
this(0);
|
||||
@@ -55,8 +55,8 @@ public interface BaseTSD extends StdCallLibrary {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsigned LONG_PTR.
|
||||
*/
|
||||
* Unsigned LONG_PTR.
|
||||
*/
|
||||
public static class ULONG_PTR extends IntegerType {
|
||||
public ULONG_PTR() {
|
||||
this(0);
|
||||
@@ -72,8 +72,8 @@ public interface BaseTSD extends StdCallLibrary {
|
||||
}
|
||||
|
||||
/**
|
||||
* PULONG_PTR
|
||||
*/
|
||||
* PULONG_PTR
|
||||
*/
|
||||
public static class ULONG_PTRByReference extends ByReference {
|
||||
public ULONG_PTRByReference() {
|
||||
this(new ULONG_PTR(0));
|
||||
@@ -99,8 +99,8 @@ public interface BaseTSD extends StdCallLibrary {
|
||||
|
||||
|
||||
/**
|
||||
* Unsigned DWORD_PTR.
|
||||
*/
|
||||
* Unsigned DWORD_PTR.
|
||||
*/
|
||||
public static class DWORD_PTR extends IntegerType {
|
||||
public DWORD_PTR() {
|
||||
this(0);
|
||||
@@ -112,9 +112,9 @@ public interface BaseTSD extends StdCallLibrary {
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum number of bytes to which a pointer can point.
|
||||
* Use for a count that must span the full range of a pointer.
|
||||
*/
|
||||
* 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);
|
||||
@@ -124,4 +124,4 @@ public interface BaseTSD extends StdCallLibrary {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ 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.
|
||||
*
|
||||
@@ -22,83 +23,93 @@ import com.sun.jna.ptr.IntByReference;
|
||||
*/
|
||||
public class COMException extends RuntimeException {
|
||||
|
||||
/** The p excep info. */
|
||||
private EXCEPINFO pExcepInfo;
|
||||
/** The p excep info. */
|
||||
private EXCEPINFO pExcepInfo;
|
||||
|
||||
/** The pu arg err. */
|
||||
private IntByReference puArgErr;
|
||||
/** The pu arg err. */
|
||||
private IntByReference puArgErr;
|
||||
|
||||
private int uArgErr;
|
||||
|
||||
/**
|
||||
* Instantiates a new automation exception.
|
||||
*/
|
||||
public COMException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @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
|
||||
*/
|
||||
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 message
|
||||
* the message
|
||||
* @param pExcepInfo
|
||||
* the excep info
|
||||
* @param puArgErr
|
||||
* the pu arg err
|
||||
*/
|
||||
public COMException(String message, EXCEPINFO pExcepInfo,
|
||||
IntByReference puArgErr) {
|
||||
super(message);
|
||||
this.pExcepInfo = pExcepInfo;
|
||||
this.puArgErr = puArgErr;
|
||||
}
|
||||
/**
|
||||
* Instantiates a new automation exception.
|
||||
*
|
||||
* @param cause
|
||||
* the cause
|
||||
*/
|
||||
public COMException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 excep info.
|
||||
*
|
||||
* @return the excep info
|
||||
*/
|
||||
public EXCEPINFO getExcepInfo() {
|
||||
return pExcepInfo;
|
||||
}
|
||||
/**
|
||||
* Gets the arg err.
|
||||
*
|
||||
* @return the arg err
|
||||
*/
|
||||
public IntByReference getArgErr() {
|
||||
return puArgErr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/* 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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,616 @@
|
||||
/* 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 });
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,200 +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.Native;
|
||||
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.Kernel32Util;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Helper class to provide basic COM support.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class COMObject {
|
||||
|
||||
public final static LCID LOCALE_USER_DEFAULT = Kernel32.INSTANCE
|
||||
.GetUserDefaultLCID();
|
||||
public final static LCID LOCALE_SYSTEM_DEFAULT = Kernel32.INSTANCE
|
||||
.GetSystemDefaultLCID();
|
||||
|
||||
protected IUnknown iUnknown;
|
||||
|
||||
protected IDispatch iDispatch;
|
||||
|
||||
private PointerByReference pDispatch = new PointerByReference();
|
||||
|
||||
private PointerByReference pUnknown = new PointerByReference();
|
||||
|
||||
public COMObject(IDispatch iDispatch) {
|
||||
this.iDispatch = iDispatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new cOM object.
|
||||
*
|
||||
* @param progId
|
||||
* the prog id
|
||||
* @param useActiveInstance
|
||||
* the use active instance
|
||||
* @throws COMException
|
||||
* the automation exception
|
||||
*/
|
||||
public COMObject(String progId, boolean useActiveInstance)
|
||||
throws COMException {
|
||||
|
||||
// Initialize COM for this thread...
|
||||
HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, Ole32.COINIT_MULTITHREADED);
|
||||
|
||||
if (COMUtils.FAILED(hr)) {
|
||||
this.release();
|
||||
throw new COMException("CoInitializeEx() failed: " + Kernel32Util.formatMessage(hr));
|
||||
}
|
||||
|
||||
CLSID clsid = new CLSID();
|
||||
hr = Ole32.INSTANCE.CLSIDFromProgID(progId, clsid);
|
||||
|
||||
if (COMUtils.FAILED(hr)) {
|
||||
Ole32.INSTANCE.CoUninitialize();
|
||||
throw new COMException("CLSIDFromProgID() failed: " + Kernel32Util.formatMessage(hr));
|
||||
}
|
||||
|
||||
if (useActiveInstance) {
|
||||
hr = OleAuto.INSTANCE.GetActiveObject(clsid, null, this.pUnknown);
|
||||
|
||||
if (COMUtils.SUCCEEDED(hr)) {
|
||||
this.iUnknown = new IUnknown(this.pUnknown.getValue());
|
||||
hr = iUnknown.QueryInterface(IDispatch.IID_IDispatch,
|
||||
this.pDispatch);
|
||||
} else {
|
||||
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null,
|
||||
WTypes.CLSCTX_SERVER, IDispatch.IID_IDispatch,
|
||||
this.pDispatch);
|
||||
}
|
||||
} else {
|
||||
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null,
|
||||
WTypes.CLSCTX_SERVER, 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 IDispatch(this.pDispatch.getValue());
|
||||
}
|
||||
|
||||
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!");
|
||||
|
||||
WString[] ptName = new WString[] { new WString(name) };
|
||||
DISPPARAMS dp = new DISPPARAMS();
|
||||
DISPIDByReference pdispID = new DISPIDByReference();
|
||||
VariantArg.ByReference variantArg = new VariantArg.ByReference();
|
||||
variantArg.variantArg = pArgs;
|
||||
EXCEPINFO.ByReference pExcepInfo = new EXCEPINFO.ByReference();
|
||||
IntByReference puArgErr = new IntByReference();
|
||||
|
||||
// Get DISPID for name passed...
|
||||
HRESULT hr = pDisp.GetIDsOfNames(Guid.IID_NULL, ptName, 1,
|
||||
LOCALE_USER_DEFAULT, pdispID);
|
||||
|
||||
COMUtils.checkAutoRC(hr);
|
||||
|
||||
// Handle special-case for property-puts!
|
||||
if (nType == OleAuto.DISPATCH_PROPERTYPUT) {
|
||||
dp.cNamedArgs = new UINT(pArgs.length);
|
||||
dp.rgdispidNamedArgs = new DISPIDByReference(
|
||||
OaIdl.DISPID_PROPERTYPUT);
|
||||
}
|
||||
|
||||
// Build DISPPARAMS
|
||||
if ((pArgs != null) && (pArgs.length > 0)) {
|
||||
dp.cArgs = new UINT(pArgs.length);
|
||||
dp.rgvarg = variantArg;
|
||||
|
||||
// write 'DISPPARAMS' structure to memory
|
||||
dp.write();
|
||||
}
|
||||
|
||||
// Make the call!
|
||||
hr = pDisp.Invoke(pdispID.getValue(), Guid.IID_NULL,
|
||||
LOCALE_SYSTEM_DEFAULT, new DISPID(nType), dp, pvResult,
|
||||
pExcepInfo, puArgErr);
|
||||
|
||||
COMUtils.checkAutoRC(hr, pExcepInfo, puArgErr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
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, String name) throws COMException {
|
||||
|
||||
return this.oleMethod(nType, pvResult, pDisp, name, (VARIANT[]) null);
|
||||
}
|
||||
|
||||
protected void checkFailed(HRESULT hr) {
|
||||
COMUtils.checkAutoRC(hr, null, null);
|
||||
}
|
||||
|
||||
public IDispatch getIDispatch() {
|
||||
return iDispatch;
|
||||
}
|
||||
|
||||
public PointerByReference getIDispatchPointer() {
|
||||
return pDispatch;
|
||||
}
|
||||
|
||||
public IUnknown getIUnknown() {
|
||||
return iUnknown;
|
||||
}
|
||||
|
||||
public PointerByReference getIUnknownPointer() {
|
||||
return pUnknown;
|
||||
}
|
||||
|
||||
public void release() {
|
||||
if (this.iDispatch != null)
|
||||
this.iDispatch.Release();
|
||||
|
||||
Ole32.INSTANCE.CoUninitialize();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,15 @@
|
||||
/* 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;
|
||||
@@ -7,348 +19,213 @@ 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.W32Errors;
|
||||
import com.sun.jna.platform.win32.Win32Exception;
|
||||
import com.sun.jna.platform.win32.WinError;
|
||||
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, S_FALSE = 1,
|
||||
REGDB_E_CLASSNOTREG = 0x80040154,
|
||||
CLASS_E_NOAGGREGATION = 0x80040110,
|
||||
CO_E_NOTINITIALIZED = 0x800401F0;
|
||||
/** The Constant CO_E_NOTINITIALIZED. */
|
||||
public static final int S_OK = 0;
|
||||
|
||||
/** The Constant E_UNEXPECTED. */
|
||||
public static final int E_UNEXPECTED = 0x8000FFFF;
|
||||
/**
|
||||
* Succeeded.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean SUCCEEDED(HRESULT hr) {
|
||||
return SUCCEEDED(hr.intValue());
|
||||
}
|
||||
|
||||
/** The Constant E_NOTIMPL. */
|
||||
public static final int E_NOTIMPL = 0x80004001;
|
||||
/**
|
||||
* Succeeded.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean SUCCEEDED(int hr) {
|
||||
if (hr == S_OK)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/** The Constant E_OUTOFMEMORY. */
|
||||
public static final int E_OUTOFMEMORY = 0x8007000E;
|
||||
/**
|
||||
* Failed.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean FAILED(HRESULT hr) {
|
||||
return FAILED(hr.intValue());
|
||||
}
|
||||
|
||||
/** The Constant E_INVALIDARG. */
|
||||
public static final int E_INVALIDARG = 0x80070057;
|
||||
/**
|
||||
* Failed.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean FAILED(int hr) {
|
||||
if (hr != S_OK)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/** The Constant E_NOINTERFACE. */
|
||||
public static final int E_NOINTERFACE = 0x80004002;
|
||||
/**
|
||||
* Throw new exception.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
*/
|
||||
public static void checkRC(HRESULT hr) {
|
||||
checkRC(hr, null, null);
|
||||
}
|
||||
|
||||
/** The Constant E_POINTER. */
|
||||
public static final int E_POINTER = 0x80004003;
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
/** The Constant E_HANDLE. */
|
||||
public static final int E_HANDLE = 0x80070006;
|
||||
/**
|
||||
* 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>();
|
||||
|
||||
/** The Constant E_ABORT. */
|
||||
public static final int E_ABORT = 0x80004004;
|
||||
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);
|
||||
|
||||
/** The Constant E_FAIL. */
|
||||
public static final int E_FAIL = 0x80004005;
|
||||
for (int i = 0; i < infoKey.lpcSubKeys.getValue(); i++) {
|
||||
EnumKey enumKey = Advapi32Util.registryRegEnumKey(
|
||||
phkResult.getValue(), i);
|
||||
subKey = Native.toString(enumKey.lpName);
|
||||
|
||||
/** The Constant E_ACCESSDENIED. */
|
||||
public static final int E_ACCESSDENIED = 0x80070005;
|
||||
COMInfo comInfo = new COMInfo(subKey);
|
||||
|
||||
/** The Constant DISP_E_BADVARTYPE. */
|
||||
public static final int DISP_E_BADVARTYPE = -2147352568;
|
||||
phkResult2 = Advapi32Util.registryGetKey(phkResult.getValue(),
|
||||
subKey, WinNT.KEY_ALL_ACCESS);
|
||||
InfoKey infoKey2 = Advapi32Util.registryQueryInfoKey(
|
||||
phkResult2.getValue(), WinNT.KEY_ALL_ACCESS);
|
||||
|
||||
/** The Constant DISP_E_NOTACOLLECTION. */
|
||||
public static final int DISP_E_NOTACOLLECTION = -2147352559;
|
||||
for (int y = 0; y < infoKey2.lpcSubKeys.getValue(); y++) {
|
||||
EnumKey enumKey2 = Advapi32Util.registryRegEnumKey(
|
||||
phkResult2.getValue(), y);
|
||||
String subKey2 = Native.toString(enumKey2.lpName);
|
||||
|
||||
/** The Constant DISP_E_MEMBERNOTFOUND. */
|
||||
public static final int DISP_E_MEMBERNOTFOUND = -2147352573;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/** The Constant DISP_E_ARRAYISLOCKED. */
|
||||
public static final int DISP_E_ARRAYISLOCKED = -2147352563;
|
||||
Advapi32.INSTANCE.RegCloseKey(phkResult2.getValue());
|
||||
comInfos.add(comInfo);
|
||||
}
|
||||
} finally {
|
||||
Advapi32.INSTANCE.RegCloseKey(phkResult.getValue());
|
||||
Advapi32.INSTANCE.RegCloseKey(phkResult2.getValue());
|
||||
}
|
||||
|
||||
/** The Constant DISP_E_EXCEPTION. */
|
||||
public static final int DISP_E_EXCEPTION = -2147352567;
|
||||
return comInfos;
|
||||
}
|
||||
|
||||
/** The Constant DISP_E_TYPEMISMATCH. */
|
||||
public static final int DISP_E_TYPEMISMATCH = -2147352571;
|
||||
/**
|
||||
* The Class COMInfo.
|
||||
*
|
||||
* @author wolf.tobias@gmx.net The Class COMInfo.
|
||||
*/
|
||||
public static class COMInfo {
|
||||
|
||||
/** The Constant DISP_E_BADINDEX. */
|
||||
public static final int DISP_E_BADINDEX = -2147352565;
|
||||
/** The clsid. */
|
||||
public String clsid;
|
||||
|
||||
/** The Constant DISP_E_BADCALLEE. */
|
||||
public static final int DISP_E_BADCALLEE = -2147352560;
|
||||
/** The inproc handler32. */
|
||||
public String inprocHandler32;
|
||||
|
||||
/** The Constant DISP_E_OVERFLOW. */
|
||||
public static final int DISP_E_OVERFLOW = -2147352566;
|
||||
/** The inproc server32. */
|
||||
public String inprocServer32;
|
||||
|
||||
/** The Constant DISP_E_UNKNOWNINTERFACE. */
|
||||
public static final int DISP_E_UNKNOWNINTERFACE = -2147352575;
|
||||
/** The local server32. */
|
||||
public String localServer32;
|
||||
|
||||
/** The Constant DISP_E_DIVBYZERO. */
|
||||
public static final int DISP_E_DIVBYZERO = -2147352558;
|
||||
/** The prog id. */
|
||||
public String progID;
|
||||
|
||||
/** The Constant DISP_E_UNKNOWNLCID. */
|
||||
public static final int DISP_E_UNKNOWNLCID = -2147352564;
|
||||
/** The type lib. */
|
||||
public String typeLib;
|
||||
|
||||
/** The Constant DISP_E_PARAMNOTOPTIONAL. */
|
||||
public static final int DISP_E_PARAMNOTOPTIONAL = -2147352561;
|
||||
/**
|
||||
* Instantiates a new cOM info.
|
||||
*/
|
||||
public COMInfo() {
|
||||
}
|
||||
|
||||
/** The Constant DISP_E_PARAMNOTFOUND. */
|
||||
public static final int DISP_E_PARAMNOTFOUND = -2147352572;
|
||||
|
||||
/** The Constant DISP_E_BADPARAMCOUNT. */
|
||||
public static final int DISP_E_BADPARAMCOUNT = -2147352562;
|
||||
|
||||
/** The Constant DISP_E_BUFFERTOOSMALL. */
|
||||
public static final int DISP_E_BUFFERTOOSMALL = -2147352557;
|
||||
|
||||
/** The Constant DISP_E_UNKNOWNNAME. */
|
||||
public static final int DISP_E_UNKNOWNNAME = -2147352570;
|
||||
|
||||
/** The Constant DISP_E_NONAMEDARGS. */
|
||||
public static final int DISP_E_NONAMEDARGS = -2147352569;
|
||||
|
||||
/** The Constant CO_E_OBJNOTCONNECTED. */
|
||||
public static final int CO_E_OBJNOTCONNECTED = -2147220995;
|
||||
|
||||
/**
|
||||
* 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 checkAutoRC(HRESULT hr) {
|
||||
checkAutoRC(hr, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw new exception.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @param pExcepInfo
|
||||
* the excep info
|
||||
* @param puArgErr
|
||||
* the pu arg err
|
||||
*/
|
||||
public static void checkAutoRC(HRESULT hr, EXCEPINFO pExcepInfo,
|
||||
IntByReference puArgErr) {
|
||||
switch (hr.intValue()) {
|
||||
case S_OK:
|
||||
return;
|
||||
case E_NOTIMPL:
|
||||
throw new COMException("Not implemented!");
|
||||
case E_INVALIDARG:
|
||||
throw new COMException("Invalid argument!");
|
||||
case E_OUTOFMEMORY:
|
||||
throw new COMException("Out of memory!");
|
||||
case E_UNEXPECTED:
|
||||
throw new COMException("Error "
|
||||
+ Integer.toHexString(hr.intValue()));
|
||||
case CO_E_NOTINITIALIZED:
|
||||
throw new COMException("CoInitialized wasn't called!");
|
||||
case E_NOINTERFACE:
|
||||
throw new COMException("Interface does not inherit from class!");
|
||||
case E_POINTER:
|
||||
throw new COMException("Allocated pointer pointer is null!");
|
||||
case DISP_E_UNKNOWNNAME:
|
||||
throw new COMException(
|
||||
"One or more of the names were not known. The returned array of DISPIDs contains DISPID_UNKNOWN for each entry that corresponds to an unknown name!");
|
||||
case DISP_E_UNKNOWNLCID:
|
||||
throw new COMException(
|
||||
"The locale identifier (LCID) was not recognized!");
|
||||
case DISP_E_BADPARAMCOUNT:
|
||||
throw new COMException(
|
||||
"The number of elements provided to DISPPARAMS is different from the number of arguments accepted by the method or property!");
|
||||
case DISP_E_BADVARTYPE:
|
||||
throw new COMException(
|
||||
"One of the arguments in DISPPARAMS is not a valid variant type!");
|
||||
case DISP_E_EXCEPTION:
|
||||
throw new COMException(
|
||||
"The application needs to raise an exception. In this case, the structure passed in pexcepinfo should be filled in!",
|
||||
pExcepInfo, puArgErr);
|
||||
case DISP_E_MEMBERNOTFOUND:
|
||||
throw new COMException("The requested member does not exist!");
|
||||
case DISP_E_NONAMEDARGS:
|
||||
throw new COMException(
|
||||
"This implementation of IDispatch does not support named arguments!");
|
||||
case DISP_E_OVERFLOW:
|
||||
throw new COMException(
|
||||
"One of the arguments in DISPPARAMS could not be coerced to the specified type!");
|
||||
case DISP_E_PARAMNOTFOUND:
|
||||
throw new COMException(
|
||||
"One of the parameter IDs does not correspond to a parameter on the method. In this case, puArgErr is set to the first argument that contains the error!",
|
||||
pExcepInfo, puArgErr);
|
||||
case DISP_E_TYPEMISMATCH:
|
||||
throw new COMException(
|
||||
"One or more of the arguments could not be coerced. The index of the first parameter with the incorrect type within rgvarg is returned in puArgErr!",
|
||||
pExcepInfo, puArgErr);
|
||||
case DISP_E_UNKNOWNINTERFACE:
|
||||
throw new COMException(
|
||||
"The interface identifier passed in riid is not IID_NULL!");
|
||||
case CO_E_OBJNOTCONNECTED:
|
||||
throw new COMException(
|
||||
"The method is not connected to the Dispatch pointer!");
|
||||
default:
|
||||
throw new COMException("Unexpected COM error code : "
|
||||
+ toHexStr(hr));
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkTypeLibRC(HRESULT hr) {
|
||||
switch (hr.intValue()) {
|
||||
case S_OK:
|
||||
return;
|
||||
case WinError.E_INVALIDARG:
|
||||
throw new COMException("One or more of the arguments is not valid.");
|
||||
case WinError.E_OUTOFMEMORY:
|
||||
throw new COMException(
|
||||
"Insufficient memory to complete the operation.");
|
||||
case WinError.TYPE_E_IOERROR:
|
||||
throw new COMException("The function could not write to the file.");
|
||||
case WinError.TYPE_E_INVALIDSTATE:
|
||||
throw new COMException("The type library could not be opened.");
|
||||
case WinError.TYPE_E_INVDATAREAD:
|
||||
throw new COMException(
|
||||
"The function could not read from the file. ");
|
||||
case WinError.TYPE_E_UNSUPFORMAT:
|
||||
throw new COMException("The type library has an older format.");
|
||||
case WinError.TYPE_E_UNKNOWNLCID:
|
||||
throw new COMException(
|
||||
"The LCID could not be found in the OLE-supported DLLs.");
|
||||
case WinError.TYPE_E_CANTLOADLIBRARY:
|
||||
throw new COMException(
|
||||
"The type library or DLL could not be loaded.");
|
||||
case WinError.TYPE_E_ELEMENTNOTFOUND:
|
||||
throw new COMException(
|
||||
"No type description was found in the library with the specified GUID.");
|
||||
default:
|
||||
throw new COMException("Unexpected Typelib error code : "
|
||||
+ toHexStr(hr));
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static class COMInfo {
|
||||
public String clsid;
|
||||
public String inprocHandler32;
|
||||
public String inprocServer32;
|
||||
public String localServer32;
|
||||
public String progID;
|
||||
public String typeLib;
|
||||
|
||||
public COMInfo() {
|
||||
}
|
||||
|
||||
public COMInfo(String clsid) {
|
||||
this.clsid = clsid;
|
||||
}
|
||||
}
|
||||
|
||||
private static String toHexStr(HRESULT hr) {
|
||||
return "0x" + Integer.toHexString(hr.intValue()).toUpperCase();
|
||||
}
|
||||
/**
|
||||
* Instantiates a new cOM info.
|
||||
*
|
||||
* @param clsid
|
||||
* the clsid
|
||||
*/
|
||||
public COMInfo(String clsid) {
|
||||
this.clsid = clsid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,6 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Function;
|
||||
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;
|
||||
@@ -24,10 +21,12 @@ 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
|
||||
*
|
||||
@@ -36,129 +35,21 @@ import com.sun.jna.ptr.PointerByReference;
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class IDispatch extends IUnknown {
|
||||
public interface IDispatch extends IUnknown {
|
||||
|
||||
/**
|
||||
* The Class ByReference.
|
||||
*/
|
||||
public static class ByReference extends IDispatch implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
public final static IID IID_IDISPATCH = new IID(
|
||||
"00020400-0000-0000-C000-000000000046");
|
||||
|
||||
/** The Constant IID_IDispatch. */
|
||||
public final static IID IID_IDispatch = new IID(
|
||||
"00020400-0000-0000-C000-000000000046");
|
||||
public HRESULT GetTypeInfoCount(UINTByReference pctinfo);
|
||||
|
||||
/**
|
||||
* Instantiates a new i dispatch.
|
||||
*/
|
||||
public IDispatch() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new i dispatch.
|
||||
*
|
||||
* @param pvInstance
|
||||
* the pv instance
|
||||
*/
|
||||
public IDispatch(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info count.
|
||||
*
|
||||
* @param pctinfo
|
||||
* the pctinfo
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetTypeInfoCount(IntByReference pctinfo) {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(12));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), pctinfo });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(16));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), iTInfo, lcid,
|
||||
ppTInfo });
|
||||
PointerByReference ppTInfo);
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the i ds 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) {
|
||||
LCID lcid, DISPIDByReference rgDispId);
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(20));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), riid,
|
||||
rgszNames, cNames, lcid, rgDispId });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(24));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), dispIdMember,
|
||||
riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo,
|
||||
puArgErr });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
DISPID wFlags, DISPPARAMS pDispParams,
|
||||
VARIANT.ByReference pVarResult, EXCEPINFO.ByReference pExcepInfo,
|
||||
IntByReference puArgErr);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.Guid.IID;
|
||||
@@ -23,260 +22,73 @@ 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
|
||||
* Wrapper class for the IRecordInfo interface.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class IRecordInfo extends IUnknown {
|
||||
public interface IRecordInfo extends IUnknown {
|
||||
|
||||
/** The Constant IID_IRecordInfo. */
|
||||
public final static IID IID_IRecordInfo = new IID(
|
||||
"{0000002F-0000-0000-C000-000000000046}");
|
||||
public final static IID IID_IRecordInfo = new IID(
|
||||
"{0000002F-0000-0000-C000-000000000046}");
|
||||
|
||||
/**
|
||||
* Instantiates a new i record info.
|
||||
*/
|
||||
public IRecordInfo() {
|
||||
}
|
||||
public HRESULT RecordInit(/* [out] */PVOID pvNew);
|
||||
|
||||
/**
|
||||
* Instantiates a new i record info.
|
||||
*
|
||||
* @param pvInstance
|
||||
* the pv instance
|
||||
*/
|
||||
public IRecordInfo(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
public HRESULT RecordClear(
|
||||
/* [in] */PVOID pvExisting);
|
||||
|
||||
/**
|
||||
* Record init.
|
||||
*
|
||||
* @param pvNew
|
||||
* the pv new
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT RecordInit(/* [out] */PVOID pvNew) {
|
||||
return null;
|
||||
}
|
||||
public HRESULT RecordCopy(/* [in] */PVOID pvExisting,
|
||||
/* [out] */PVOID pvNew);
|
||||
|
||||
/**
|
||||
* Record clear.
|
||||
*
|
||||
* @param pvExisting
|
||||
* the pv existing
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT RecordClear(
|
||||
/* [in] */PVOID pvExisting) {
|
||||
return null;
|
||||
}
|
||||
public HRESULT GetGuid(
|
||||
/* [out] */GUID pguid);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
public HRESULT GetName(
|
||||
/* [out] */BSTR pbstrName);
|
||||
|
||||
/**
|
||||
* Gets the guid.
|
||||
*
|
||||
* @param pguid
|
||||
* the pguid
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetGuid(
|
||||
/* [out] */GUID pguid) {
|
||||
return null;
|
||||
}
|
||||
public HRESULT GetSize(
|
||||
/* [out] */ULONG pcbSize);
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @param pbstrName
|
||||
* the pbstr name
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetName(
|
||||
/* [out] */BSTR pbstrName) {
|
||||
return null;
|
||||
}
|
||||
public HRESULT GetTypeInfo(
|
||||
/* [out] */ITypeInfo ppTypeInfo);
|
||||
|
||||
/**
|
||||
* Gets the size.
|
||||
*
|
||||
* @param pcbSize
|
||||
* the pcb size
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetSize(
|
||||
/* [out] */ULONG pcbSize) {
|
||||
return null;
|
||||
}
|
||||
public HRESULT GetField(
|
||||
/* [in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [out] */VARIANT pvarField);
|
||||
|
||||
/**
|
||||
* Gets the type info.
|
||||
*
|
||||
* @param ppTypeInfo
|
||||
* the pp type info
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetTypeInfo(
|
||||
/* [out] */ITypeInfo ppTypeInfo) {
|
||||
return null;
|
||||
}
|
||||
public HRESULT GetFieldNoCopy(
|
||||
/* [in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [out] */VARIANT pvarField,
|
||||
/* [out] */PVOID ppvDataCArray);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
public HRESULT PutField(
|
||||
/* [in] */ULONG wFlags,
|
||||
/* [out][in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [in] */VARIANT pvarField);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
public HRESULT PutFieldNoCopy(
|
||||
/* [in] */ULONG wFlags,
|
||||
/* [out][in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [in] */VARIANT pvarField);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
public HRESULT GetFieldNames(
|
||||
/* [out][in] */ULONG pcNames,
|
||||
/* [length_is][size_is][out] */BSTR rgBstrNames);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
public BOOL IsMatchingType(
|
||||
/* [in] */IRecordInfo pRecordInfo);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
public PVOID RecordCreate();
|
||||
|
||||
/**
|
||||
* Checks if is matching type.
|
||||
*
|
||||
* @param pRecordInfo
|
||||
* the record info
|
||||
* @return the bool
|
||||
*/
|
||||
public BOOL IsMatchingType(
|
||||
/* [in] */IRecordInfo pRecordInfo) {
|
||||
return null;
|
||||
}
|
||||
public HRESULT RecordCreateCopy(
|
||||
/* [in] */PVOID pvSource,
|
||||
/* [out] */PVOID ppvDest);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
public HRESULT RecordDestroy(
|
||||
/* [in] */PVOID pvRecord);
|
||||
}
|
||||
|
||||
@@ -12,63 +12,35 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Function;
|
||||
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
|
||||
* Wrapper class for the ITypeComp interface.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class ITypeComp extends IUnknown {
|
||||
public interface ITypeComp extends IUnknown {
|
||||
|
||||
public static class ByReference extends ITypeComp implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
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 ITypeComp() {
|
||||
}
|
||||
|
||||
public ITypeComp(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
|
||||
public HRESULT Bind(
|
||||
/* [annotation][in] */
|
||||
WString szName,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [in] */WORD wFlags,
|
||||
/* [out] */ITypeInfo.ByReference ppTInfo,
|
||||
/* [out] */DESCKIND.ByReference pDescKind,
|
||||
/* [out] */BINDPTR.ByReference pBindPtr) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(12));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), szName,
|
||||
lHashVal, wFlags, ppTInfo, pDescKind, pBindPtr });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT BindType(
|
||||
/* [annotation][in] */
|
||||
WString szName,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [out] */ITypeInfo.ByReference ppTInfo,
|
||||
/* [out] */ITypeComp.ByReference ppTComp) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(16));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), szName,
|
||||
lHashVal, ppTInfo, ppTComp });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
public HRESULT BindType(
|
||||
/* [annotation][in] */
|
||||
WString szName,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [out] */PointerByReference ppTInfo,
|
||||
/* [out] */PointerByReference ppTComp);
|
||||
}
|
||||
|
||||
@@ -12,24 +12,21 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Function;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
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.MEMBERIDByReference;
|
||||
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;
|
||||
@@ -40,254 +37,98 @@ 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
|
||||
*
|
||||
* Wrapper class for the ITypeInfo interface.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class ITypeInfo extends IUnknown {
|
||||
public interface ITypeInfo extends IUnknown {
|
||||
|
||||
public static class ByReference extends ITypeInfo implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
public HRESULT GetTypeAttr(
|
||||
/* [out] */PointerByReference ppTypeAttr);
|
||||
|
||||
public ITypeInfo() {
|
||||
}
|
||||
public HRESULT GetTypeComp(
|
||||
/* [out] */PointerByReference ppTComp);
|
||||
|
||||
public ITypeInfo(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
public/* [local] */HRESULT GetFuncDesc(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */PointerByReference ppFuncDesc);
|
||||
|
||||
public HRESULT GetTypeAttr(
|
||||
/* [out] */TYPEATTR.ByReference pTypeAttr) {
|
||||
public/* [local] */HRESULT GetVarDesc(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */PointerByReference ppVarDesc);
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(12));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), pTypeAttr });
|
||||
pTypeAttr.read();
|
||||
public/* [local] */HRESULT GetNames(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [length_is][size_is][out] */BSTR[] rgBstrNames,
|
||||
/* [in] */UINT cMaxNames,
|
||||
/* [out] */UINTByReference pcNames);
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
public HRESULT GetRefTypeOfImplType(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */HREFTYPEByReference pRefType);
|
||||
|
||||
public HRESULT GetTypeComp(
|
||||
/* [out] */ITypeComp.ByReference pTComp) {
|
||||
public HRESULT GetImplTypeFlags(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */IntByReference pImplTypeFlags);
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(16));
|
||||
PointerByReference ppTComp = new PointerByReference();
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), ppTComp });
|
||||
pTComp.setPointer(ppTComp.getValue());
|
||||
public/* [local] */HRESULT GetIDsOfNames(
|
||||
/* [size_is][in] */LPOLESTR[] rgszNames,
|
||||
/* [in] */UINT cNames,
|
||||
/* [size_is][out] */MEMBERID[] pMemId);
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
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 GetFuncDesc(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */FUNCDESC.ByReference pFuncDesc) {
|
||||
public/* [local] */HRESULT GetDocumentation(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [out] */BSTRByReference pBstrName,
|
||||
/* [out] */BSTRByReference pBstrDocString,
|
||||
/* [out] */DWORDByReference pdwHelpContext,
|
||||
/* [out] */BSTRByReference pBstrHelpFile);
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(20));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
|
||||
pFuncDesc });
|
||||
public/* [local] */HRESULT GetDllEntry(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [in] */INVOKEKIND invKind,
|
||||
/* [out] */BSTRByReference pBstrDllName,
|
||||
/* [out] */BSTRByReference pBstrName,
|
||||
/* [out] */WORDByReference pwOrdinal);
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
public HRESULT GetRefTypeInfo(
|
||||
/* [in] */HREFTYPE hRefType,
|
||||
/* [out] */PointerByReference ppTInfo);
|
||||
|
||||
public/* [local] */HRESULT GetVarDesc(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */VARDESC.ByReference pVarDesc) {
|
||||
public/* [local] */HRESULT AddressOfMember(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [in] */INVOKEKIND invKind,
|
||||
/* [out] */PointerByReference ppv);
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(24));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
|
||||
pVarDesc });
|
||||
public/* [local] */HRESULT CreateInstance(
|
||||
/* [in] */IUnknown pUnkOuter,
|
||||
/* [in] */REFIID riid,
|
||||
/* [iid_is][out] */PointerByReference ppvObj);
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
public HRESULT GetMops(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [out] */BSTRByReference pBstrMops);
|
||||
|
||||
public/* [local] */HRESULT GetNames(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [length_is][size_is][out] */BSTR[] rgBstrNames,
|
||||
/* [in] */UINT cMaxNames,
|
||||
/* [out] */UINTByReference pcNames) {
|
||||
public/* [local] */HRESULT GetContainingTypeLib(
|
||||
/* [out] */PointerByReference ppTLib,
|
||||
/* [out] */UINTByReference pIndex);
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(28));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
|
||||
rgBstrNames, cMaxNames, pcNames });
|
||||
public/* [local] */void ReleaseTypeAttr(
|
||||
/* [in] */TYPEATTR pTypeAttr);
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
public/* [local] */void ReleaseFuncDesc(
|
||||
/* [in] */FUNCDESC pFuncDesc);
|
||||
|
||||
public HRESULT GetRefTypeOfImplType(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */HREFTYPEByReference pRefType) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(32));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
|
||||
pRefType });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetImplTypeFlags(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */IntByReference pImplTypeFlags) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(36));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
|
||||
pImplTypeFlags });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT GetIDsOfNames(
|
||||
/* [size_is][in] */WString[] rgszNames,
|
||||
/* [in] */UINT cNames,
|
||||
/* [size_is][out] */MEMBERID[] pMemId) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(40));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), rgszNames,
|
||||
cNames, pMemId });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(44));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), pvInstance,
|
||||
memid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT GetDocumentation(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [out] */BSTR pBstrName,
|
||||
/* [out] */BSTR pBstrDocString,
|
||||
/* [out] */DWORDByReference pdwHelpContext,
|
||||
/* [out] */BSTR pBstrHelpFile) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(48));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
|
||||
pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT GetDllEntry(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [in] */INVOKEKIND invKind,
|
||||
/* [out] */BSTR pBstrDllName,
|
||||
/* [out] */BSTR pBstrName,
|
||||
/* [out] */WORDByReference pwOrdinal) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(52));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
|
||||
invKind, pBstrDllName, pBstrName, pwOrdinal });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetRefTypeInfo(
|
||||
/* [in] */HREFTYPE hRefType,
|
||||
/* [out] */ITypeInfo.ByReference ppTInfo) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(56));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), hRefType,
|
||||
ppTInfo });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT AddressOfMember(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [in] */INVOKEKIND invKind,
|
||||
/* [out] */PointerByReference ppv) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(60));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
|
||||
invKind, ppv });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT CreateInstance(
|
||||
/* [in] */IUnknown pUnkOuter,
|
||||
/* [in] */REFIID riid,
|
||||
/* [iid_is][out] */PointerByReference ppvObj) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(64));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), pUnkOuter,
|
||||
riid, ppvObj });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetMops(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [out] */BSTR pBstrMops) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(68));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
|
||||
pBstrMops });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT GetContainingTypeLib(
|
||||
/* [out] */ITypeLib.ByReference pTLib,
|
||||
/* [out] */UINTByReference pIndex) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(72));
|
||||
PointerByReference ppTLib = new PointerByReference();
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), ppTLib,
|
||||
pIndex });
|
||||
pTLib.setPointer(ppTLib.getPointer());
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */void ReleaseTypeAttr(
|
||||
/* [in] */TYPEATTR pTypeAttr) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(76));
|
||||
func.invokeInt(new Object[] { this.getPointer(), pTypeAttr });
|
||||
}
|
||||
|
||||
public/* [local] */void ReleaseFuncDesc(
|
||||
/* [in] */FUNCDESC pFuncDesc) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(80));
|
||||
func.invokeInt(new Object[] { this.getPointer(), pFuncDesc });
|
||||
}
|
||||
|
||||
public/* [local] */void ReleaseVarDesc(
|
||||
/* [in] */VARDESC pVarDesc) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(84));
|
||||
func.invokeInt(new Object[] { this.getPointer(), pVarDesc });
|
||||
}
|
||||
public/* [local] */void ReleaseVarDesc(
|
||||
/* [in] */VARDESC pVarDesc);
|
||||
}
|
||||
|
||||
@@ -12,157 +12,68 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Function;
|
||||
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.OaIdl.MEMBERIDByReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.TLIBATTR;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
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.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Wrapper class for the ITypeLib interface
|
||||
*
|
||||
* Wrapper class for the ITypeLib interface.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class ITypeLib extends IUnknown {
|
||||
public interface ITypeLib extends IUnknown {
|
||||
|
||||
public static class ByReference extends IUnknown implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
public UINT GetTypeInfoCount();
|
||||
|
||||
public ITypeLib() {
|
||||
}
|
||||
public HRESULT GetTypeInfo(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */PointerByReference pTInfo);
|
||||
|
||||
public ITypeLib(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
public HRESULT GetTypeInfoType(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */TYPEKIND.ByReference pTKind);
|
||||
|
||||
public UINT GetTypeInfoCount() {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(12));
|
||||
int count = func.invokeInt(new Object[] { this.getPointer() });
|
||||
public HRESULT GetTypeInfoOfGuid(
|
||||
/* [in] */GUID guid,
|
||||
/* [out] */PointerByReference pTinfo);
|
||||
|
||||
return new UINT(count);
|
||||
}
|
||||
public HRESULT GetLibAttr(
|
||||
/* [out] */PointerByReference ppTLibAttr);
|
||||
|
||||
public HRESULT GetTypeInfo(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */ITypeInfo.ByReference pTInfo) {
|
||||
public HRESULT GetTypeComp(
|
||||
/* [out] */PointerByReference ppTComp);
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(16));
|
||||
PointerByReference ppTInfo = new PointerByReference();
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), index, ppTInfo });
|
||||
pTInfo.setPointer(ppTInfo.getValue());
|
||||
public HRESULT GetDocumentation(
|
||||
/* [in] */int index,
|
||||
/* [out] */BSTRByReference pBstrName,
|
||||
/* [out] */BSTRByReference pBstrDocString,
|
||||
/* [out] */DWORDByReference pdwHelpContext,
|
||||
/* [out] */BSTRByReference pBstrHelpFile);
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
public HRESULT IsName(
|
||||
/* [annotation][out][in] */
|
||||
LPOLESTR szNameBuf,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [out] */BOOLByReference pfName);
|
||||
|
||||
public HRESULT GetTypeInfoType(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */IntByReference pTKind) {
|
||||
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);
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(20));
|
||||
int hr = func
|
||||
.invokeInt(new Object[] { this.getPointer(), index, pTKind });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetTypeInfoOfGuid(
|
||||
/* [in] */GUID guid,
|
||||
/* [out] */ITypeInfo.ByReference pTinfo) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(24));
|
||||
PointerByReference ppTinfo = new PointerByReference();
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), guid, ppTinfo });
|
||||
pTinfo.setPointer(ppTinfo.getPointer());
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetLibAttr(
|
||||
/* [out] */TLIBATTR.ByReference ppTLibAttr) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(28));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), ppTLibAttr });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetTypeComp(
|
||||
/* [out] */ITypeComp.ByReference pTComp) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(32));
|
||||
PointerByReference ppTComp = new PointerByReference();
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), ppTComp });
|
||||
pTComp.setPointer(ppTComp.getPointer());
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetDocumentation(
|
||||
/* [in] */int index,
|
||||
/* [out] */BSTR pBstrName,
|
||||
/* [out] */BSTR pBstrDocString,
|
||||
/* [out] */DWORDByReference pdwHelpContext,
|
||||
/* [out] */BSTR pBstrHelpFile) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(36));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
|
||||
pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT IsName(
|
||||
/* [annotation][out][in] */
|
||||
WString szNameBuf,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [out] */BOOLByReference pfName) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(40));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), szNameBuf,
|
||||
lHashVal, pfName });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT FindName(
|
||||
/* [annotation][out][in] */
|
||||
WString szNameBuf,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [length_is][size_is][out] */ITypeInfo.ByReference ppTInfo,
|
||||
/* [length_is][size_is][out] */MEMBERIDByReference rgMemId,
|
||||
/* [out][in] */USHORTByReference pcFound) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(44));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), szNameBuf,
|
||||
lHashVal, ppTInfo, rgMemId, pcFound });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public void ReleaseTLibAttr(/* [in] */TLIBATTR pTLibAttr) {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(48));
|
||||
func.invokeInt(new Object[] { this.getPointer(), pTLibAttr });
|
||||
}
|
||||
public void ReleaseTLibAttr(/* [in] */TLIBATTR pTLibAttr);
|
||||
}
|
||||
|
||||
@@ -12,14 +12,11 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Function;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.PointerType;
|
||||
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
|
||||
*
|
||||
@@ -28,74 +25,15 @@ import com.sun.jna.ptr.PointerByReference;
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class IUnknown extends PointerType {
|
||||
|
||||
/**
|
||||
* The Class ByReference.
|
||||
*/
|
||||
public static class ByReference extends IUnknown implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
public interface IUnknown {
|
||||
|
||||
/** The Constant IID_IDispatch. */
|
||||
public final static IID IID_IDispatch = new IID(
|
||||
"{00000000-0000-0000-C000-000000000046}");
|
||||
public final static IID IID_IUNKNOWN = new IID(
|
||||
"{00000000-0000-0000-C000-000000000046}");
|
||||
|
||||
/**
|
||||
* Instantiates a new i unknown.
|
||||
*/
|
||||
public IUnknown() {
|
||||
}
|
||||
public HRESULT QueryInterface(IID riid, PointerByReference ppvObject);
|
||||
|
||||
/**
|
||||
* Instantiates a new i unknown.
|
||||
*
|
||||
* @param pvInstance
|
||||
* the pv instance
|
||||
*/
|
||||
public IUnknown(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
public int AddRef();
|
||||
|
||||
/**
|
||||
* Query interface.
|
||||
*
|
||||
* @param riid
|
||||
* the riid
|
||||
* @param ppvObject
|
||||
* the ppv object
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT QueryInterface(IID riid, PointerByReference ppvObject) {
|
||||
Pointer base = this.getPointer();
|
||||
Pointer vptr = base.getPointer(0);
|
||||
Pointer root = vptr.getPointer(0);
|
||||
Function func = Function.getFunction(root);
|
||||
int hr = func.invokeInt(new Object[] { base, riid, ppvObject });
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the ref.
|
||||
*
|
||||
* @return the ulong
|
||||
*/
|
||||
public int AddRef() {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(4));
|
||||
|
||||
return func.invokeInt(new Object[] { this.getPointer() });
|
||||
}
|
||||
|
||||
/**
|
||||
* Release.
|
||||
*
|
||||
* @return the ulong
|
||||
*/
|
||||
public int Release() {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(8));
|
||||
|
||||
return func.invokeInt(new Object[] { this.getPointer() });
|
||||
}
|
||||
public int Release();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,283 @@
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
/* 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 });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,681 @@
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,536 @@
|
||||
/* 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/* 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() });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
Provides...
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,231 @@
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/* 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; i++) {
|
||||
String cmd = args[i];
|
||||
if (cmd.startsWith("-")) {
|
||||
this.put(args[i].substring(1), args[i + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/* 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";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/* 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";
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/* 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
@@ -0,0 +1,24 @@
|
||||
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}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/* 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";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
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" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/* 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
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* ${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};
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/* 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";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* ${helpstring}
|
||||
* Virtual table id: ${vtableid}
|
||||
* Member id: ${memberid}
|
||||
*/
|
||||
public ${returntype} ${methodname}(${methodparams});
|
||||
@@ -0,0 +1,83 @@
|
||||
/* 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
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* ${helpstring}
|
||||
* Virtual table id: ${vtableid}
|
||||
* Member id: ${memberid}
|
||||
*/
|
||||
public ${returntype} ${methodname}(${methodparams}) {
|
||||
return (${returntype})this._invokeNativeObject(${functionCount}, new Object[] { this.getPointer()${methodvariables}}, ${returntype}.class);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/* 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";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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
@@ -0,0 +1,31 @@
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/* 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";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* ${helpstring}
|
||||
* Virtual table id: ${vtableid}
|
||||
* Member id: ${memberid}
|
||||
*/
|
||||
public ${returntype} ${methodname}() {
|
||||
return (${returntype})this._invokeNativeObject(${functionCount}, new Object[] { this.getPointer() }, ${returntype}.class);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/* 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
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* ${helpstring}
|
||||
* Virtual table id: ${vtableid}
|
||||
* Member id: ${memberid}
|
||||
*/
|
||||
public ${returntype} ${methodname}();
|
||||
@@ -0,0 +1,82 @@
|
||||
/* 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";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* ${helpstring}
|
||||
* Virtual table id: ${vtableid}
|
||||
* Member id: ${memberid}
|
||||
*/
|
||||
public void ${methodname}(${methodparams}) {
|
||||
this._invokeNativeInt(${functionCount}, new Object[] { this.getPointer()${methodvariables}});
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/* 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 TlbPropertyPut.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class TlbPropertyPutStub 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 TlbPropertyPutStub(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 = "set" + typeInfoDoc.getName();
|
||||
String[] names = typeInfoUtil.getNames(funcDesc.memid, paramCount + 1);
|
||||
|
||||
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());
|
||||
|
||||
// if there is more than 1 param
|
||||
if (i < (paramCount - 1)) {
|
||||
methodparams += ", ";
|
||||
}
|
||||
}
|
||||
|
||||
this.replaceVariable("helpstring", docStr);
|
||||
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/TlbPropertyPutStub.template";
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* ${helpstring}
|
||||
* Virtual table id: ${vtableid}
|
||||
* Member id: ${memberid}
|
||||
*/
|
||||
public void ${methodname}(${methodparams});
|
||||
@@ -0,0 +1,7 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
Provides...
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,7 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
Provides...
|
||||
</body>
|
||||
</html>
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -22,23 +22,25 @@ import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
|
||||
/**
|
||||
* Ported from DsGetDC.h.
|
||||
* Windows SDK 6.0a
|
||||
* @author dblock[at]dblock.org
|
||||
* Ported from DsGetDC.h. Windows SDK 6.0a
|
||||
*
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface DsGetDC extends StdCallLibrary {
|
||||
|
||||
|
||||
/**
|
||||
* The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName
|
||||
* The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName
|
||||
* function to receive data about a domain controller.
|
||||
*/
|
||||
public static class DOMAIN_CONTROLLER_INFO extends Structure {
|
||||
|
||||
public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference { }
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO() { }
|
||||
|
||||
public static class ByReference extends DOMAIN_CONTROLLER_INFO
|
||||
implements Structure.ByReference {
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO() {
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO(Pointer memory) {
|
||||
super(memory);
|
||||
@@ -46,85 +48,95 @@ public interface DsGetDC extends StdCallLibrary {
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the computer name
|
||||
* of the discovered domain controller. The returned computer name is
|
||||
* prefixed with "\\". The DNS-style name, for example, "\\phoenix.fabrikam.com",
|
||||
* is returned, if available. If the DNS-style name is not available, the
|
||||
* flat-style name (for example, "\\phoenix") is returned. This example would apply
|
||||
* if the domain is a Windows NT 4.0 domain or if the domain does not support the
|
||||
* IP family of protocols.
|
||||
* Pointer to a null-terminated WString that specifies the computer name
|
||||
* of the discovered domain controller. The returned computer name is
|
||||
* prefixed with "\\". The DNS-style name, for example,
|
||||
* "\\phoenix.fabrikam.com", is returned, if available. If the DNS-style
|
||||
* name is not available, the flat-style name (for example, "\\phoenix")
|
||||
* is returned. This example would apply if the domain is a Windows NT
|
||||
* 4.0 domain or if the domain does not support the IP family of
|
||||
* protocols.
|
||||
*/
|
||||
public WString DomainControllerName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the address of the discovered
|
||||
* domain controller. The address is prefixed with "\\". This WString is one of the
|
||||
* types defined by the DomainControllerAddressType member.
|
||||
* Pointer to a null-terminated WString that specifies the address of
|
||||
* the discovered domain controller. The address is prefixed with "\\".
|
||||
* This WString is one of the types defined by the
|
||||
* DomainControllerAddressType member.
|
||||
*/
|
||||
public WString DomainControllerAddress;
|
||||
/**
|
||||
* Indicates the type of WString that is contained in the DomainControllerAddress member.
|
||||
* Indicates the type of WString that is contained in the
|
||||
* DomainControllerAddress member.
|
||||
*/
|
||||
public int DomainControllerAddressType;
|
||||
/**
|
||||
* The GUID of the domain. This member is zero if the domain controller does not have
|
||||
* a Domain GUID; for example, the domain controller is not a Windows 2000 domain
|
||||
* controller.
|
||||
* The GUID of the domain. This member is zero if the domain controller
|
||||
* does not have a Domain GUID; for example, the domain controller is
|
||||
* not a Windows 2000 domain controller.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain. The
|
||||
* DNS-style name, for example, "fabrikam.com", is returned if available. Otherwise,
|
||||
* the flat-style name, for example, "fabrikam", is returned. This name may be different
|
||||
* than the requested domain name if the domain has been renamed.
|
||||
* Pointer to a null-terminated WString that specifies the name of the
|
||||
* domain. The DNS-style name, for example, "fabrikam.com", is returned
|
||||
* if available. Otherwise, the flat-style name, for example,
|
||||
* "fabrikam", is returned. This name may be different than the
|
||||
* requested domain name if the domain has been renamed.
|
||||
*/
|
||||
public WString DomainName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain at the root
|
||||
* of the DS tree. The DNS-style name, for example, "fabrikam.com", is returned if
|
||||
* available. Otherwise, the flat-style name, for example, "fabrikam" is returned.
|
||||
* Pointer to a null-terminated WString that specifies the name of the
|
||||
* domain at the root of the DS tree. The DNS-style name, for example,
|
||||
* "fabrikam.com", is returned if available. Otherwise, the flat-style
|
||||
* name, for example, "fabrikam" is returned.
|
||||
*/
|
||||
public WString DnsForestName;
|
||||
/**
|
||||
* Contains a set of flags that describe the domain controller.
|
||||
* Contains a set of flags that describe the domain controller.
|
||||
*/
|
||||
public int Flags;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the site where the
|
||||
* domain controller is located. This member may be NULL if the domain controller is
|
||||
* not in a site; for example, the domain controller is a Windows NT 4.0 domain
|
||||
* controller.
|
||||
* Pointer to a null-terminated WString that specifies the name of the
|
||||
* site where the domain controller is located. This member may be NULL
|
||||
* if the domain controller is not in a site; for example, the domain
|
||||
* controller is a Windows NT 4.0 domain controller.
|
||||
*/
|
||||
public WString DcSiteName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the site that the
|
||||
* computer belongs to. The computer is specified in the ComputerName parameter passed
|
||||
* to DsGetDcName. This member may be NULL if the site that contains the computer
|
||||
* cannot be found; for example, if the DS administrator has not associated the
|
||||
* subnet that the computer is in with a valid site.
|
||||
* Pointer to a null-terminated WString that specifies the name of the
|
||||
* site that the computer belongs to. The computer is specified in the
|
||||
* ComputerName parameter passed to DsGetDcName. This member may be NULL
|
||||
* if the site that contains the computer cannot be found; for example,
|
||||
* if the DS administrator has not associated the subnet that the
|
||||
* computer is in with a valid site.
|
||||
*/
|
||||
public WString ClientSiteName;
|
||||
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "DomainControllerName", "DomainControllerAddress", "DomainControllerAddressType", "DomainGuid", "DomainName", "DnsForestName", "Flags", "DcSiteName", "ClientSiteName"});
|
||||
return Arrays.asList(new String[] { "DomainControllerName",
|
||||
"DomainControllerAddress", "DomainControllerAddressType",
|
||||
"DomainGuid", "DomainName", "DnsForestName", "Flags",
|
||||
"DcSiteName", "ClientSiteName" });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to DOMAIN_CONTROLLER_INFO.
|
||||
*/
|
||||
public static class PDOMAIN_CONTROLLER_INFO extends Structure {
|
||||
|
||||
public static class ByReference extends PDOMAIN_CONTROLLER_INFO implements Structure.ByReference {
|
||||
public static class ByReference extends PDOMAIN_CONTROLLER_INFO
|
||||
implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO.ByReference dci;
|
||||
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dci" });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Domain is a member of the forest.
|
||||
*/
|
||||
@@ -136,7 +148,7 @@ public interface DsGetDC extends StdCallLibrary {
|
||||
/**
|
||||
* Domain is root of a tree in the forest.
|
||||
*/
|
||||
int DS_DOMAIN_TREE_ROOT = 0x0004;
|
||||
int DS_DOMAIN_TREE_ROOT = 0x0004;
|
||||
/**
|
||||
* Domain is the primary domain of queried server.
|
||||
*/
|
||||
@@ -152,51 +164,55 @@ public interface DsGetDC extends StdCallLibrary {
|
||||
/**
|
||||
* Valid domain flags.
|
||||
*/
|
||||
int DS_DOMAIN_VALID_FLAGS =
|
||||
DS_DOMAIN_IN_FOREST |
|
||||
DS_DOMAIN_DIRECT_OUTBOUND |
|
||||
DS_DOMAIN_TREE_ROOT |
|
||||
DS_DOMAIN_PRIMARY |
|
||||
DS_DOMAIN_NATIVE_MODE |
|
||||
DS_DOMAIN_DIRECT_INBOUND;
|
||||
int DS_DOMAIN_VALID_FLAGS = DS_DOMAIN_IN_FOREST | DS_DOMAIN_DIRECT_OUTBOUND
|
||||
| DS_DOMAIN_TREE_ROOT | DS_DOMAIN_PRIMARY | DS_DOMAIN_NATIVE_MODE
|
||||
| DS_DOMAIN_DIRECT_INBOUND;
|
||||
|
||||
/**
|
||||
* The DS_DOMAIN_TRUSTS structure is used with the DsEnumerateDomainTrusts function to
|
||||
* contain trust data for a domain.
|
||||
* The DS_DOMAIN_TRUSTS structure is used with the DsEnumerateDomainTrusts
|
||||
* function to contain trust data for a domain.
|
||||
*/
|
||||
public static class DS_DOMAIN_TRUSTS extends Structure {
|
||||
|
||||
public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference {
|
||||
|
||||
public static class ByReference extends DS_DOMAIN_TRUSTS implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated string that contains the NetBIOS name of the domain.
|
||||
* Pointer to a null-terminated string that contains the NetBIOS name of
|
||||
* the domain.
|
||||
*/
|
||||
public WString NetbiosDomainName;
|
||||
/**
|
||||
* Pointer to a null-terminated string that contains the DNS name of the domain. This member may be NULL.
|
||||
* Pointer to a null-terminated string that contains the DNS name of the
|
||||
* domain. This member may be NULL.
|
||||
*/
|
||||
public WString DnsDomainName;
|
||||
/**
|
||||
* Contains a set of flags that specify more data about the domain trust.
|
||||
*/
|
||||
* Contains a set of flags that specify more data about the domain
|
||||
* trust.
|
||||
*/
|
||||
public int Flags;
|
||||
/**
|
||||
* Contains the index in the Domains array returned by the DsEnumerateDomainTrusts function that
|
||||
* corresponds to the parent domain of the domain represented by this structure.
|
||||
* Contains the index in the Domains array returned by the
|
||||
* DsEnumerateDomainTrusts function that corresponds to the parent
|
||||
* domain of the domain represented by this structure.
|
||||
*/
|
||||
public int ParentIndex;
|
||||
/**
|
||||
* Contains a value that indicates the type of trust represented by this structure.
|
||||
* Contains a value that indicates the type of trust represented by this
|
||||
* structure.
|
||||
*/
|
||||
public int TrustType;
|
||||
public int TrustType;
|
||||
/**
|
||||
* Contains a value that indicates the attributes of the trust represented by this structure.
|
||||
* Contains a value that indicates the attributes of the trust
|
||||
* represented by this structure.
|
||||
*/
|
||||
public int TrustAttributes;
|
||||
|
||||
|
||||
/**
|
||||
* Contains the security identifier of the domain represented by this structure.
|
||||
* Contains the security identifier of the domain represented by this
|
||||
* structure.
|
||||
*/
|
||||
public PSID.ByReference DomainSid;
|
||||
|
||||
@@ -204,9 +220,11 @@ public interface DsGetDC extends StdCallLibrary {
|
||||
* Contains the GUID of the domain represented by this structure.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "NetbiosDomainName", "DnsDomainName", "Flags", "ParentIndex", "TrustType", "TrustAttributes", "DomainSid", "DomainGuid" });
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "NetbiosDomainName",
|
||||
"DnsDomainName", "Flags", "ParentIndex", "TrustType",
|
||||
"TrustAttributes", "DomainSid", "DomainGuid" });
|
||||
}
|
||||
|
||||
public DS_DOMAIN_TRUSTS() {
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HRGN;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFOHEADER;
|
||||
import com.sun.jna.platform.win32.WinGDI.PIXELFORMATDESCRIPTOR;
|
||||
import com.sun.jna.platform.win32.WinGDI.RGNDATA;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
@@ -123,7 +124,7 @@ public interface GDI32 extends StdCallLibrary {
|
||||
* If the function fails, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HRGN CreatePolyPolygonRgn(WinUser.POINT[] lppt, int[] lpPolyCounts,
|
||||
HRGN CreatePolyPolygonRgn(WinDef.POINT[] lppt, int[] lpPolyCounts,
|
||||
int nCount, int fnPolyFillMode);
|
||||
|
||||
/**
|
||||
@@ -313,4 +314,33 @@ public interface GDI32 extends StdCallLibrary {
|
||||
* BITMAPINFO} structure.
|
||||
*/
|
||||
int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, Pointer lpvBits, BITMAPINFO lpbi, int uUsage);
|
||||
|
||||
/**
|
||||
* The ChoosePixelFormat function attempts to match an appropriate pixel format supported
|
||||
* by a device context to a given pixel format specification.
|
||||
*
|
||||
* @param hdc
|
||||
* Specifies the device context that the function examines to determine the best
|
||||
* match for the pixel format descriptor pointed to by ppfd.
|
||||
* @param ppfd
|
||||
* Pointer to a PIXELFORMATDESCRIPTOR structure that specifies the requested pixel format.
|
||||
* @return If the function succeeds, the return value is a pixel format index (one-based) that
|
||||
* is the closest match to the given pixel format descriptor.
|
||||
*/
|
||||
public int ChoosePixelFormat(HDC hdc, PIXELFORMATDESCRIPTOR.ByReference ppfd);
|
||||
|
||||
/**
|
||||
* The SetPixelFormat function sets the pixel format of the specified device context to the
|
||||
* format specified by the iPixelFormat index.
|
||||
*
|
||||
* @param hdc
|
||||
* Specifies the device context whose pixel format the function attempts to set.
|
||||
* @param iPixelFormat
|
||||
* Index that identifies the pixel format to set. The various pixel formats supported
|
||||
* by a device context are identified by one-based indexes.
|
||||
* @param ppfd
|
||||
* Pointer to a PIXELFORMATDESCRIPTOR structure that contains the logical pixel format specification.
|
||||
* @return true if successful
|
||||
*/
|
||||
public boolean SetPixelFormat(HDC hdc, int iPixelFormat, PIXELFORMATDESCRIPTOR.ByReference ppfd);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/* Copyright (c) 2011 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.win32;
|
||||
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Definitions for WinOpenGL
|
||||
*/
|
||||
public interface GL extends StdCallLibrary {
|
||||
public final int GL_VENDOR = 0x1F00;
|
||||
public final int GL_RENDERER = 0x1F01;
|
||||
public final int GL_VERSION = 0x1F02;
|
||||
public final int GL_EXTENSIONS = 0x1F03;
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* 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
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
@@ -19,457 +19,494 @@ import java.util.List;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Ported from Guid.h. Microsoft Windows SDK 6.0A.
|
||||
*
|
||||
*
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Guid {
|
||||
|
||||
public final static IID IID_NULL = new IID();
|
||||
|
||||
/**
|
||||
* The Class GUID.
|
||||
*/
|
||||
public static class GUID extends Structure {
|
||||
|
||||
/**
|
||||
* The Class ByReference.
|
||||
*/
|
||||
public static class ByReference extends GUID implements
|
||||
Structure.ByReference {
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*/
|
||||
public ByReference() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
*/
|
||||
public ByReference(GUID guid) {
|
||||
super(guid.getPointer());
|
||||
|
||||
Data1 = guid.Data1;
|
||||
Data2 = guid.Data2;
|
||||
Data3 = guid.Data3;
|
||||
Data4 = guid.Data4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public ByReference(Pointer memory) {
|
||||
super(memory);
|
||||
}
|
||||
}
|
||||
|
||||
/** The Data1. */
|
||||
public int Data1;
|
||||
|
||||
/** The Data2. */
|
||||
public short Data2;
|
||||
|
||||
/** The Data3. */
|
||||
public short Data3;
|
||||
|
||||
/** The Data4. */
|
||||
public byte[] Data4 = new byte[8];
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*/
|
||||
public GUID() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
*/
|
||||
public GUID(GUID guid) {
|
||||
this.Data1 = guid.Data1;
|
||||
this.Data2 = guid.Data2;
|
||||
this.Data3 = guid.Data3;
|
||||
this.Data4 = guid.Data4;
|
||||
|
||||
this.writeFieldsToMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
*/
|
||||
public GUID(String guid) {
|
||||
this(fromString(guid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
*/
|
||||
public GUID(byte[] data) {
|
||||
this(fromBinary(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public GUID(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* From binary.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
* @return the guid
|
||||
*/
|
||||
public static GUID fromBinary(byte[] data) {
|
||||
if (data.length != 16) {
|
||||
throw new IllegalArgumentException("Invalid data length: "
|
||||
+ data.length);
|
||||
}
|
||||
|
||||
GUID newGuid = new GUID();
|
||||
long data1Temp = data[0] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[1] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[2] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[3] & 0xff;
|
||||
newGuid.Data1 = (int) data1Temp;
|
||||
|
||||
int data2Temp = data[4] & 0xff;
|
||||
data2Temp <<= 8;
|
||||
data2Temp |= data[5] & 0xff;
|
||||
newGuid.Data2 = (short) data2Temp;
|
||||
|
||||
int data3Temp = data[6] & 0xff;
|
||||
data3Temp <<= 8;
|
||||
data3Temp |= data[7] & 0xff;
|
||||
newGuid.Data3 = (short) data3Temp;
|
||||
|
||||
newGuid.Data4[0] = data[8];
|
||||
newGuid.Data4[1] = data[9];
|
||||
newGuid.Data4[2] = data[10];
|
||||
newGuid.Data4[3] = data[11];
|
||||
newGuid.Data4[4] = data[12];
|
||||
newGuid.Data4[5] = data[13];
|
||||
newGuid.Data4[6] = data[14];
|
||||
newGuid.Data4[7] = data[15];
|
||||
|
||||
newGuid.writeFieldsToMemory();
|
||||
|
||||
return newGuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* From string.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
* @return the guid
|
||||
*/
|
||||
public static GUID fromString(String guid) {
|
||||
int y = 0;
|
||||
char[] _cnewguid = new char[32];
|
||||
char[] _cguid = guid.toCharArray();
|
||||
byte[] bdata = new byte[16];
|
||||
GUID newGuid = new GUID();
|
||||
|
||||
// we not accept a string longer than 38 chars
|
||||
if (guid.length() > 38) {
|
||||
throw new IllegalArgumentException("Invalid guid length: "
|
||||
+ guid.length());
|
||||
}
|
||||
|
||||
// remove '{', '}' and '-' from guid string
|
||||
for (int i = 0; i < _cguid.length; i++) {
|
||||
if ((_cguid[i] != '{') && (_cguid[i] != '-')
|
||||
&& (_cguid[i] != '}'))
|
||||
_cnewguid[y++] = _cguid[i];
|
||||
}
|
||||
|
||||
// convert char to byte
|
||||
for (int i = 0; i < 32; i += 2) {
|
||||
bdata[i / 2] = (byte) ((Character.digit(_cnewguid[i], 16) << 4)
|
||||
+ Character.digit(_cnewguid[i + 1], 16) & 0xff);
|
||||
}
|
||||
|
||||
if (bdata.length != 16) {
|
||||
throw new IllegalArgumentException("Invalid data length: "
|
||||
+ bdata.length);
|
||||
}
|
||||
|
||||
long data1Temp = bdata[0] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= bdata[1] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= bdata[2] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= bdata[3] & 0xff;
|
||||
newGuid.Data1 = (int) data1Temp;
|
||||
|
||||
int data2Temp = bdata[4] & 0xff;
|
||||
data2Temp <<= 8;
|
||||
data2Temp |= bdata[5] & 0xff;
|
||||
newGuid.Data2 = (short) data2Temp;
|
||||
|
||||
int data3Temp = bdata[6] & 0xff;
|
||||
data3Temp <<= 8;
|
||||
data3Temp |= bdata[7] & 0xff;
|
||||
newGuid.Data3 = (short) data3Temp;
|
||||
|
||||
newGuid.Data4[0] = bdata[8];
|
||||
newGuid.Data4[1] = bdata[9];
|
||||
newGuid.Data4[2] = bdata[10];
|
||||
newGuid.Data4[3] = bdata[11];
|
||||
newGuid.Data4[4] = bdata[12];
|
||||
newGuid.Data4[5] = bdata[13];
|
||||
newGuid.Data4[6] = bdata[14];
|
||||
newGuid.Data4[7] = bdata[15];
|
||||
|
||||
newGuid.writeFieldsToMemory();
|
||||
|
||||
return newGuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new guid. Code taken from the standard jdk
|
||||
* implementation (see UUID class).
|
||||
*
|
||||
* @return the guid
|
||||
*/
|
||||
public static GUID newGuid() {
|
||||
SecureRandom ng = new SecureRandom();
|
||||
byte[] randomBytes = new byte[16];
|
||||
|
||||
ng.nextBytes(randomBytes);
|
||||
randomBytes[6] &= 0x0f;
|
||||
randomBytes[6] |= 0x40;
|
||||
randomBytes[8] &= 0x3f;
|
||||
randomBytes[8] |= 0x80;
|
||||
|
||||
return new GUID(randomBytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* To byte array.
|
||||
*
|
||||
* @return the byte[]
|
||||
*/
|
||||
public byte[] toByteArray() {
|
||||
byte[] guid = new byte[16];
|
||||
|
||||
byte[] bytes1 = new byte[4];
|
||||
bytes1[0] = (byte) (Data1 >> 24);
|
||||
bytes1[1] = (byte) (Data1 >> 16);
|
||||
bytes1[2] = (byte) (Data1 >> 8);
|
||||
bytes1[3] = (byte) (Data1 >> 0);
|
||||
|
||||
byte[] bytes2 = new byte[4];
|
||||
bytes2[0] = (byte) (Data2 >> 24);
|
||||
bytes2[1] = (byte) (Data2 >> 16);
|
||||
bytes2[2] = (byte) (Data2 >> 8);
|
||||
bytes2[3] = (byte) (Data2 >> 0);
|
||||
|
||||
byte[] bytes3 = new byte[4];
|
||||
bytes3[0] = (byte) (Data3 >> 24);
|
||||
bytes3[1] = (byte) (Data3 >> 16);
|
||||
bytes3[2] = (byte) (Data3 >> 8);
|
||||
bytes3[3] = (byte) (Data3 >> 0);
|
||||
|
||||
System.arraycopy(bytes1, 0, guid, 0, 4);
|
||||
System.arraycopy(bytes2, 2, guid, 4, 2);
|
||||
System.arraycopy(bytes3, 2, guid, 6, 2);
|
||||
System.arraycopy(Data4, 0, guid, 8, 8);
|
||||
|
||||
return guid;
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of this Guid, formatted as follows:
|
||||
* xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public String toGuidString() {
|
||||
final String HEXES = "0123456789ABCDEF";
|
||||
byte[] bGuid = toByteArray();
|
||||
|
||||
final StringBuilder hexStr = new StringBuilder(2 * bGuid.length);
|
||||
hexStr.append("{");
|
||||
|
||||
for (int i = 0; i < bGuid.length; i++) {
|
||||
char ch1 = HEXES.charAt((bGuid[i] & 0xF0) >> 4);
|
||||
char ch2 = HEXES.charAt(bGuid[i] & 0x0F);
|
||||
hexStr.append(ch1).append(ch2);
|
||||
|
||||
if ((i == 3) || (i == 5) || (i == 7) || (i == 9))
|
||||
hexStr.append("-");
|
||||
}
|
||||
|
||||
hexStr.append("}");
|
||||
return hexStr.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write fields to backing memory.
|
||||
*/
|
||||
protected void writeFieldsToMemory() {
|
||||
this.writeField("Data1");
|
||||
this.writeField("Data2");
|
||||
this.writeField("Data3");
|
||||
this.writeField("Data4");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.Structure#getFieldOrder()
|
||||
*/
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "Data1", "Data2", "Data3",
|
||||
"Data4" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class CLSID.
|
||||
*/
|
||||
public static class CLSID extends GUID {
|
||||
|
||||
/**
|
||||
* The Class ByReference.
|
||||
*/
|
||||
public static class ByReference extends GUID {
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*/
|
||||
public ByReference() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
*/
|
||||
public ByReference(GUID guid) {
|
||||
super(guid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public ByReference(Pointer memory) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new clsid.
|
||||
*/
|
||||
public CLSID() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class REFIID.
|
||||
*/
|
||||
public class REFIID extends IID {
|
||||
|
||||
/**
|
||||
* Instantiates a new refiid.
|
||||
*/
|
||||
public REFIID() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new refiid.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public REFIID(Pointer memory) {
|
||||
super(memory);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new refiid.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
*/
|
||||
public REFIID(byte[] data) {
|
||||
super(data);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class IID.
|
||||
*/
|
||||
public class IID extends GUID {
|
||||
|
||||
/**
|
||||
* Instantiates a new iid.
|
||||
*/
|
||||
public IID() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new iid.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public IID(Pointer memory) {
|
||||
super(memory);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public IID(String iid) {
|
||||
super(iid);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new iid.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
*/
|
||||
public IID(byte[] data) {
|
||||
super(data);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The Constant IID_NULL. */
|
||||
public final static IID IID_NULL = new IID();
|
||||
|
||||
/**
|
||||
* The Class GUID.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public static class GUID extends Structure {
|
||||
|
||||
/**
|
||||
* The Class ByReference.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public static class ByReference extends GUID implements
|
||||
Structure.ByReference {
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*/
|
||||
public ByReference() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
*/
|
||||
public ByReference(GUID guid) {
|
||||
super(guid.getPointer());
|
||||
|
||||
Data1 = guid.Data1;
|
||||
Data2 = guid.Data2;
|
||||
Data3 = guid.Data3;
|
||||
Data4 = guid.Data4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public ByReference(Pointer memory) {
|
||||
super(memory);
|
||||
}
|
||||
}
|
||||
|
||||
/** The Data1. */
|
||||
public int Data1;
|
||||
|
||||
/** The Data2. */
|
||||
public short Data2;
|
||||
|
||||
/** The Data3. */
|
||||
public short Data3;
|
||||
|
||||
/** The Data4. */
|
||||
public byte[] Data4 = new byte[8];
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*/
|
||||
public GUID() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
*/
|
||||
public GUID(GUID guid) {
|
||||
this.Data1 = guid.Data1;
|
||||
this.Data2 = guid.Data2;
|
||||
this.Data3 = guid.Data3;
|
||||
this.Data4 = guid.Data4;
|
||||
|
||||
this.writeFieldsToMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
*/
|
||||
public GUID(String guid) {
|
||||
this(fromString(guid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
*/
|
||||
public GUID(byte[] data) {
|
||||
this(fromBinary(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public GUID(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* From binary.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
* @return the guid
|
||||
*/
|
||||
public static GUID fromBinary(byte[] data) {
|
||||
if (data.length != 16) {
|
||||
throw new IllegalArgumentException("Invalid data length: "
|
||||
+ data.length);
|
||||
}
|
||||
|
||||
GUID newGuid = new GUID();
|
||||
long data1Temp = data[0] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[1] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[2] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[3] & 0xff;
|
||||
newGuid.Data1 = (int) data1Temp;
|
||||
|
||||
int data2Temp = data[4] & 0xff;
|
||||
data2Temp <<= 8;
|
||||
data2Temp |= data[5] & 0xff;
|
||||
newGuid.Data2 = (short) data2Temp;
|
||||
|
||||
int data3Temp = data[6] & 0xff;
|
||||
data3Temp <<= 8;
|
||||
data3Temp |= data[7] & 0xff;
|
||||
newGuid.Data3 = (short) data3Temp;
|
||||
|
||||
newGuid.Data4[0] = data[8];
|
||||
newGuid.Data4[1] = data[9];
|
||||
newGuid.Data4[2] = data[10];
|
||||
newGuid.Data4[3] = data[11];
|
||||
newGuid.Data4[4] = data[12];
|
||||
newGuid.Data4[5] = data[13];
|
||||
newGuid.Data4[6] = data[14];
|
||||
newGuid.Data4[7] = data[15];
|
||||
|
||||
newGuid.writeFieldsToMemory();
|
||||
|
||||
return newGuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* From string.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
* @return the guid
|
||||
*/
|
||||
public static GUID fromString(String guid) {
|
||||
int y = 0;
|
||||
char[] _cnewguid = new char[32];
|
||||
char[] _cguid = guid.toCharArray();
|
||||
byte[] bdata = new byte[16];
|
||||
GUID newGuid = new GUID();
|
||||
|
||||
// we not accept a string longer than 38 chars
|
||||
if (guid.length() > 38) {
|
||||
throw new IllegalArgumentException("Invalid guid length: "
|
||||
+ guid.length());
|
||||
}
|
||||
|
||||
// remove '{', '}' and '-' from guid string
|
||||
for (int i = 0; i < _cguid.length; i++) {
|
||||
if ((_cguid[i] != '{') && (_cguid[i] != '-')
|
||||
&& (_cguid[i] != '}'))
|
||||
_cnewguid[y++] = _cguid[i];
|
||||
}
|
||||
|
||||
// convert char to byte
|
||||
for (int i = 0; i < 32; i += 2) {
|
||||
bdata[i / 2] = (byte) ((Character.digit(_cnewguid[i], 16) << 4)
|
||||
+ Character.digit(_cnewguid[i + 1], 16) & 0xff);
|
||||
}
|
||||
|
||||
if (bdata.length != 16) {
|
||||
throw new IllegalArgumentException("Invalid data length: "
|
||||
+ bdata.length);
|
||||
}
|
||||
|
||||
long data1Temp = bdata[0] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= bdata[1] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= bdata[2] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= bdata[3] & 0xff;
|
||||
newGuid.Data1 = (int) data1Temp;
|
||||
|
||||
int data2Temp = bdata[4] & 0xff;
|
||||
data2Temp <<= 8;
|
||||
data2Temp |= bdata[5] & 0xff;
|
||||
newGuid.Data2 = (short) data2Temp;
|
||||
|
||||
int data3Temp = bdata[6] & 0xff;
|
||||
data3Temp <<= 8;
|
||||
data3Temp |= bdata[7] & 0xff;
|
||||
newGuid.Data3 = (short) data3Temp;
|
||||
|
||||
newGuid.Data4[0] = bdata[8];
|
||||
newGuid.Data4[1] = bdata[9];
|
||||
newGuid.Data4[2] = bdata[10];
|
||||
newGuid.Data4[3] = bdata[11];
|
||||
newGuid.Data4[4] = bdata[12];
|
||||
newGuid.Data4[5] = bdata[13];
|
||||
newGuid.Data4[6] = bdata[14];
|
||||
newGuid.Data4[7] = bdata[15];
|
||||
|
||||
newGuid.writeFieldsToMemory();
|
||||
|
||||
return newGuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new guid. Code taken from the standard jdk implementation
|
||||
* (see UUID class).
|
||||
*
|
||||
* @return the guid
|
||||
*/
|
||||
public static GUID newGuid() {
|
||||
SecureRandom ng = new SecureRandom();
|
||||
byte[] randomBytes = new byte[16];
|
||||
|
||||
ng.nextBytes(randomBytes);
|
||||
randomBytes[6] &= 0x0f;
|
||||
randomBytes[6] |= 0x40;
|
||||
randomBytes[8] &= 0x3f;
|
||||
randomBytes[8] |= 0x80;
|
||||
|
||||
return new GUID(randomBytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* To byte array.
|
||||
*
|
||||
* @return the byte[]
|
||||
*/
|
||||
public byte[] toByteArray() {
|
||||
byte[] guid = new byte[16];
|
||||
|
||||
byte[] bytes1 = new byte[4];
|
||||
bytes1[0] = (byte) (Data1 >> 24);
|
||||
bytes1[1] = (byte) (Data1 >> 16);
|
||||
bytes1[2] = (byte) (Data1 >> 8);
|
||||
bytes1[3] = (byte) (Data1 >> 0);
|
||||
|
||||
byte[] bytes2 = new byte[4];
|
||||
bytes2[0] = (byte) (Data2 >> 24);
|
||||
bytes2[1] = (byte) (Data2 >> 16);
|
||||
bytes2[2] = (byte) (Data2 >> 8);
|
||||
bytes2[3] = (byte) (Data2 >> 0);
|
||||
|
||||
byte[] bytes3 = new byte[4];
|
||||
bytes3[0] = (byte) (Data3 >> 24);
|
||||
bytes3[1] = (byte) (Data3 >> 16);
|
||||
bytes3[2] = (byte) (Data3 >> 8);
|
||||
bytes3[3] = (byte) (Data3 >> 0);
|
||||
|
||||
System.arraycopy(bytes1, 0, guid, 0, 4);
|
||||
System.arraycopy(bytes2, 2, guid, 4, 2);
|
||||
System.arraycopy(bytes3, 2, guid, 6, 2);
|
||||
System.arraycopy(Data4, 0, guid, 8, 8);
|
||||
|
||||
return guid;
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of this Guid, formatted as follows:
|
||||
* xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public String toGuidString() {
|
||||
final String HEXES = "0123456789ABCDEF";
|
||||
byte[] bGuid = toByteArray();
|
||||
|
||||
final StringBuilder hexStr = new StringBuilder(2 * bGuid.length);
|
||||
hexStr.append("{");
|
||||
|
||||
for (int i = 0; i < bGuid.length; i++) {
|
||||
char ch1 = HEXES.charAt((bGuid[i] & 0xF0) >> 4);
|
||||
char ch2 = HEXES.charAt(bGuid[i] & 0x0F);
|
||||
hexStr.append(ch1).append(ch2);
|
||||
|
||||
if ((i == 3) || (i == 5) || (i == 7) || (i == 9))
|
||||
hexStr.append("-");
|
||||
}
|
||||
|
||||
hexStr.append("}");
|
||||
return hexStr.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write fields to backing memory.
|
||||
*/
|
||||
protected void writeFieldsToMemory() {
|
||||
this.writeField("Data1");
|
||||
this.writeField("Data2");
|
||||
this.writeField("Data3");
|
||||
this.writeField("Data4");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.Structure#getFieldOrder()
|
||||
*/
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "Data1", "Data2", "Data3",
|
||||
"Data4" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class CLSID.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public static class CLSID extends GUID {
|
||||
|
||||
/**
|
||||
* The Class ByReference.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public static class ByReference extends GUID {
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*/
|
||||
public ByReference() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
*/
|
||||
public ByReference(GUID guid) {
|
||||
super(guid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public ByReference(Pointer memory) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new clsid.
|
||||
*/
|
||||
public CLSID() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new clsid.
|
||||
*
|
||||
* @param guid the guid
|
||||
*/
|
||||
public CLSID(String guid) {
|
||||
super(guid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new clsid.
|
||||
*
|
||||
* @param guid the guid
|
||||
*/
|
||||
public CLSID(GUID guid) {
|
||||
super(guid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class REFIID.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class REFIID extends IID {
|
||||
|
||||
/**
|
||||
* Instantiates a new refiid.
|
||||
*/
|
||||
public REFIID() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new refiid.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public REFIID(Pointer memory) {
|
||||
super(memory);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new refiid.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
*/
|
||||
public REFIID(byte[] data) {
|
||||
super(data);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class IID.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class IID extends GUID {
|
||||
|
||||
/**
|
||||
* Instantiates a new iid.
|
||||
*/
|
||||
public IID() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new iid.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public IID(Pointer memory) {
|
||||
super(memory);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new iid.
|
||||
*
|
||||
* @param iid the iid
|
||||
*/
|
||||
public IID(String iid) {
|
||||
super(iid);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new iid.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
*/
|
||||
public IID(byte[] data) {
|
||||
super(data);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
}
|
||||
}
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -28,58 +28,56 @@ import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Kernel32 utility API.
|
||||
*
|
||||
* @author dblock[at]dblock.org
|
||||
* @author markus[at]headcrashing[dot]eu
|
||||
*/
|
||||
public abstract class Kernel32Util implements WinDef {
|
||||
|
||||
|
||||
/**
|
||||
* Get current computer NetBIOS name.
|
||||
* @return
|
||||
* Netbios name.
|
||||
*
|
||||
* @return Netbios name.
|
||||
*/
|
||||
public static String getComputerName() {
|
||||
char buffer[] = new char[WinBase.MAX_COMPUTERNAME_LENGTH + 1];
|
||||
IntByReference lpnSize = new IntByReference(buffer.length);
|
||||
if (! Kernel32.INSTANCE.GetComputerName(buffer, lpnSize)) {
|
||||
char buffer[] = new char[WinBase.MAX_COMPUTERNAME_LENGTH + 1];
|
||||
IntByReference lpnSize = new IntByReference(buffer.length);
|
||||
if (!Kernel32.INSTANCE.GetComputerName(buffer, lpnSize)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Format a message from the value obtained from {@link
|
||||
* Kernel32#GetLastError} or {@link Native#getLastError}.
|
||||
* Format a message from the value obtained from
|
||||
* {@link Kernel32#GetLastError} or {@link Native#getLastError}.
|
||||
*
|
||||
* @param code
|
||||
* int
|
||||
* @return
|
||||
* Formatted message.
|
||||
* int
|
||||
* @return Formatted message.
|
||||
*/
|
||||
public static String formatMessage(int code) {
|
||||
PointerByReference buffer = new PointerByReference();
|
||||
PointerByReference buffer = new PointerByReference();
|
||||
if (0 == Kernel32.INSTANCE.FormatMessage(
|
||||
WinBase.FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||
| WinBase.FORMAT_MESSAGE_FROM_SYSTEM
|
||||
| WinBase.FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
null,
|
||||
code,
|
||||
0, // TODO: MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)
|
||||
buffer,
|
||||
0,
|
||||
null)) {
|
||||
WinBase.FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||
| WinBase.FORMAT_MESSAGE_FROM_SYSTEM
|
||||
| WinBase.FORMAT_MESSAGE_IGNORE_INSERTS, null, code, 0, // TODO:
|
||||
// MAKELANGID(LANG_NEUTRAL,
|
||||
// SUBLANG_DEFAULT)
|
||||
buffer, 0, null)) {
|
||||
throw new LastErrorException(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
String s = buffer.getValue().getString(0, ! Boolean.getBoolean("w32.ascii"));
|
||||
Kernel32.INSTANCE.LocalFree(buffer.getValue());
|
||||
return s.trim();
|
||||
}
|
||||
String s = buffer.getValue().getWideString(0);
|
||||
Kernel32.INSTANCE.LocalFree(buffer.getValue());
|
||||
return s.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a message from an HRESULT.
|
||||
*
|
||||
* @param code
|
||||
* HRESULT
|
||||
* @return
|
||||
* Formatted message.
|
||||
* HRESULT
|
||||
* @return Formatted message.
|
||||
*/
|
||||
public static String formatMessage(HRESULT code) {
|
||||
return formatMessage(code.intValue());
|
||||
@@ -89,75 +87,76 @@ public abstract class Kernel32Util implements WinDef {
|
||||
public static String formatMessageFromHR(HRESULT code) {
|
||||
return formatMessage(code.intValue());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Format a system message from an error code.
|
||||
*
|
||||
* @param code
|
||||
* Error code, typically a result of GetLastError.
|
||||
* @return
|
||||
* Formatted message.
|
||||
* Error code, typically a result of GetLastError.
|
||||
* @return Formatted message.
|
||||
*/
|
||||
public static String formatMessageFromLastErrorCode(int code) {
|
||||
return formatMessageFromHR(W32Errors.HRESULT_FROM_WIN32(code));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the path designated for temporary files.
|
||||
* @return
|
||||
* Path.
|
||||
*
|
||||
* @return Path.
|
||||
*/
|
||||
public static String getTempPath() {
|
||||
DWORD nBufferLength = new DWORD(WinDef.MAX_PATH);
|
||||
char[] buffer = new char[nBufferLength.intValue()];
|
||||
if (Kernel32.INSTANCE.GetTempPath(nBufferLength, buffer).intValue() == 0) {
|
||||
char[] buffer = new char[nBufferLength.intValue()];
|
||||
if (Kernel32.INSTANCE.GetTempPath(nBufferLength, buffer).intValue() == 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
|
||||
public static void deleteFile(String filename) {
|
||||
if (! Kernel32.INSTANCE.DeleteFile(filename)) {
|
||||
if (!Kernel32.INSTANCE.DeleteFile(filename)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns valid drives in the system.
|
||||
* @return
|
||||
* An array of valid drives.
|
||||
*
|
||||
* @return An array of valid drives.
|
||||
*/
|
||||
public static String[] getLogicalDriveStrings() {
|
||||
DWORD dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(new DWORD(0), null);
|
||||
if (dwSize.intValue() <= 0) {
|
||||
DWORD dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(new DWORD(0),
|
||||
null);
|
||||
if (dwSize.intValue() <= 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
char buf[] = new char[dwSize.intValue()];
|
||||
dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(dwSize, buf);
|
||||
if (dwSize.intValue() <= 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
List<String> drives = new ArrayList<String>();
|
||||
String drive = "";
|
||||
// the buffer is double-null-terminated
|
||||
for(int i = 0; i < buf.length - 1; i++) {
|
||||
char buf[] = new char[dwSize.intValue()];
|
||||
dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(dwSize, buf);
|
||||
if (dwSize.intValue() <= 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
List<String> drives = new ArrayList<String>();
|
||||
String drive = "";
|
||||
// the buffer is double-null-terminated
|
||||
for (int i = 0; i < buf.length - 1; i++) {
|
||||
if (buf[i] == 0) {
|
||||
drives.add(drive);
|
||||
drive = "";
|
||||
} else {
|
||||
drive += buf[i];
|
||||
}
|
||||
}
|
||||
return drives.toArray(new String[0]);
|
||||
}
|
||||
|
||||
}
|
||||
return drives.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves file system attributes for a specified file or directory.
|
||||
*
|
||||
* @param fileName
|
||||
* The name of the file or directory.
|
||||
* @return
|
||||
* The attributes of the specified file or directory.
|
||||
* The name of the file or directory.
|
||||
* @return The attributes of the specified file or directory.
|
||||
*/
|
||||
public static int getFileAttributes(String fileName) {
|
||||
int fileAttributes = Kernel32.INSTANCE.GetFileAttributes(fileName);
|
||||
@@ -178,23 +177,20 @@ public abstract class Kernel32Util implements WinDef {
|
||||
|
||||
HANDLE hFile = null;
|
||||
try {
|
||||
hFile = Kernel32.INSTANCE.CreateFile(fileName,
|
||||
WinNT.GENERIC_READ,
|
||||
WinNT.FILE_SHARE_READ,
|
||||
new WinBase.SECURITY_ATTRIBUTES(),
|
||||
WinNT.OPEN_EXISTING,
|
||||
WinNT.FILE_ATTRIBUTE_NORMAL,
|
||||
new HANDLEByReference().getValue());
|
||||
hFile = Kernel32.INSTANCE.CreateFile(fileName, WinNT.GENERIC_READ,
|
||||
WinNT.FILE_SHARE_READ, new WinBase.SECURITY_ATTRIBUTES(),
|
||||
WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL,
|
||||
new HANDLEByReference().getValue());
|
||||
|
||||
if (WinBase.INVALID_HANDLE_VALUE.equals(hFile)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
int type = Kernel32.INSTANCE.GetFileType(hFile);
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case WinNT.FILE_TYPE_UNKNOWN:
|
||||
int err = Kernel32.INSTANCE.GetLastError();
|
||||
switch(err) {
|
||||
switch (err) {
|
||||
case WinError.NO_ERROR:
|
||||
break;
|
||||
default:
|
||||
@@ -207,7 +203,7 @@ public abstract class Kernel32Util implements WinDef {
|
||||
}
|
||||
} finally {
|
||||
if (hFile != null) {
|
||||
if (! Kernel32.INSTANCE.CloseHandle(hFile)) {
|
||||
if (!Kernel32.INSTANCE.CloseHandle(hFile)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
@@ -220,13 +216,13 @@ public abstract class Kernel32Util implements WinDef {
|
||||
public static int getDriveType(String rootName) {
|
||||
return Kernel32.INSTANCE.GetDriveType(rootName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of an environment variable.
|
||||
*
|
||||
* @param name
|
||||
* Name of the environment variable.
|
||||
* @return
|
||||
* Value of an environment variable.
|
||||
* Name of the environment variable.
|
||||
* @return Value of an environment variable.
|
||||
*/
|
||||
public static String getEnvironmentVariable(String name) {
|
||||
// obtain the buffer size
|
||||
@@ -238,101 +234,195 @@ public abstract class Kernel32Util implements WinDef {
|
||||
}
|
||||
// obtain the value
|
||||
char[] buffer = new char[size];
|
||||
size = Kernel32.INSTANCE.GetEnvironmentVariable(name, buffer, buffer.length);
|
||||
size = Kernel32.INSTANCE.GetEnvironmentVariable(name, buffer,
|
||||
buffer.length);
|
||||
if (size <= 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return Native.toString(buffer);
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an integer associated with a key in the specified section of an initialization file.
|
||||
*
|
||||
* Retrieves an integer associated with a key in the specified section of an
|
||||
* initialization file.
|
||||
*
|
||||
* @param appName
|
||||
* The name of the section in the initialization file.
|
||||
* @param keyName
|
||||
* The name of the key whose value is to be retrieved. This value is in the form of a string; the {@link Kernel32#GetPrivateProfileInt} function converts
|
||||
* the string into an integer and returns the integer.
|
||||
* The name of the key whose value is to be retrieved. This value
|
||||
* is in the form of a string; the
|
||||
* {@link Kernel32#GetPrivateProfileInt} function converts the
|
||||
* string into an integer and returns the integer.
|
||||
* @param defaultValue
|
||||
* The default value to return if the key name cannot be found in the initialization file.
|
||||
* The default value to return if the key name cannot be found in
|
||||
* the initialization file.
|
||||
* @param fileName
|
||||
* The name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the
|
||||
* Windows directory.
|
||||
* The name of the initialization file. If this parameter does
|
||||
* not contain a full path to the file, the system searches for
|
||||
* the file in the Windows directory.
|
||||
* @return The retrieved integer, or the default if not found.
|
||||
*/
|
||||
public static final int getPrivateProfileInt(final String appName, final String keyName, final int defaultValue, final String fileName) {
|
||||
return Kernel32.INSTANCE.GetPrivateProfileInt(appName, keyName, defaultValue, fileName);
|
||||
public static final int getPrivateProfileInt(final String appName,
|
||||
final String keyName, final int defaultValue, final String fileName) {
|
||||
return Kernel32.INSTANCE.GetPrivateProfileInt(appName, keyName,
|
||||
defaultValue, fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a string from the specified section in an initialization file.
|
||||
*
|
||||
* @param lpAppName
|
||||
* The name of the section containing the key name. If this parameter is {@code null}, the {@link Kernel32#GetPrivateProfileString} function copies all
|
||||
* The name of the section containing the key name. If this
|
||||
* parameter is {@code null}, the
|
||||
* {@link Kernel32#GetPrivateProfileString} function copies all
|
||||
* section names in the file to the supplied buffer.
|
||||
* @param lpKeyName
|
||||
* The name of the key whose associated string is to be retrieved. If this parameter is {@code null}, all key names in the section specified by
|
||||
* the {@code lpAppName} parameter are returned.
|
||||
* The name of the key whose associated string is to be
|
||||
* retrieved. If this parameter is {@code null}, all key names in
|
||||
* the section specified by the {@code lpAppName} parameter are
|
||||
* returned.
|
||||
* @param lpDefault
|
||||
* A default string. If the {@code lpKeyName} key cannot be found in the initialization file, {@link Kernel32#GetPrivateProfileString} returns the
|
||||
* default. If this parameter is {@code null}, the default is an empty string, {@code ""}.
|
||||
* A default string. If the {@code lpKeyName} key cannot be found
|
||||
* in the initialization file,
|
||||
* {@link Kernel32#GetPrivateProfileString} returns the default.
|
||||
* If this parameter is {@code null}, the default is an empty
|
||||
* string, {@code ""}.
|
||||
* <p>
|
||||
* Avoid specifying a default string with trailing blank characters. The function inserts a {@code null} character in the
|
||||
* {@code lpReturnedString} buffer to strip any trailing blanks.
|
||||
* Avoid specifying a default string with trailing blank
|
||||
* characters. The function inserts a {@code null} character in
|
||||
* the {@code lpReturnedString} buffer to strip any trailing
|
||||
* blanks.
|
||||
* </p>
|
||||
* @param lpFileName
|
||||
* The name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the
|
||||
* Windows directory.
|
||||
* The name of the initialization file. If this parameter does
|
||||
* not contain a full path to the file, the system searches for
|
||||
* the file in the Windows directory.
|
||||
* @return <p>
|
||||
* If neither {@code lpAppName} nor {@code lpKeyName} is {@code null} and the destination buffer is too small to hold the requested string, the
|
||||
* string is truncated.
|
||||
* If neither {@code lpAppName} nor {@code lpKeyName} is
|
||||
* {@code null} and the destination buffer is too small to hold the
|
||||
* requested string, the string is truncated.
|
||||
* </p>
|
||||
* <p>
|
||||
* If either {@code lpAppName} or {@code lpKeyName} is {@code null} and the destination buffer is too small to hold all the strings, the last string
|
||||
* is truncated and followed by two {@code null} characters.
|
||||
* If either {@code lpAppName} or {@code lpKeyName} is {@code null}
|
||||
* and the destination buffer is too small to hold all the strings,
|
||||
* the last string is truncated and followed by two {@code null}
|
||||
* characters.
|
||||
* </p>
|
||||
* <p>
|
||||
* In the event the initialization file specified by {@code lpFileName} is not found, or contains invalid values, this function will set errorno
|
||||
* with a value of '0x2' (File Not Found). To retrieve extended error information, call {@link Kernel32#GetLastError}.
|
||||
* In the event the initialization file specified by
|
||||
* {@code lpFileName} is not found, or contains invalid values, this
|
||||
* function will set errorno with a value of '0x2' (File Not Found).
|
||||
* To retrieve extended error information, call
|
||||
* {@link Kernel32#GetLastError}.
|
||||
* </p>
|
||||
*/
|
||||
public static final String getPrivateProfileString(final String lpAppName, final String lpKeyName, final String lpDefault, final String lpFileName) {
|
||||
public static final String getPrivateProfileString(final String lpAppName,
|
||||
final String lpKeyName, final String lpDefault,
|
||||
final String lpFileName) {
|
||||
final char buffer[] = new char[1024];
|
||||
Kernel32.INSTANCE.GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, buffer, new DWORD(buffer.length), lpFileName);
|
||||
Kernel32.INSTANCE.GetPrivateProfileString(lpAppName, lpKeyName,
|
||||
lpDefault, buffer, new DWORD(buffer.length), lpFileName);
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
public static final void writePrivateProfileString(final String appName, final String keyName, final String string, final String fileName) {
|
||||
if (!Kernel32.INSTANCE.WritePrivateProfileString(appName, keyName, string, fileName))
|
||||
public static final void writePrivateProfileString(final String appName,
|
||||
final String keyName, final String string, final String fileName) {
|
||||
if (!Kernel32.INSTANCE.WritePrivateProfileString(appName, keyName,
|
||||
string, fileName))
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to get the processor information. Takes care of auto-growing the array.
|
||||
*
|
||||
* Convenience method to get the processor information. Takes care of
|
||||
* auto-growing the array.
|
||||
*
|
||||
* @return the array of processor information.
|
||||
*/
|
||||
public static final WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[] getLogicalProcessorInformation()
|
||||
{
|
||||
int sizePerStruct = new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION().size();
|
||||
WinDef.DWORDByReference bufferSize = new WinDef.DWORDByReference(new WinDef.DWORD(sizePerStruct));
|
||||
public static final WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[] getLogicalProcessorInformation() {
|
||||
int sizePerStruct = new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION()
|
||||
.size();
|
||||
WinDef.DWORDByReference bufferSize = new WinDef.DWORDByReference(
|
||||
new WinDef.DWORD(sizePerStruct));
|
||||
Memory memory;
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
memory = new Memory(bufferSize.getValue().intValue());
|
||||
if (! Kernel32.INSTANCE.GetLogicalProcessorInformation(memory, bufferSize))
|
||||
{
|
||||
if (!Kernel32.INSTANCE.GetLogicalProcessorInformation(memory,
|
||||
bufferSize)) {
|
||||
int err = Kernel32.INSTANCE.GetLastError();
|
||||
if (err != WinError.ERROR_INSUFFICIENT_BUFFER)
|
||||
throw new Win32Exception(err);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Win32Exception(err);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION firstInformation = new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION(memory);
|
||||
int returnedStructCount = bufferSize.getValue().intValue() / sizePerStruct;
|
||||
return (WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[]) firstInformation.toArray(new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[returnedStructCount]);
|
||||
WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION firstInformation = new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION(
|
||||
memory);
|
||||
int returnedStructCount = bufferSize.getValue().intValue()
|
||||
/ sizePerStruct;
|
||||
return (WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[]) firstInformation
|
||||
.toArray(new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[returnedStructCount]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all the keys and values for the specified section of an initialization file.
|
||||
*
|
||||
* <p>
|
||||
* Each string has the following format: {@code key=string}.
|
||||
* </p>
|
||||
* <p>
|
||||
* This operation is atomic; no updates to the specified initialization file are allowed while this method is executed.
|
||||
* </p>
|
||||
*
|
||||
* @param appName
|
||||
* The name of the section in the initialization file.
|
||||
* @param fileName
|
||||
* The name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the
|
||||
* Windows directory.
|
||||
* @return The key name and value pairs associated with the named section.
|
||||
*/
|
||||
public static final String[] getPrivateProfileSection(final String appName, final String fileName) {
|
||||
final char buffer[] = new char[32768]; // Maximum section size according to MSDN (http://msdn.microsoft.com/en-us/library/windows/desktop/ms724348(v=vs.85).aspx)
|
||||
if (Kernel32.INSTANCE.GetPrivateProfileSection(appName, buffer, new DWORD(buffer.length), fileName).intValue() == 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return new String(buffer).split("\0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the names of all sections in an initialization file.
|
||||
* <p>
|
||||
* This operation is atomic; no updates to the initialization file are allowed while this method is executed.
|
||||
* </p>
|
||||
*
|
||||
* @param fileName
|
||||
* The name of the initialization file. If this parameter is {@code NULL}, the function searches the Win.ini file. If this parameter does not
|
||||
* contain a full path to the file, the system searches for the file in the Windows directory.
|
||||
* @return the section names associated with the named file.
|
||||
*/
|
||||
public static final String[] getPrivateProfileSectionNames(final String fileName) {
|
||||
final char buffer[] = new char[65536]; // Maximum INI file size according to MSDN (http://support.microsoft.com/kb/78346)
|
||||
if (Kernel32.INSTANCE.GetPrivateProfileSectionNames(buffer, new DWORD(buffer.length), fileName).intValue() == 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return new String(buffer).split("\0");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param appName
|
||||
* The name of the section in which data is written. This section name is typically the name of the calling application.
|
||||
* @param strings
|
||||
* The new key names and associated values that are to be written to the named section. Each entry must be of the form {@code key=value}.
|
||||
* @param fileName
|
||||
* The name of the initialization file. If this parameter does not contain a full path for the file, the function searches the Windows directory
|
||||
* for the file. If the file does not exist and lpFileName does not contain a full path, the function creates the file in the Windows directory.
|
||||
*/
|
||||
public static final void writePrivateProfileSection(final String appName, final String[] strings, final String fileName) {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
for (final String string : strings)
|
||||
buffer.append(string).append('\0');
|
||||
buffer.append('\0');
|
||||
if (! Kernel32.INSTANCE.WritePrivateProfileSection(appName, buffer.toString(), fileName)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,9 +69,9 @@ public interface NTSecApi extends StdCallLibrary {
|
||||
if (data.length < 2 || data[data.length - 1] != 0) {
|
||||
Memory newdata = new Memory(data.length + 2);
|
||||
newdata.write(0, data, 0, data.length);
|
||||
return newdata.getString(0, true);
|
||||
return newdata.getWideString(0);
|
||||
}
|
||||
return Buffer.getString(0, true);
|
||||
return Buffer.getWideString(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ public abstract class Netapi32Util {
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return bufptr.getValue().getString(0, true);
|
||||
return bufptr.getValue().getWideString(0);
|
||||
} finally {
|
||||
if (W32Errors.ERROR_SUCCESS != Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
@@ -167,7 +167,7 @@ public abstract class Netapi32Util {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
// type of domain: bufferType.getValue()
|
||||
return lpNameBuffer.getValue().getString(0, true);
|
||||
return lpNameBuffer.getValue().getWideString(0);
|
||||
} finally {
|
||||
if (lpNameBuffer.getPointer() != null) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
|
||||
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -186,7 +186,7 @@ public interface Ole32 extends StdCallLibrary {
|
||||
* are the only two functions that can be used to generate a CLSID
|
||||
* for an OLE 1 object.
|
||||
*/
|
||||
HRESULT CLSIDFromProgID(String lpszProgID, CLSID lpclsid);
|
||||
HRESULT CLSIDFromProgID(String lpszProgID, CLSID.ByReference lpclsid);
|
||||
|
||||
/**
|
||||
* Converts a string generated by the StringFromCLSID function back into the
|
||||
@@ -212,6 +212,6 @@ public interface Ole32 extends StdCallLibrary {
|
||||
*
|
||||
* REGDB_E_READREGDB The registry could not be opened for reading.
|
||||
*/
|
||||
HRESULT CLSIDFromString(WString lpsz, CLSID pclsid);
|
||||
HRESULT CLSIDFromString(WString lpsz, CLSID.ByReference pclsid);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
/* 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
|
||||
@@ -32,12 +32,13 @@ import com.sun.jna.platform.win32.WinDef.LCID;
|
||||
import com.sun.jna.platform.win32.WinDef.PVOID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.COM.ITypeLib;
|
||||
import com.sun.jna.platform.win32.COM.TypeLib;
|
||||
import com.sun.jna.ptr.DoubleByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Oleaut32.dll Interface.
|
||||
*
|
||||
@@ -123,6 +124,17 @@ public interface OleAuto extends StdCallLibrary {
|
||||
*/
|
||||
public void SysFreeString(BSTR bstr);
|
||||
|
||||
/**
|
||||
* The VariantInit function initializes the VARIANTARG by setting the vt
|
||||
* field to VT_EMPTY. Unlike VariantClear, this function does not interpret
|
||||
* the current contents of the VARIANTARG. Use VariantInit to initialize new
|
||||
* local variables of type VARIANTARG (or VARIANT).
|
||||
*
|
||||
* @param pvarg
|
||||
* The variant to initialize.
|
||||
*/
|
||||
public void VariantInit(VARIANT.ByReference pvarg);
|
||||
|
||||
/**
|
||||
* The VariantInit function initializes the VARIANTARG by setting the vt
|
||||
* field to VT_EMPTY. Unlike VariantClear, this function does not interpret
|
||||
@@ -224,7 +236,7 @@ public interface OleAuto extends StdCallLibrary {
|
||||
* A safe array descriptor, or null if the array could not be
|
||||
* created.
|
||||
*/
|
||||
public SAFEARRAY SafeArrayCreate(VARTYPE vt, int cDims,
|
||||
public SAFEARRAY.ByReference SafeArrayCreate(VARTYPE vt, int cDims,
|
||||
SAFEARRAYBOUND[] rgsabound);
|
||||
|
||||
/**
|
||||
@@ -459,7 +471,7 @@ public interface OleAuto extends StdCallLibrary {
|
||||
* TYPE_E_CANTLOADLIBRARY The type library or DLL could not be
|
||||
* loaded.
|
||||
*/
|
||||
HRESULT LoadTypeLib(WString szFile, ITypeLib pptlib);
|
||||
public HRESULT LoadTypeLib(WString szFile, PointerByReference pptlib);
|
||||
|
||||
/**
|
||||
* Converts a system time to a variant representation.
|
||||
@@ -472,6 +484,6 @@ public interface OleAuto extends StdCallLibrary {
|
||||
*
|
||||
* @return The function returns TRUE on success and FALSE otherwise.
|
||||
*/
|
||||
int SystemTimeToVariantTime(SYSTEMTIME lpSystemTime,
|
||||
public int SystemTimeToVariantTime(SYSTEMTIME lpSystemTime,
|
||||
DoubleByReference pvtime);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.sun.jna.platform.win32.WTypes.VARTYPE;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.COM.COMUtils;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class OleAut32Util.
|
||||
*
|
||||
@@ -32,8 +33,8 @@ public abstract class OleAutoUtil {
|
||||
* @param size the size
|
||||
* @return the sAFEARRA y. by reference
|
||||
*/
|
||||
public static SAFEARRAY createVarArray(int size) {
|
||||
SAFEARRAY psa;
|
||||
public static SAFEARRAY.ByReference createVarArray(int size) {
|
||||
SAFEARRAY.ByReference psa;
|
||||
SAFEARRAYBOUND[] rgsabound = new SAFEARRAYBOUND[1];
|
||||
rgsabound[0] = new SAFEARRAYBOUND(size, 0);
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/* Copyright (c) 2011 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.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HGLRC;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* opengl32.dll Interface.
|
||||
*/
|
||||
public interface OpenGL32 extends StdCallLibrary {
|
||||
OpenGL32 INSTANCE = (OpenGL32) Native.loadLibrary("opengl32", OpenGL32.class);
|
||||
|
||||
/**
|
||||
* The glGetString function returns a string describing the current OpenGL connection.
|
||||
*
|
||||
* @param name
|
||||
* One of the following symbolic constants.
|
||||
* @return The glGetString function returns a pointer to a static string describing some aspect of the current OpenGL connection.
|
||||
*/
|
||||
public String glGetString(int name);
|
||||
|
||||
/**
|
||||
* The wglCreateContext function creates a new OpenGL rendering context, which is suitable for drawing on the device
|
||||
* referenced by hdc. The rendering context has the same pixel format as the device context.
|
||||
*
|
||||
* @param hdc
|
||||
* Handle to a device context for which the function creates a suitable OpenGL rendering context.
|
||||
* @return handle to an OpenGL rendering context
|
||||
*/
|
||||
public WinDef.HGLRC wglCreateContext(HDC windowDC);
|
||||
|
||||
/**
|
||||
* The wglGetCurrentContext function obtains a handle to the current OpenGL rendering context of the calling thread.
|
||||
*
|
||||
* @return If the calling thread has a current OpenGL rendering context, wglGetCurrentContext returns a
|
||||
* handle to that rendering context. Otherwise, the return value is NULL.
|
||||
*/
|
||||
public WinDef.HGLRC wglGetCurrentContext();
|
||||
|
||||
/**
|
||||
* The wglMakeCurrent function makes a specified OpenGL rendering context the calling thread's current rendering
|
||||
* context. All subsequent OpenGL calls made by the thread are drawn on the device identified by hdc.
|
||||
*
|
||||
* @param hdc
|
||||
* Handle to a device context. Subsequent OpenGL calls made by the calling thread are drawn on the
|
||||
* device identified by hdc.
|
||||
* @param hglrc
|
||||
* Handle to an OpenGL rendering context that the function sets as the calling thread's rendering context.
|
||||
* @return true if successful
|
||||
*/
|
||||
public boolean wglMakeCurrent(HDC windowDC, WinDef.HGLRC hglrc);
|
||||
|
||||
/**
|
||||
* The wglDeleteContext function deletes a specified OpenGL rendering context.
|
||||
*
|
||||
* @param hglrc
|
||||
* Handle to an OpenGL rendering context that the function will delete.
|
||||
* @return true if successful
|
||||
*/
|
||||
public boolean wglDeleteContext(WinDef.HGLRC hglrc);
|
||||
|
||||
/**
|
||||
* The wglGetProcAddress function returns the address of an OpenGL extension function for use with the
|
||||
* current OpenGL rendering context.
|
||||
*
|
||||
* @param lpszProc
|
||||
* Points to a null-terminated string that is the name of the extension function.
|
||||
* The name of the extension function must be identical to a corresponding function implemented by OpenGL.
|
||||
* @return When the function succeeds, the return value is the address of the extension function.
|
||||
*/
|
||||
public Pointer wglGetProcAddress(String lpszProc);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/* Copyright (c) 2011 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.win32;
|
||||
|
||||
import com.sun.jna.Function;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HGLRCByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinGDI.PIXELFORMATDESCRIPTOR;
|
||||
|
||||
/**
|
||||
* opengl32 utility API.
|
||||
*/
|
||||
public abstract class OpenGL32Util {
|
||||
|
||||
/**
|
||||
* Return a procedure function pointer
|
||||
* @param procName the procedure name
|
||||
* @return the function
|
||||
*/
|
||||
public static Function wglGetProcAddress(String procName) {
|
||||
Pointer funcPointer = OpenGL32.INSTANCE.wglGetProcAddress("wglEnumGpusNV");
|
||||
return (funcPointer == null) ? null : Function.getFunction(funcPointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a RAS connection by name
|
||||
* @param connName the connection name
|
||||
* @return the RAS connection structure
|
||||
*/
|
||||
public static int countGpusNV() {
|
||||
// create a dummy window
|
||||
HWND hWnd = User32Util.createWindow("Message", null, 0, 0, 0, 0, 0, null, null, null, null);
|
||||
HDC hdc = User32.INSTANCE.GetDC(hWnd);
|
||||
|
||||
// set a compatible pixel format
|
||||
PIXELFORMATDESCRIPTOR.ByReference pfd = new PIXELFORMATDESCRIPTOR.ByReference();
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = WinGDI.PFD_DRAW_TO_WINDOW | WinGDI.PFD_SUPPORT_OPENGL | WinGDI.PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = WinGDI.PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = 24;
|
||||
pfd.cDepthBits = 16;
|
||||
pfd.iLayerType = WinGDI.PFD_MAIN_PLANE;
|
||||
GDI32.INSTANCE.SetPixelFormat(hdc, GDI32.INSTANCE.ChoosePixelFormat(hdc, pfd), pfd);
|
||||
|
||||
// create the OpenGL context to get function address
|
||||
WinDef.HGLRC hGLRC = OpenGL32.INSTANCE.wglCreateContext(hdc);
|
||||
OpenGL32.INSTANCE.wglMakeCurrent(hdc, hGLRC);
|
||||
Pointer funcPointer = OpenGL32.INSTANCE.wglGetProcAddress("wglEnumGpusNV");
|
||||
Function fncEnumGpusNV = (funcPointer == null) ? null : Function.getFunction(funcPointer);
|
||||
OpenGL32.INSTANCE.wglDeleteContext(hGLRC);
|
||||
|
||||
// destroy the window
|
||||
User32.INSTANCE.ReleaseDC(hWnd, hdc);
|
||||
User32Util.destroyWindow(hWnd);
|
||||
|
||||
// abort if the nVidia extensions are not present
|
||||
if (fncEnumGpusNV == null) return 0;
|
||||
|
||||
// enumerate nVidia adapters
|
||||
HGLRCByReference hGPU = new HGLRCByReference();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
Boolean ok = (Boolean) fncEnumGpusNV.invoke(Boolean.class, new Object[] { Integer.valueOf(i), hGPU, });
|
||||
if (!ok.booleanValue()) return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
/* Copyright (c) 2011 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.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.WinDef.BOOLByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.WinRas.RASCONN;
|
||||
import com.sun.jna.platform.win32.WinRas.RASCONNSTATUS;
|
||||
import com.sun.jna.platform.win32.WinRas.RASCREDENTIALS;
|
||||
import com.sun.jna.platform.win32.WinRas.RASDIALEXTENSIONS;
|
||||
import com.sun.jna.platform.win32.WinRas.RASDIALPARAMS;
|
||||
import com.sun.jna.platform.win32.WinRas.RASENTRY;
|
||||
import com.sun.jna.platform.win32.WinRas.RAS_STATS;
|
||||
import com.sun.jna.platform.win32.WinRas.RasDialFunc2;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Rasapi32.dll Interface.
|
||||
*/
|
||||
public interface Rasapi32 extends StdCallLibrary {
|
||||
Rasapi32 INSTANCE = (Rasapi32) Native.loadLibrary("Rasapi32", Rasapi32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* The RasDial function establishes a RAS connection between a RAS client and a RAS server.
|
||||
* The connection data includes callback and user-authentication information.
|
||||
*
|
||||
* @param lpRasDialExtensions
|
||||
* Pointer to a RASDIALEXTENSIONS structure that specifies a set of RasDial extended features to enable.
|
||||
* Set this parameter to NULL if there is not a need to enable these features.
|
||||
* @param lpszPhonebook
|
||||
* Pointer to a null-terminated string that specifies the full path and file name of a phone-book (PBK) file.
|
||||
* If this parameter is NULL, the function uses the current default phone-book file.
|
||||
* The default phone-book file is the one selected by the user in the User Preferences property sheet of the
|
||||
* Dial-Up Networking dialog box.
|
||||
* @param lpRasDialParams
|
||||
* Pointer to a RASDIALPARAMS structure that specifies calling parameters for the RAS connection.
|
||||
* Use the RasGetEntryDialParams function to retrieve a copy of this structure for a particular phone-book entry.
|
||||
* @param dwNotifierType
|
||||
* Specifies the nature of the lpvNotifier parameter. If lpvNotifier is NULL, dwNotifierType is ignored.
|
||||
* If lpvNotifier is not NULL, set dwNotifierType to one of the following values.
|
||||
* @param lpvNotifier
|
||||
* Specifies a window handle or a RasDialFunc, RasDialFunc1, or RasDialFunc2 callback function to receive
|
||||
* RasDial event notifications.
|
||||
* The dwNotifierType parameter specifies the nature of lpvNotifier. Please refer to its description preceding for further detail.
|
||||
* @param lphRasConn
|
||||
* Pointer to a variable of type HRASCONN. Set the HRASCONN variable to NULL before calling RasDial.
|
||||
* If RasDial succeeds, it stores a handle to the RAS connection into *lphRasConn.
|
||||
* @return If the function succeeds, the return value is ERROR_SUCCESS.
|
||||
*/
|
||||
public int RasDial(RASDIALEXTENSIONS.ByReference lpRasDialExtensions, String lpszPhonebook, RASDIALPARAMS.ByReference lpRasDialParams, int dwNotifierType, RasDialFunc2 lpvNotifier, HANDLEByReference lphRasConn);
|
||||
|
||||
/**
|
||||
* The RasEnumConnections function lists all active RAS connections. It returns each connection's handle and phone-book entry name.
|
||||
*
|
||||
* @param lprasconn
|
||||
* Pointer to a buffer that receives, on output, an array of RASCONN structures, one for each RAS connection.
|
||||
* On input, an application must set the dwSize member of the first RASCONN structure in the buffer to sizeof(RASCONN)
|
||||
* in order to identify the version of the structure being passed.
|
||||
* @param lpcb
|
||||
* Pointer to a variable that, on input, contains the size, in bytes, of the buffer specified by lprasconn.
|
||||
* On output, the function sets this variable to the number of bytes required to enumerate the RAS connections.
|
||||
* @param lpcConnections
|
||||
* Pointer to a variable that receives the number of RASCONN structures written to the buffer specified by lprasconn.
|
||||
* @return If the function succeeds, the return value is ERROR_SUCCESS.
|
||||
*/
|
||||
public int RasEnumConnections(RASCONN[] lprasconn, IntByReference lpcb, IntByReference lpcConnections);
|
||||
|
||||
/**
|
||||
* The RasGetConnectionStatistics function retrieves accumulated connection statistics for the specified connection.
|
||||
*
|
||||
* @param hrasconn
|
||||
* Handle to the connection. Use RasDial or RasEnumConnections to obtain this handle.
|
||||
* @param lpStatistics
|
||||
* Pointer to the RASCONNSTATUS structure that, on output, receives the status information.
|
||||
* On input, set the dwSize member of the structure to sizeof(RASCONNSTATUS) in order to identify the version of the structure being passed.
|
||||
* @return If the function succeeds, the return value is ERROR_SUCCESS.
|
||||
*/
|
||||
public int RasGetConnectionStatistics(HANDLE hrasconn, RAS_STATS.ByReference lpStatistics);
|
||||
|
||||
/**
|
||||
* The RasGetConnectionStatistics function retrieves accumulated connection statistics for the specified connection.
|
||||
*
|
||||
* @param hrasconn
|
||||
* Specifies the remote access connection for which to retrieve the status. This handle must have been obtained from RasDial
|
||||
* or RasEnumConnections.
|
||||
* @param lprasconnstatus
|
||||
* Pointer to the RASCONNSTATUS structure that, on output, receives the status information.
|
||||
* On input, set the dwSize member of the structure to sizeof(RASCONNSTATUS) in order to identify the version of the structure being passed.
|
||||
* @return If the function succeeds, the return value is ERROR_SUCCESS.
|
||||
*/
|
||||
public int RasGetConnectStatus(HANDLE hrasconn, RASCONNSTATUS.ByReference lprasconnstatus);
|
||||
|
||||
/**
|
||||
* The RasGetCredentials function retrieves the user credentials associated with a specified RAS phone-book entry.
|
||||
*
|
||||
* @param lpszPhonebook
|
||||
* Pointer to a null-terminated string that specifies the full path and file name of a phone-book (PBK) file.
|
||||
* If this parameter is NULL, the function uses the current default phone-book file. The default phone-book file is the
|
||||
* one selected by the user in the User Preferences property sheet of the Dial-Up Networking dialog box.
|
||||
* @param lpszEntry
|
||||
* Pointer to a null-terminated string that specifies the name of a phone-book entry.
|
||||
* @param lpCredentials
|
||||
* Pointer to the RASCREDENTIALS structure that, on output, receives the user credentials associated with the specified
|
||||
* phone-book entry.
|
||||
* On input, set the dwSize member of the structure to sizeof(RASCREDENTIALS), and set the dwMask member to indicate the
|
||||
* credential information to retrieve. When the function returns, dwMask indicates the members that were successfully retrieved.
|
||||
* @return If the function succeeds, the return value is ERROR_SUCCESS.
|
||||
*/
|
||||
public int RasGetCredentials(String lpszPhonebook, String lpszEntry, RASCREDENTIALS.ByReference lpCredentials);
|
||||
|
||||
/**
|
||||
* The RasGetEntryProperties function retrieves the properties of a phone-book entry.
|
||||
*
|
||||
* @param lpszPhonebook
|
||||
* Pointer to a null-terminated string that specifies the full path and file name of a phone-book (PBK) file.
|
||||
* If this parameter is NULL, the function uses the current default phone-book file.
|
||||
* The default phone-book file is the one selected by the user in the User Preferences property sheet of the
|
||||
* Dial-Up Networking dialog box.
|
||||
* @param lpszEntry
|
||||
* Pointer to a null-terminated string that specifies an existing entry name.
|
||||
* If an empty string is specified, the function returns default values in the buffers pointed to by the
|
||||
* lpRasEntry and lpbDeviceInfo parameters.
|
||||
* @param lpRasEntry
|
||||
* Pointer to a RASENTRY structure followed by additional bytes for the alternate phone number list, if there is one.
|
||||
* @param lpdwEntryInfoSize
|
||||
* Pointer to a variable that, on input, specifies the size, in bytes, of the lpRasEntry buffer.
|
||||
* @param lpbDeviceInfo
|
||||
* This parameter is no longer used. The calling function should set this parameter to NULL.
|
||||
* @param lpdwDeviceInfoSize
|
||||
* This parameter is unused. The calling function should set this parameter to NULL.
|
||||
* @return If the function succeeds, the return value is ERROR_SUCCESS.
|
||||
*/
|
||||
public int RasGetEntryProperties(String lpszPhonebook, String lpszEntry, RASENTRY.ByReference lpRasEntry, IntByReference lpdwEntryInfoSize, Pointer lpbDeviceInfo, Pointer lpdwDeviceInfoSize);
|
||||
|
||||
/**
|
||||
* The RasGetProjectionInfo function obtains information about a remote access projection operation for a specified remote access
|
||||
* component protocol.
|
||||
*
|
||||
* @param hrasconn
|
||||
* Handle to the remote access connection of interest. An application obtains a RAS connection handle from the RasDial
|
||||
* or RasEnumConnections function.
|
||||
* @param rasprojection
|
||||
* Specifies the RASPROJECTION enumerated type value that identifies the protocol of interest.
|
||||
* @param lpprojection
|
||||
* Pointer to a buffer that receives the information specified by the rasprojection parameter. The information is in a
|
||||
* structure appropriate to the rasprojection value.
|
||||
* @param lpcb
|
||||
* Pointer to a variable that, on input, specifies the size, in bytes, of the buffer pointed to by lpprojection.
|
||||
* On output, this variable receives the size, in bytes, of the lpprojection buffer.
|
||||
* @return If the function succeeds, the return value is ERROR_SUCCESS.
|
||||
*/
|
||||
public int RasGetProjectionInfo(HANDLE hrasconn, int rasprojection, Pointer lpprojection, IntByReference lpcb);
|
||||
|
||||
/**
|
||||
* The RasHangUp function terminates a remote access connection. The connection is specified with a RAS connection handle.
|
||||
* The function releases all RASAPI32.DLL resources associated with the handle.
|
||||
*
|
||||
* @param hrasconn
|
||||
* Specifies the remote access connection to terminate. This is a handle returned from a previous call to RasDial or RasEnumConnections.
|
||||
* @return If the function succeeds, the return value is ERROR_SUCCESS.
|
||||
*/
|
||||
public int RasHangUp(HANDLE hrasconn);
|
||||
|
||||
/**
|
||||
* The RasSetEntryProperties function changes the connection information for an entry in the phone book or creates a new phone-book entry.
|
||||
*
|
||||
* @param lpszPhonebook
|
||||
* Pointer to a null-terminated string that specifies the full path and file name of a phone-book (PBK) file.
|
||||
* If this parameter is NULL, the function uses the current default phone-book file.
|
||||
* The default phone-book file is the one selected by the user in the User Preferences property sheet of the Dial-Up
|
||||
* Networking dialog box.
|
||||
* @param lpszEntry
|
||||
* Pointer to a null-terminated string that specifies an entry name.
|
||||
* @param lpRasEntry
|
||||
* Pointer to the RASENTRY structure that specifies the new connection data to be associated with the
|
||||
* phone-book entry indicated by the lpszEntry parameter.
|
||||
* @param dwEntryInfoSize
|
||||
* Specifies the size, in bytes, of the buffer identified by the lpRasEntry parameter.
|
||||
* @param lpbDeviceInfo
|
||||
* Pointer to a buffer that specifies device-specific configuration information.
|
||||
* This is opaque TAPI device configuration information. For more information about TAPI device configuration,
|
||||
* see the lineGetDevConfig function in Telephony Application Programming Interfaces (TAPI) in the Platform SDK.
|
||||
* @param dwDeviceInfoSize
|
||||
* Specifies the size, in bytes, of the lpbDeviceInfo buffer.
|
||||
* @return If the function succeeds, the return value is ERROR_SUCCESS.
|
||||
*/
|
||||
public int RasSetEntryProperties(String lpszPhonebook, String lpszEntry, RASENTRY.ByReference lpRasEntry, int dwEntryInfoSize, byte[] lpbDeviceInfo, int dwDeviceInfoSize);
|
||||
|
||||
/**
|
||||
* The RasGetEntryDialParams function retrieves the connection information saved by the last successful call to the RasDial or
|
||||
* RasSetEntryDialParams function for a specified phone-book entry.
|
||||
*
|
||||
* @param lpszPhonebook
|
||||
* Pointer to a null-terminated string that specifies the full path and file name of a phone-book (PBK) file.
|
||||
* If this parameter is NULL, the function uses the current default phone-book file.
|
||||
* The default phone-book file is the one selected by the user in the User Preferences property sheet of the
|
||||
* Dial-Up Networking dialog box.
|
||||
* @param lprasdialparams
|
||||
* Pointer to a RASDIALPARAMS structure.
|
||||
* @param lpfPassword
|
||||
* Pointer to a flag that indicates whether the function retrieved the password associated with the user
|
||||
* name for the phone-book entry. The lpfPassword parameter is TRUE if the system has saved a password for
|
||||
* the specified entry. If the system has no password saved for this entry, lpfPassword is FALSE.
|
||||
* @return If the function succeeds, the return value is ERROR_SUCCESS.
|
||||
*/
|
||||
public int RasGetEntryDialParams(String lpszPhonebook, RASDIALPARAMS.ByReference lprasdialparams, BOOLByReference lpfPassword);
|
||||
|
||||
/**
|
||||
* The RasGetErrorString function obtains an error message string for a specified RAS error value.
|
||||
*
|
||||
* @param uErrorValue
|
||||
* Specifies the error value of interest. These are values returned by one of the RAS functions:
|
||||
* those listed in the RasError.h header file.
|
||||
* @param lpszErrorString
|
||||
* Pointer to a buffer that receives the error string. This parameter must not be NULL.
|
||||
* @param cBufSize
|
||||
* Specifies the size, in characters, of the buffer pointed to by lpszErrorString.
|
||||
*/
|
||||
public int RasGetErrorString(int uErrorValue, char[] lpszErrorString, int cBufSize);
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
/* Copyright (c) 2011 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.win32;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.jna.platform.win32.WinDef.BOOLByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.WinRas.RASCONN;
|
||||
import com.sun.jna.platform.win32.WinRas.RASCREDENTIALS;
|
||||
import com.sun.jna.platform.win32.WinRas.RASDIALPARAMS;
|
||||
import com.sun.jna.platform.win32.WinRas.RASENTRY;
|
||||
import com.sun.jna.platform.win32.WinRas.RASPPPIP;
|
||||
import com.sun.jna.platform.win32.WinRas.RasDialFunc2;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
/**
|
||||
* Rasapi32 utility API.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public abstract class Rasapi32Util {
|
||||
private static final int RASP_PppIp = 0x8021;
|
||||
|
||||
private static Object phoneBookMutex = new Object();
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final Map CONNECTION_STATE_TEXT = new HashMap();
|
||||
|
||||
static {
|
||||
CONNECTION_STATE_TEXT.put(0, "Opening the port...");
|
||||
CONNECTION_STATE_TEXT.put(1, "Port has been opened successfully");
|
||||
CONNECTION_STATE_TEXT.put(2, "Connecting to the device...");
|
||||
CONNECTION_STATE_TEXT.put(3, "The device has connected successfully.");
|
||||
CONNECTION_STATE_TEXT.put(4, "All devices in the device chain have successfully connected.");
|
||||
CONNECTION_STATE_TEXT.put(5, "Verifying the user name and password...");
|
||||
CONNECTION_STATE_TEXT.put(6, "An authentication event has occurred.");
|
||||
CONNECTION_STATE_TEXT.put(7, "Requested another validation attempt with a new user.");
|
||||
CONNECTION_STATE_TEXT.put(8, "Server has requested a callback number.");
|
||||
CONNECTION_STATE_TEXT.put(9, "The client has requested to change the password");
|
||||
CONNECTION_STATE_TEXT.put(10, "Registering your computer on the network...");
|
||||
CONNECTION_STATE_TEXT.put(11, "The link-speed calculation phase is starting...");
|
||||
CONNECTION_STATE_TEXT.put(12, "An authentication request is being acknowledged.");
|
||||
CONNECTION_STATE_TEXT.put(13, "Reauthentication (after callback) is starting.");
|
||||
CONNECTION_STATE_TEXT.put(14, "The client has successfully completed authentication.");
|
||||
CONNECTION_STATE_TEXT.put(15, "The line is about to disconnect for callback.");
|
||||
CONNECTION_STATE_TEXT.put(16, "Delaying to give the modem time to reset for callback.");
|
||||
CONNECTION_STATE_TEXT.put(17, "Waiting for an incoming call from server.");
|
||||
CONNECTION_STATE_TEXT.put(18, "Projection result information is available.");
|
||||
CONNECTION_STATE_TEXT.put(19, "User authentication is being initiated or retried.");
|
||||
CONNECTION_STATE_TEXT.put(20, "Client has been called back and is about to resume authentication.");
|
||||
CONNECTION_STATE_TEXT.put(21, "Logging on to the network...");
|
||||
CONNECTION_STATE_TEXT.put(22, "Subentry has been connected");
|
||||
CONNECTION_STATE_TEXT.put(23, "Subentry has been disconnected");
|
||||
CONNECTION_STATE_TEXT.put(4096, "Terminal state supported by RASPHONE.EXE.");
|
||||
CONNECTION_STATE_TEXT.put(4097, "Retry authentication state supported by RASPHONE.EXE.");
|
||||
CONNECTION_STATE_TEXT.put(4098, "Callback state supported by RASPHONE.EXE.");
|
||||
CONNECTION_STATE_TEXT.put(4099, "Change password state supported by RASPHONE.EXE.");
|
||||
CONNECTION_STATE_TEXT.put(4100, "Displaying authentication UI");
|
||||
CONNECTION_STATE_TEXT.put(8192, "Connected to remote server successfully");
|
||||
CONNECTION_STATE_TEXT.put(8193, "Disconnected");
|
||||
}
|
||||
|
||||
/**
|
||||
* Exceptions
|
||||
*/
|
||||
public static class Ras32Exception extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final int code;
|
||||
|
||||
/**
|
||||
* Returns the error code of the error.
|
||||
* @return
|
||||
* Error code.
|
||||
*/
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* New Win32 exception from an error code, usually obtained from GetLastError.
|
||||
* @param code
|
||||
* Error code.
|
||||
*/
|
||||
public Ras32Exception(int code) {
|
||||
super(getRasErrorString(code));
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the RAS error description
|
||||
* @param code the error code
|
||||
* @return the RAS description
|
||||
*/
|
||||
public static String getRasErrorString(int code) {
|
||||
char[] msg = new char[1024];
|
||||
int err = Rasapi32.INSTANCE.RasGetErrorString(code, msg, msg.length);
|
||||
if (err != WinError.ERROR_SUCCESS) return "Unknown error " + code;
|
||||
int len = 0;
|
||||
for (; len < msg.length; len++) if (msg[len] == 0) break;
|
||||
return new String(msg, 0, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the connection status value to text
|
||||
* @param connStatus the connection status
|
||||
* @return the descriptive text
|
||||
*/
|
||||
public static String getRasConnectionStatusText(int connStatus) {
|
||||
if (!CONNECTION_STATE_TEXT.containsKey(connStatus)) return Integer.toString(connStatus);
|
||||
return (String)CONNECTION_STATE_TEXT.get(connStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a RAS connection by name
|
||||
* @param connName the connection name
|
||||
* @return the RAS connection structure
|
||||
* @throws Ras32Exception errors
|
||||
*/
|
||||
public static HANDLE getRasConnection(String connName) throws Ras32Exception {
|
||||
// size the array needed
|
||||
IntByReference lpcb = new IntByReference(0);
|
||||
IntByReference lpcConnections = new IntByReference();
|
||||
int err = Rasapi32.INSTANCE.RasEnumConnections(null, lpcb, lpcConnections);
|
||||
if (err != WinError.ERROR_SUCCESS && err != WinRas.ERROR_BUFFER_TOO_SMALL) throw new Ras32Exception(err);
|
||||
if (lpcb.getValue() == 0) return null;
|
||||
|
||||
// get the connections
|
||||
RASCONN[] connections = new RASCONN[lpcConnections.getValue()];
|
||||
for (int i = 0; i < lpcConnections.getValue(); i++) connections[i] = new RASCONN();
|
||||
lpcb = new IntByReference(connections[0].dwSize * lpcConnections.getValue());
|
||||
err = Rasapi32.INSTANCE.RasEnumConnections(connections, lpcb, lpcConnections);
|
||||
if (err != WinError.ERROR_SUCCESS) throw new Ras32Exception(err);
|
||||
|
||||
// find connection
|
||||
for (int i = 0; i < lpcConnections.getValue(); i++) {
|
||||
if (new String(connections[i].szEntryName).equals(connName)) return connections[i].hrasconn;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hangup a connection by name
|
||||
* @param connName the connection name
|
||||
* @throws Ras32Exception errors
|
||||
*/
|
||||
public static void hangupRasConnection(String connName) throws Ras32Exception {
|
||||
HANDLE hrasConn = getRasConnection(connName);
|
||||
if (hrasConn == null) return;
|
||||
int err = Rasapi32.INSTANCE.RasHangUp(hrasConn);
|
||||
if (err != WinError.ERROR_SUCCESS) throw new Ras32Exception(err);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hangup a connection
|
||||
* @param hrasConn the connection
|
||||
* @throws Ras32Exception errors
|
||||
*/
|
||||
public static void hangupRasConnection(HANDLE hrasConn) throws Ras32Exception {
|
||||
if (hrasConn == null) return;
|
||||
int err = Rasapi32.INSTANCE.RasHangUp(hrasConn);
|
||||
if (err != WinError.ERROR_SUCCESS) throw new Ras32Exception(err);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the connection's IP projection
|
||||
* @param hrasConn the RAS connection handle
|
||||
* @return the IP projection
|
||||
* @throws Ras32Exception errors
|
||||
*/
|
||||
public static RASPPPIP getIPProjection(HANDLE hrasConn) throws Ras32Exception {
|
||||
RASPPPIP pppIpProjection = new RASPPPIP();
|
||||
IntByReference lpcb = new IntByReference(pppIpProjection.size());
|
||||
pppIpProjection.write();
|
||||
int err = Rasapi32.INSTANCE.RasGetProjectionInfo(hrasConn, RASP_PppIp, pppIpProjection.getPointer(), lpcb);
|
||||
if (err != WinError.ERROR_SUCCESS) throw new Ras32Exception(err);
|
||||
pppIpProjection.read();
|
||||
return pppIpProjection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the phone book entry.
|
||||
* @param entryName the entry name
|
||||
* @return the RAS entry
|
||||
* @throws Ras32Exception any errors
|
||||
*/
|
||||
public static RASENTRY.ByReference getPhoneBookEntry(String entryName) throws Ras32Exception {
|
||||
synchronized (phoneBookMutex) {
|
||||
RASENTRY.ByReference rasEntry = new RASENTRY.ByReference();
|
||||
IntByReference lpdwEntryInfoSize = new IntByReference(rasEntry.size());
|
||||
int err = Rasapi32.INSTANCE.RasGetEntryProperties(null, entryName, rasEntry, lpdwEntryInfoSize, null, null);
|
||||
if (err != WinError.ERROR_SUCCESS) throw new Ras32Exception(err);
|
||||
return rasEntry;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a phone book entry
|
||||
* @param entryName the phone book entry name
|
||||
* @param rasEntry the entry parameters
|
||||
* @throws Ras32Exception errors
|
||||
*/
|
||||
public static void setPhoneBookEntry(String entryName, RASENTRY.ByReference rasEntry) throws Ras32Exception {
|
||||
synchronized (phoneBookMutex) {
|
||||
int err = Rasapi32.INSTANCE.RasSetEntryProperties(null, entryName, rasEntry, rasEntry.size(), null, 0);
|
||||
if (err != WinError.ERROR_SUCCESS) throw new Ras32Exception(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get a phone book entry's dialing parameters
|
||||
* @param entryName the phone book entry name
|
||||
* @return the entry's dialing parameters parameters
|
||||
* @throws Ras32Exception errors
|
||||
*/
|
||||
public static RASDIALPARAMS getPhoneBookDialingParams(String entryName) throws Ras32Exception {
|
||||
synchronized (phoneBookMutex) {
|
||||
RASDIALPARAMS.ByReference rasDialParams = new RASDIALPARAMS.ByReference();
|
||||
System.arraycopy(rasDialParams.szEntryName, 0, entryName.toCharArray(), 0, entryName.length());
|
||||
BOOLByReference lpfPassword = new BOOLByReference();
|
||||
int err = Rasapi32.INSTANCE.RasGetEntryDialParams(null, rasDialParams, lpfPassword);
|
||||
if (err != WinError.ERROR_SUCCESS) throw new Ras32Exception(err);
|
||||
return rasDialParams;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dial a phone book entry by name (Synchronously)
|
||||
* @param entryName The phone book entry name
|
||||
* @throws Ras32Exception errors
|
||||
*/
|
||||
public static HANDLE dialEntry(String entryName) throws Ras32Exception {
|
||||
// get the RAS Credentials
|
||||
RASCREDENTIALS.ByReference credentials = new RASCREDENTIALS.ByReference();
|
||||
synchronized (phoneBookMutex) {
|
||||
credentials.dwMask = WinRas.RASCM_UserName | WinRas.RASCM_Password | WinRas.RASCM_Domain;
|
||||
int err = Rasapi32.INSTANCE.RasGetCredentials(null, entryName, credentials);
|
||||
if (err != WinError.ERROR_SUCCESS) throw new Ras32Exception(err);
|
||||
}
|
||||
|
||||
// set the dialing parameters
|
||||
RASDIALPARAMS.ByReference rasDialParams = new RASDIALPARAMS.ByReference();
|
||||
System.arraycopy(entryName.toCharArray(), 0, rasDialParams.szEntryName, 0, entryName.length());
|
||||
System.arraycopy(credentials.szUserName, 0, rasDialParams.szUserName, 0, credentials.szUserName.length);
|
||||
System.arraycopy(credentials.szPassword, 0, rasDialParams.szPassword, 0, credentials.szPassword.length);
|
||||
System.arraycopy(credentials.szDomain, 0, rasDialParams.szDomain, 0, credentials.szDomain.length);
|
||||
|
||||
// dial
|
||||
HANDLEByReference hrasConn = new HANDLEByReference();
|
||||
int err = Rasapi32.INSTANCE.RasDial(null, null, rasDialParams, 0, null, hrasConn);
|
||||
if (err != WinError.ERROR_SUCCESS) {
|
||||
if (hrasConn.getValue() != null) Rasapi32.INSTANCE.RasHangUp(hrasConn.getValue());
|
||||
throw new Ras32Exception(err);
|
||||
}
|
||||
return hrasConn.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dial a phone book entry by name (Asynchronously - callback type 2)
|
||||
* @param entryName The phone book entry name
|
||||
* @return the HRASCONN for this connection
|
||||
* @throws Ras32Exception errors
|
||||
*/
|
||||
public static HANDLE dialEntry(String entryName, RasDialFunc2 func2) throws Ras32Exception {
|
||||
// get the RAS Credentials
|
||||
RASCREDENTIALS.ByReference credentials = new RASCREDENTIALS.ByReference();
|
||||
synchronized (phoneBookMutex) {
|
||||
credentials.dwMask = WinRas.RASCM_UserName | WinRas.RASCM_Password | WinRas.RASCM_Domain;
|
||||
int err = Rasapi32.INSTANCE.RasGetCredentials(null, entryName, credentials);
|
||||
if (err != WinError.ERROR_SUCCESS) throw new Ras32Exception(err);
|
||||
}
|
||||
|
||||
// set the dialing parameters
|
||||
RASDIALPARAMS.ByReference rasDialParams = new RASDIALPARAMS.ByReference();
|
||||
System.arraycopy(entryName.toCharArray(), 0, rasDialParams.szEntryName, 0, entryName.length());
|
||||
System.arraycopy(credentials.szUserName, 0, rasDialParams.szUserName, 0, credentials.szUserName.length);
|
||||
System.arraycopy(credentials.szPassword, 0, rasDialParams.szPassword, 0, credentials.szPassword.length);
|
||||
System.arraycopy(credentials.szDomain, 0, rasDialParams.szDomain, 0, credentials.szDomain.length);
|
||||
|
||||
// dial
|
||||
HANDLEByReference hrasConn = new HANDLEByReference();
|
||||
int err = Rasapi32.INSTANCE.RasDial(null, null, rasDialParams, 2, func2, hrasConn);
|
||||
if (err != WinError.ERROR_SUCCESS) {
|
||||
if (hrasConn.getValue() != null) Rasapi32.INSTANCE.RasHangUp(hrasConn.getValue());
|
||||
throw new Ras32Exception(err);
|
||||
}
|
||||
return hrasConn.getValue();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public interface Shell32 extends ShellAPI, StdCallLibrary {
|
||||
* {@link ShellAPI#ABM_QUERYPOS} Requests a size and screen position for an appbar.
|
||||
* {@link ShellAPI#ABM_SETPOS} Sets the size and screen position of an appbar.
|
||||
* {@link ShellAPI#ABM_GETSTATE} Retrieves the autohide and always-on-top states of the Windows taskbar.
|
||||
* {@link ShellAPI#ABM_GETTASKBARPOS} Retrieves the bounding rectangle of the Windows taskbar. Note that this applies only to the system taskbar. Other objects, particularly toolbars supplied with third-party software, also can be present. As a result, some of the screen area not covered by the Windows taskbar might not be visible to the user. To retrieve the area of the screen not covered by both the taskbar and other app barsÑthe working area available to your applicationÑ, use the GetMonitorInfo function.
|
||||
* {@link ShellAPI#ABM_GETTASKBARPOS} Retrieves the bounding rectangle of the Windows taskbar. Note that this applies only to the system taskbar. Other objects, particularly toolbars supplied with third-party software, also can be present. As a result, some of the screen area not covered by the Windows taskbar might not be visible to the user. To retrieve the area of the screen not covered by both the taskbar and other app bars -- the working area available to your application --, use the GetMonitorInfo function.
|
||||
* {@link ShellAPI#ABM_ACTIVATE} Notifies the system to activate or deactivate an appbar. The lParam member of the APPBARDATA pointed to by pData is set to TRUE to activate or FALSE to deactivate.
|
||||
* {@link ShellAPI#ABM_GETAUTOHIDEBAR} Retrieves the handle to the autohide appbar associated with a particular edge of the screen.
|
||||
* {@link ShellAPI#ABM_SETAUTOHIDEBAR} Registers or unregisters an autohide appbar for an edge of the screen.
|
||||
|
||||
@@ -149,8 +149,8 @@ public interface ShellAPI extends StdCallLibrary {
|
||||
* supplied with third-party software, also can be present. As a result,
|
||||
* some of the screen area not covered by the Windows taskbar might not be
|
||||
* visible to the user. To retrieve the area of the screen not covered by
|
||||
* both the taskbar and other app barsÑthe working area available to your
|
||||
* applicationÑ, use the GetMonitorInfo function.
|
||||
* both the taskbar and other app bars -- the working area available to your
|
||||
* application --, use the GetMonitorInfo function.
|
||||
*/
|
||||
int ABM_ACTIVATE = 0x00000006;
|
||||
/**
|
||||
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -15,95 +15,230 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.PointerType;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.WinDef.USHORT;
|
||||
import com.sun.jna.ptr.ByReference;
|
||||
|
||||
/**
|
||||
* Constant defined in WTypes.h
|
||||
*
|
||||
*
|
||||
* @author scott.palmer
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
|
||||
public interface WTypes {
|
||||
|
||||
public static int CLSCTX_INPROC_SERVER = 0x1;
|
||||
public static int CLSCTX_INPROC_HANDLER = 0x2;
|
||||
public static int CLSCTX_LOCAL_SERVER = 0x4;
|
||||
public static int CLSCTX_INPROC_SERVER16 = 0x8;
|
||||
public static int CLSCTX_REMOTE_SERVER = 0x10;
|
||||
public static int CLSCTX_INPROC_HANDLER16 = 0x20;
|
||||
public static int CLSCTX_RESERVED1 = 0x40;
|
||||
public static int CLSCTX_RESERVED2 = 0x80;
|
||||
public static int CLSCTX_RESERVED3 = 0x100;
|
||||
public static int CLSCTX_RESERVED4 = 0x200;
|
||||
public static int CLSCTX_NO_CODE_DOWNLOAD = 0x400;
|
||||
public static int CLSCTX_RESERVED5 = 0x800;
|
||||
public static int CLSCTX_NO_CUSTOM_MARSHAL = 0x1000;
|
||||
public static int CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000;
|
||||
public static int CLSCTX_NO_FAILURE_LOG = 0x4000;
|
||||
public static int CLSCTX_DISABLE_AAA = 0x8000;
|
||||
public static int CLSCTX_ENABLE_AAA = 0x10000;
|
||||
public static int CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000;
|
||||
public static int CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000;
|
||||
public static int CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000;
|
||||
public static int CLSCTX_ENABLE_CLOAKING = 0x100000;
|
||||
public static int CLSCTX_APPCONTAINER = 0x400000;
|
||||
public static int CLSCTX_ACTIVATE_AAA_AS_IU = 0x800000;
|
||||
public static int CLSCTX_PS_DLL = 0x80000000;
|
||||
public static int CLSCTX_SERVER = CLSCTX_INPROC_SERVER
|
||||
| CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER;
|
||||
public static int CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER
|
||||
| CLSCTX_LOCAL_SERVER;
|
||||
public static int CLSCTX_INPROC_SERVER = 0x1;
|
||||
public static int CLSCTX_INPROC_HANDLER = 0x2;
|
||||
public static int CLSCTX_LOCAL_SERVER = 0x4;
|
||||
public static int CLSCTX_INPROC_SERVER16 = 0x8;
|
||||
public static int CLSCTX_REMOTE_SERVER = 0x10;
|
||||
public static int CLSCTX_INPROC_HANDLER16 = 0x20;
|
||||
public static int CLSCTX_RESERVED1 = 0x40;
|
||||
public static int CLSCTX_RESERVED2 = 0x80;
|
||||
public static int CLSCTX_RESERVED3 = 0x100;
|
||||
public static int CLSCTX_RESERVED4 = 0x200;
|
||||
public static int CLSCTX_NO_CODE_DOWNLOAD = 0x400;
|
||||
public static int CLSCTX_RESERVED5 = 0x800;
|
||||
public static int CLSCTX_NO_CUSTOM_MARSHAL = 0x1000;
|
||||
public static int CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000;
|
||||
public static int CLSCTX_NO_FAILURE_LOG = 0x4000;
|
||||
public static int CLSCTX_DISABLE_AAA = 0x8000;
|
||||
public static int CLSCTX_ENABLE_AAA = 0x10000;
|
||||
public static int CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000;
|
||||
public static int CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000;
|
||||
public static int CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000;
|
||||
public static int CLSCTX_ENABLE_CLOAKING = 0x100000;
|
||||
public static int CLSCTX_APPCONTAINER = 0x400000;
|
||||
public static int CLSCTX_ACTIVATE_AAA_AS_IU = 0x800000;
|
||||
public static int CLSCTX_PS_DLL = 0x80000000;
|
||||
public static int CLSCTX_SERVER = CLSCTX_INPROC_SERVER
|
||||
| CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER;
|
||||
public static int CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER
|
||||
| CLSCTX_LOCAL_SERVER;
|
||||
|
||||
public static class BSTR extends PointerType {
|
||||
public BSTR() {
|
||||
super(Pointer.NULL);
|
||||
}
|
||||
public static class BSTR extends PointerType {
|
||||
public static class ByReference extends BSTR implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.getPointer().setString(0, value, true);
|
||||
}
|
||||
public BSTR() {
|
||||
super(new Memory(Pointer.SIZE));
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.getPointer().getString(0, true);
|
||||
}
|
||||
public BSTR(Pointer pointer) {
|
||||
super(pointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getValue();
|
||||
}
|
||||
}
|
||||
public BSTR(String value) {
|
||||
super(new Memory((value.length() + 1L) * Native.WCHAR_SIZE));
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public class BSTRByReference extends ByReference {
|
||||
public void setValue(String value) {
|
||||
this.getPointer().setWideString(0, value);
|
||||
}
|
||||
|
||||
public BSTRByReference() {
|
||||
super(Pointer.SIZE);
|
||||
}
|
||||
public String getValue() {
|
||||
Pointer pointer = this.getPointer();
|
||||
String str = null;
|
||||
if (pointer != null)
|
||||
str = pointer.getWideString(0);
|
||||
|
||||
public BSTRByReference(String value) {
|
||||
super(Pointer.SIZE);
|
||||
setValue(value);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
getPointer().setString(0, value);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return getPointer().getString(0);
|
||||
}
|
||||
}
|
||||
public class BSTRByReference extends ByReference {
|
||||
public BSTRByReference() {
|
||||
super(Pointer.SIZE);
|
||||
}
|
||||
|
||||
public static class VARTYPE extends USHORT {
|
||||
public VARTYPE() {
|
||||
this(0);
|
||||
}
|
||||
public BSTRByReference(BSTR value) {
|
||||
this();
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
public VARTYPE(int value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
public void setValue(BSTR value) {
|
||||
this.getPointer().setPointer(0, value.getPointer());
|
||||
}
|
||||
|
||||
public BSTR getValue() {
|
||||
return new BSTR(getPointer().getPointer(0));
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return this.getValue().getValue();
|
||||
}
|
||||
}
|
||||
|
||||
public static class LPSTR extends PointerType {
|
||||
public static class ByReference extends BSTR implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
public LPSTR() {
|
||||
super(Pointer.NULL);
|
||||
}
|
||||
|
||||
public LPSTR(Pointer pointer) {
|
||||
super(pointer);
|
||||
}
|
||||
|
||||
public LPSTR(String value) {
|
||||
this();
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.getPointer().setWideString(0, value);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
Pointer pointer = this.getPointer();
|
||||
String str = null;
|
||||
if (pointer != null)
|
||||
str = pointer.getWideString(0);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
public static class LPWSTR extends PointerType {
|
||||
public static class ByReference extends BSTR implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
public LPWSTR() {
|
||||
super(Pointer.NULL);
|
||||
}
|
||||
|
||||
public LPWSTR(Pointer pointer) {
|
||||
super(pointer);
|
||||
}
|
||||
|
||||
public LPWSTR(String value) {
|
||||
this();
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.getPointer().setWideString(0, value);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
Pointer pointer = this.getPointer();
|
||||
String str = null;
|
||||
if (pointer != null)
|
||||
str = pointer.getWideString(0);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
public static class LPOLESTR extends PointerType {
|
||||
public static class ByReference extends BSTR implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
public LPOLESTR() {
|
||||
super(Pointer.NULL);
|
||||
}
|
||||
|
||||
public LPOLESTR(Pointer pointer) {
|
||||
super(pointer);
|
||||
}
|
||||
|
||||
public LPOLESTR(String value) {
|
||||
super(new Memory((value.length() + 1L) * Native.WCHAR_SIZE));
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.getPointer().setWideString(0, value);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
Pointer pointer = this.getPointer();
|
||||
String str = null;
|
||||
if (pointer != null)
|
||||
str = pointer.getWideString(0);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
public static class VARTYPE extends USHORT {
|
||||
public VARTYPE() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public VARTYPE(int value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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