diff --git a/.classpath b/.classpath
index 3383917d0a..d7b6c52328 100644
--- a/.classpath
+++ b/.classpath
@@ -5,5 +5,6 @@
+
diff --git a/CHANGES.md b/CHANGES.md
index fae7c2d78b..c36e1a1164 100755
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,6 +7,10 @@ Release 4.2
Features
--------
+* Significant enhancements to COM support under com.sun.jna.platform.win32.COM.util - [@dhakehurst](https://github.com/dhakehurst).
+ * Use of interfaces and annotations to provide easier implementation of COM interfaces (uses InvocationHandler) - [@dhakehurst](https://github.com/dhakehurst).
+ * Support for COM event callbacks (this was particularly tricky, very happy I got it to work) - [@dhakehurst](https://github.com/dhakehurst).
+ * Support for COM interface discovery by iteration over the RunningObjectTable - [@dhakehurst](https://github.com/dhakehurst).
* Updated AIX natives and build - [@twall](https://github.com/twall).
* [#290](https://github.com/twall/jna/pull/290): Improved the stacktrace for the exceptions thrown by `com.sun.jna.Structure` - [@ebourg](https://github.com/ebourg).
* [#332](https://github.com/twall/jna/pull/332): Added Win32 Monitor Configuration API in `com.sun.jna.platform.win32.Dxva2` - [@msteiger](https://github.com/msteiger).
diff --git a/contrib/msoffice/.classpath b/contrib/msoffice/.classpath
index 8648c074a2..34c74501c1 100644
--- a/contrib/msoffice/.classpath
+++ b/contrib/msoffice/.classpath
@@ -2,7 +2,7 @@
-
-
+
+
diff --git a/contrib/msoffice/jnatest.xls b/contrib/msoffice/jnatest.xls
index 8da722704c..6077e40a43 100644
Binary files a/contrib/msoffice/jnatest.xls and b/contrib/msoffice/jnatest.xls differ
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/office/MSOfficeDemo.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/office/MSOfficeDemo.java
index 49967d4374..f4d6658cbd 100644
--- a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/office/MSOfficeDemo.java
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/office/MSOfficeDemo.java
@@ -18,8 +18,8 @@ public static void main(String[] args) {
+ File.separator;
public MSOfficeDemo() {
- this.testMSWord();
- // this.testMSExcel();
+ //this.testMSWord();
+ this.testMSExcel();
}
public void testMSWord() {
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/MSOfficeExcelDemo.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/MSOfficeExcelDemo.java
new file mode 100644
index 0000000000..a7a49b7d06
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/MSOfficeExcelDemo.java
@@ -0,0 +1,100 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.util.office;
+
+import java.io.File;
+
+import com.sun.jna.platform.win32.COM.office.MSExcel;
+import com.sun.jna.platform.win32.COM.util.AbstractComEventCallbackListener;
+import com.sun.jna.platform.win32.COM.util.Factory;
+import com.sun.jna.platform.win32.COM.util.office.excel.ComExcel_Application;
+import com.sun.jna.platform.win32.COM.util.office.excel.ComIAppEvents;
+import com.sun.jna.platform.win32.COM.util.office.excel.ComIApplication;
+import com.sun.jna.platform.win32.COM.util.office.excel.ComIRange;
+import com.sun.jna.platform.win32.COM.util.office.excel.ComIWorksheet;
+import com.sun.jna.platform.win32.COM.util.office.word.ComWord_Application;
+
+public class MSOfficeExcelDemo {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ new MSOfficeExcelDemo();
+ }
+
+ private String currentWorkingDir = new File("").getAbsolutePath() + File.separator;
+
+ public MSOfficeExcelDemo() {
+ this.testMSExcel();
+ }
+
+ public void testMSExcel() {
+ ComExcel_Application excelObject = null;
+ ComIApplication msExcel = null;
+ Factory factory = null;
+ try {
+ factory = new Factory();
+ excelObject = factory.createObject(ComExcel_Application.class);
+ msExcel = excelObject.queryInterface(ComIApplication.class);
+ System.out.println("MSExcel version: " + msExcel.getVersion());
+ msExcel.setVisible(true);
+ // msExcel.newExcelBook();
+ msExcel.getWorkbooks().Open(currentWorkingDir + "jnatest.xls");
+ msExcel.getActiveSheet().getRange("A1").setValue("Hello from JNA!");
+ // wait 1sec. before closing
+ Thread.currentThread().sleep(1000);
+// // close and save the active sheet
+// msExcel.getActiveWorkbook().Close(true);
+// msExcel.setVisible(true);
+// // msExcel.newExcelBook();
+// msExcel.getWorkbooks().Open(currentWorkingDir + "jnatest.xls");
+// msExcel.getActiveSheet().getRange("A2").setValue("Hello again from JNA!");
+
+ class Listener extends AbstractComEventCallbackListener implements ComIAppEvents {
+ boolean SheetSelectionChange_called;
+
+ @Override
+ public void errorReceivingCallbackEvent(String message, Exception exception) {
+ }
+
+ @Override
+ public void SheetSelectionChange(ComIWorksheet sheet, ComIRange target) {
+ SheetSelectionChange_called = true;
+ }
+
+ };
+ Listener listener = new Listener();
+ msExcel.advise(ComIAppEvents.class, listener);
+//
+// msExcel.getActiveSheet().getRange("A5").Activate();
+//
+// Thread.currentThread().sleep(500);
+
+ // close and save the active sheet
+ msExcel.getActiveWorkbook().Close(true);
+
+ msExcel.Quit();
+ msExcel = null;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (null != msExcel) {
+ msExcel.Quit();
+ }
+ if (null != factory) {
+ factory.disposeAll();
+ }
+ }
+ }
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/MSOfficeWordDemo.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/MSOfficeWordDemo.java
new file mode 100644
index 0000000000..f03467993f
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/MSOfficeWordDemo.java
@@ -0,0 +1,109 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.util.office;
+
+import java.io.File;
+
+import com.sun.jna.platform.win32.COM.COMException;
+import com.sun.jna.platform.win32.COM.util.Factory;
+import com.sun.jna.platform.win32.COM.util.office.word.ComIApplication;
+import com.sun.jna.platform.win32.COM.util.office.word.ComWord_Application;
+import com.sun.jna.platform.win32.COM.util.office.word.WdOriginalFormat;
+import com.sun.jna.platform.win32.COM.util.office.word.WdSaveFormat;
+
+public class MSOfficeWordDemo {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ new MSOfficeWordDemo();
+ }
+
+ private String currentWorkingDir = new File("").getAbsolutePath() + File.separator;
+
+ public MSOfficeWordDemo() {
+ this.testMSWord();
+ }
+
+ public void testMSWord() {
+ ComWord_Application msWordObject = null;
+ ComIApplication msWord = null;
+ Factory factory = null;
+ try {
+ String tempDir = System.getProperty("java.io.tmpdir");
+ System.out.println("Files in temp dir: "+tempDir);
+
+ factory = new Factory();
+ msWordObject = factory.createObject(ComWord_Application.class);
+ msWord = msWordObject.queryInterface(ComIApplication.class);
+
+ System.out.println("MSWord version: " + msWord.getVersion());
+
+ msWord.setVisible(true);
+ // msWord.newDocument();
+ msWord.getDocuments().Open(currentWorkingDir + "jnatest.doc");
+ msWord.getSelection().TypeText("Hello from JNA! \n\n");
+ // wait 10sec. before closing
+ Thread.sleep(1000);
+ // save in different formats
+ // pdf format is only supported in MSWord 2007 and above
+ msWord.getActiveDocument().SaveAs(tempDir+"\\jnatestSaveAs.doc", WdSaveFormat.wdFormatDocument);
+ msWord.getActiveDocument().SaveAs(tempDir+"\\jnatestSaveAs.pdf", WdSaveFormat.wdFormatPDF);
+ msWord.getActiveDocument().SaveAs(tempDir+"\\jnatestSaveAs.rtf", WdSaveFormat.wdFormatRTF);
+ msWord.getActiveDocument().SaveAs(tempDir+"\\jnatestSaveAs.html", WdSaveFormat.wdFormatHTML);
+ // close and save the document
+ msWord.getActiveDocument().Close(false);
+ msWord.getDocuments().Add();
+ // msWord.openDocument(currentWorkingDir + "jnatest.doc", true);
+ msWord.getSelection()
+ .TypeText(
+ "Hello from JNA! \n Please notice that JNA can control MS Word via the new COM interface! \nHere we are creating a new word document and we save it to the 'TEMP' directory!");
+ // save with no user prompt
+ msWord.getActiveDocument().SaveAs(tempDir+"\\jnatestNewDoc1.docx", WdSaveFormat.wdFormatDocumentDefault);
+ msWord.getActiveDocument().SaveAs(tempDir+"\\jnatestNewDoc2.docx", WdSaveFormat.wdFormatDocumentDefault);
+ msWord.getActiveDocument().SaveAs(tempDir+"\\jnatestNewDoc3.docx", WdSaveFormat.wdFormatDocumentDefault);
+ // close and save the document
+ msWord.getActiveDocument().Close(false);
+ // open 3 documents
+ msWord.getDocuments().Open(tempDir+"\\jnatestNewDoc1.docx");
+ msWord.getSelection().TypeText("Hello some changes from JNA!\n");
+ msWord.getDocuments().Open(tempDir+"\\jnatestNewDoc2.docx");
+ msWord.getSelection().TypeText("Hello some changes from JNA!\n");
+ msWord.getDocuments().Open(tempDir+"\\jnatestNewDoc3.docx");
+ msWord.getSelection().TypeText("Hello some changes from JNA!\n");
+ // save the document and prompt the user
+ msWord.getDocuments().Save(false, WdOriginalFormat.wdPromptUser);
+ // wait then close word
+ msWord.Quit();
+ msWord = null;
+ } 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();
+ } finally {
+ if (msWord != null) {
+ msWord.Quit();
+ }
+ if (null != factory) {
+ factory.getComThread().terminate(500);
+ }
+ }
+ }
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComExcel_Application.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComExcel_Application.java
new file mode 100644
index 0000000000..07cc479b48
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComExcel_Application.java
@@ -0,0 +1,10 @@
+package com.sun.jna.platform.win32.COM.util.office.excel;
+
+import com.sun.jna.platform.win32.COM.util.IUnknown;
+import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
+import com.sun.jna.platform.win32.COM.util.annotation.ComObject;
+
+@ComObject(progId="Excel.Application")
+public interface ComExcel_Application extends IUnknown {
+
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIAppEvents.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIAppEvents.java
new file mode 100644
index 0000000000..381abef705
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIAppEvents.java
@@ -0,0 +1,12 @@
+package com.sun.jna.platform.win32.COM.util.office.excel;
+
+import com.sun.jna.platform.win32.COM.util.annotation.ComEventCallback;
+import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
+
+@ComInterface(iid="{00024413-0000-0000-C000-000000000046}")
+public interface ComIAppEvents {
+
+ @ComEventCallback(dispid=1558)
+ public void SheetSelectionChange(ComIWorksheet sheet, ComIRange target);
+
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIApplication.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIApplication.java
new file mode 100644
index 0000000000..11f7cec543
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIApplication.java
@@ -0,0 +1,32 @@
+package com.sun.jna.platform.win32.COM.util.office.excel;
+
+import com.sun.jna.platform.win32.COM.util.IConnectionPoint;
+import com.sun.jna.platform.win32.COM.util.IUnknown;
+import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
+import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
+import com.sun.jna.platform.win32.COM.util.annotation.ComProperty;
+
+@ComInterface(iid="{000208D5-0000-0000-C000-000000000046}")
+public interface ComIApplication extends IUnknown, IConnectionPoint {
+
+ @ComProperty
+ String getVersion();
+
+ @ComProperty
+ boolean getVisible();
+
+ @ComProperty
+ void setVisible(boolean value);
+
+ @ComProperty
+ ComIWorkbooks getWorkbooks();
+
+ @ComProperty
+ ComIWorksheet getActiveSheet();
+
+ @ComProperty
+ ComIWorkbook getActiveWorkbook();
+
+ @ComMethod
+ void Quit();
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIRange.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIRange.java
new file mode 100644
index 0000000000..4d79f20f44
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIRange.java
@@ -0,0 +1,25 @@
+package com.sun.jna.platform.win32.COM.util.office.excel;
+
+import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
+import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
+import com.sun.jna.platform.win32.COM.util.annotation.ComProperty;
+
+@ComInterface(iid = "{00020846-0000-0000-C000-000000000046}")
+public interface ComIRange {
+
+ @ComProperty
+ ComIApplication getApplication();
+
+ @ComProperty
+ String getText();
+
+ @ComMethod
+ void Select();
+
+ @ComProperty
+ void setValue(String value);
+
+ @ComMethod
+ void Activate();
+
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIWorkbook.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIWorkbook.java
new file mode 100644
index 0000000000..375a684510
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIWorkbook.java
@@ -0,0 +1,13 @@
+package com.sun.jna.platform.win32.COM.util.office.excel;
+
+import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
+import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
+
+@ComInterface(iid="{0002096B-0000-0000-C000-000000000046}")
+public interface ComIWorkbook {
+
+ @ComMethod
+ void Close(boolean saveChanges);
+
+
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIWorkbooks.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIWorkbooks.java
new file mode 100644
index 0000000000..c9174c23c2
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIWorkbooks.java
@@ -0,0 +1,19 @@
+package com.sun.jna.platform.win32.COM.util.office.excel;
+
+import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
+import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
+import com.sun.jna.platform.win32.COM.util.annotation.ComProperty;
+
+@ComInterface(iid = "{000208DB-0000-0000-C000-000000000046}")
+public interface ComIWorkbooks {
+
+ @ComProperty
+ long getCount();
+
+ @ComMethod
+ ComIWorkbook Item(long index);
+
+ @ComMethod
+ ComIWorkbook Open(Object FileName);
+
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIWorksheet.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIWorksheet.java
new file mode 100644
index 0000000000..2687f80d27
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/excel/ComIWorksheet.java
@@ -0,0 +1,19 @@
+package com.sun.jna.platform.win32.COM.util.office.excel;
+
+import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
+import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
+import com.sun.jna.platform.win32.COM.util.annotation.ComProperty;
+
+@ComInterface(iid="{000208D8-0000-0000-C000-000000000046}")
+public interface ComIWorksheet {
+
+ @ComProperty
+ String getName();
+
+ @ComProperty
+ ComIRange getRange(String cell1);
+
+ @ComProperty
+ ComIApplication getApplication();
+
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComIApplication.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComIApplication.java
new file mode 100644
index 0000000000..10a18b21e8
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComIApplication.java
@@ -0,0 +1,43 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.util.office.word;
+
+import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
+import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
+import com.sun.jna.platform.win32.COM.util.annotation.ComProperty;
+
+@ComInterface(iid="{00020970-0000-0000-C000-000000000046}")
+public interface ComIApplication {
+
+ @ComProperty
+ String getVersion();
+
+ @ComProperty
+ boolean getVisible();
+
+ @ComProperty
+ void setVisible(boolean value);
+
+ @ComProperty
+ ComIDocuments getDocuments();
+
+ @ComProperty
+ ComISelection getSelection();
+
+ @ComProperty
+ ComIDocument getActiveDocument();
+
+ @ComMethod
+ void Quit();
+
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComIDocument.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComIDocument.java
new file mode 100644
index 0000000000..e370130b8e
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComIDocument.java
@@ -0,0 +1,25 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.util.office.word;
+
+import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
+
+public interface ComIDocument {
+
+ @ComMethod
+ void SaveAs(String string, WdSaveFormat wdFormatDocument);
+
+ @ComMethod
+ void Close(boolean saveChanges);
+
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComIDocuments.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComIDocuments.java
new file mode 100644
index 0000000000..2096de5af5
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComIDocuments.java
@@ -0,0 +1,28 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.util.office.word;
+
+import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
+
+public interface ComIDocuments {
+
+ @ComMethod
+ ComIDocument Open(String fileName);
+
+ @ComMethod
+ ComIDocument Add();
+
+ @ComMethod
+ void Save(boolean noPrompt, WdOriginalFormat originalFormat);
+
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComISelection.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComISelection.java
new file mode 100644
index 0000000000..53d59b4f90
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComISelection.java
@@ -0,0 +1,24 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.util.office.word;
+
+import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
+import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
+
+@ComInterface
+public interface ComISelection {
+
+ @ComMethod
+ void TypeText(String text);
+
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComWord_Application.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComWord_Application.java
new file mode 100644
index 0000000000..af7a26e2d9
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/ComWord_Application.java
@@ -0,0 +1,21 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.util.office.word;
+
+import com.sun.jna.platform.win32.COM.util.IUnknown;
+import com.sun.jna.platform.win32.COM.util.annotation.ComObject;
+
+@ComObject(progId="Word.Application")
+public interface ComWord_Application extends IUnknown {
+
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/WdOriginalFormat.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/WdOriginalFormat.java
new file mode 100644
index 0000000000..b7f4bbee46
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/WdOriginalFormat.java
@@ -0,0 +1,29 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.util.office.word;
+
+import com.sun.jna.platform.win32.COM.util.IComEnum;
+
+public enum WdOriginalFormat implements IComEnum {
+ wdOriginalDocumentFormat(1), // Original document format.
+ wdPromptUser(2), // Prompt user to select a document format.
+ wdWordDocument(0); // Microsoft Word document format.
+
+ private WdOriginalFormat(long value) {
+ this.value = value;
+ }
+ private long value;
+ public long getValue() {
+ return this.value;
+ }
+}
diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/WdSaveFormat.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/WdSaveFormat.java
new file mode 100644
index 0000000000..7b7fce9fb1
--- /dev/null
+++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/util/office/word/WdSaveFormat.java
@@ -0,0 +1,54 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.util.office.word;
+
+import com.sun.jna.platform.win32.COM.util.IComEnum;
+
+public enum WdSaveFormat implements IComEnum {
+ wdFormatDocument(0), // Microsoft Office Word 97 - 2003 binary file format.
+ wdFormatDOSText(4), // Microsoft DOS text format.
+ wdFormatDOSTextLineBreaks(5), // Microsoft DOS text with line breaks preserved.
+ wdFormatEncodedText(7), // Encoded text format.
+ wdFormatFilteredHTML(10), // Filtered HTML format.
+ wdFormatFlatXML(19), // Open XML file format saved as a single XML file.
+ wdFormatFlatXMLMacroEnabled(20), // Open XML file format with macros enabled saved as a single XML file.
+ wdFormatFlatXMLTemplate(21), // Open XML template format saved as a XML single file.
+ wdFormatFlatXMLTemplateMacroEnabled(22), // Open XML template format with macros enabled saved as a single XML file.
+ wdFormatOpenDocumentText(23), // OpenDocument Text format.
+ wdFormatHTML(8), // Standard HTML format.
+ wdFormatRTF(6), // Rich text format (RTF).
+ wdFormatStrictOpenXMLDocument(24), // Strict Open XML document format.
+ wdFormatTemplate(1), // Word template format.
+ wdFormatText(2), // Microsoft Windows text format.
+ wdFormatTextLineBreaks(3), //Windows text format with line breaks preserved.
+ wdFormatUnicodeText( 7), //Unicode text format.
+ wdFormatWebArchive(9), //Web archive format.
+ wdFormatXML(11), //Extensible Markup Language (XML) format.
+ wdFormatDocument97( 0), // Microsoft Word 97 document format.
+ wdFormatDocumentDefault(16), // Word default document file format. For Word 2010, this is the DOCX format.
+ wdFormatPDF( 17), //PDF format.
+ wdFormatTemplate97( 1), // Word 97 template format.
+ wdFormatXMLDocument( 12), //XML document format.
+ wdFormatXMLDocumentMacroEnabled(13), //XML document format with macros enabled.
+ wdFormatXMLTemplate(14), //XML template format.
+ wdFormatXMLTemplateMacroEnabled(15), //XML template format with macros enabled.
+ wdFormatXPS(18);
+
+ private WdSaveFormat(long value) {
+ this.value = value;
+ }
+ private long value;
+ public long getValue() {
+ return this.value;
+ }
+}
diff --git a/contrib/platform/.classpath b/contrib/platform/.classpath
index 91a28a2ee6..77917d7b3f 100644
--- a/contrib/platform/.classpath
+++ b/contrib/platform/.classpath
@@ -2,9 +2,8 @@
-
-
-
+
+
diff --git a/contrib/platform/.project b/contrib/platform/.project
index eb21a1889c..2cad830e2f 100644
--- a/contrib/platform/.project
+++ b/contrib/platform/.project
@@ -1,6 +1,6 @@
- platform
+ com.sun.jna.platform
diff --git a/contrib/platform/.settings/org.eclipse.jdt.core.prefs b/contrib/platform/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..54e493c07c
--- /dev/null
+++ b/contrib/platform/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+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.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMBindingBaseObject.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMBindingBaseObject.java
index eddbbd48f8..35237c1182 100644
--- a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMBindingBaseObject.java
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMBindingBaseObject.java
@@ -15,6 +15,7 @@
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.Guid.REFIID;
import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.OaIdl;
import com.sun.jna.platform.win32.OaIdl.DISPID;
@@ -26,6 +27,7 @@
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;
import com.sun.jna.platform.win32.WinDef.LCID;
import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.platform.win32.WinNT.HRESULT;
@@ -85,7 +87,7 @@ public COMBindingBaseObject(CLSID clsid, boolean useActiveInstance,
if (COMUtils.SUCCEEDED(hr)) {
this.iUnknown = new Unknown(this.pUnknown.getValue());
- hr = iUnknown.QueryInterface(IDispatch.IID_IDISPATCH,
+ hr = iUnknown.QueryInterface(new REFIID.ByValue( IDispatch.IID_IDISPATCH),
this.pDispatch);
} else {
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null, dwClsContext,
@@ -130,7 +132,7 @@ public COMBindingBaseObject(String progId, boolean useActiveInstance,
if (COMUtils.SUCCEEDED(hr)) {
this.iUnknown = new Unknown(this.pUnknown.getValue());
- hr = iUnknown.QueryInterface(IDispatch.IID_IDISPATCH,
+ hr = iUnknown.QueryInterface(new REFIID.ByValue(IDispatch.IID_IDISPATCH),
this.pDispatch);
} else {
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null, dwClsContext,
@@ -212,7 +214,7 @@ protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
DISPIDByReference pdispID = new DISPIDByReference();
// Get DISPID for name passed...
- HRESULT hr = pDisp.GetIDsOfNames(Guid.IID_NULL, ptName, 1,
+ HRESULT hr = pDisp.GetIDsOfNames(new REFIID.ByValue(Guid.IID_NULL), ptName, 1,
LOCALE_USER_DEFAULT, pdispID);
COMUtils.checkRC(hr);
@@ -231,7 +233,7 @@ protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
// variable declaration
int _argsLen = 0;
VARIANT[] _args = null;
- DISPPARAMS dp = new DISPPARAMS();
+ DISPPARAMS.ByReference dp = new DISPPARAMS.ByReference();
EXCEPINFO.ByReference pExcepInfo = new EXCEPINFO.ByReference();
IntByReference puArgErr = new IntByReference();
@@ -264,8 +266,8 @@ protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
}
// Make the call!
- HRESULT hr = pDisp.Invoke(dispId, Guid.IID_NULL, LOCALE_SYSTEM_DEFAULT,
- new DISPID(nType), dp, pvResult, pExcepInfo, puArgErr);
+ HRESULT hr = pDisp.Invoke(dispId, new REFIID.ByValue(Guid.IID_NULL), LOCALE_SYSTEM_DEFAULT,
+ new WinDef.WORD(nType), dp, pvResult, pExcepInfo, puArgErr);
COMUtils.checkRC(hr, pExcepInfo, puArgErr);
return hr;
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMEarlyBindingObject.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMEarlyBindingObject.java
index 07220e0d4a..34a23b50e8 100644
--- a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMEarlyBindingObject.java
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMEarlyBindingObject.java
@@ -15,6 +15,7 @@
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.Guid.REFIID;
import com.sun.jna.platform.win32.OaIdl.DISPID;
import com.sun.jna.platform.win32.OaIdl.DISPIDByReference;
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
@@ -25,6 +26,7 @@
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.WinDef.WORD;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
@@ -57,7 +59,7 @@ protected void setProperty(DISPID dispId, boolean value) {
}
@Override
- public HRESULT QueryInterface(IID riid, PointerByReference ppvObject) {
+ public HRESULT QueryInterface(REFIID.ByValue riid, PointerByReference ppvObject) {
return this.getIDispatch().QueryInterface(riid, ppvObject);
}
@@ -83,16 +85,16 @@ public HRESULT GetTypeInfo(UINT iTInfo, LCID lcid,
}
@Override
- public HRESULT GetIDsOfNames(IID riid, WString[] rgszNames, int cNames,
+ public HRESULT GetIDsOfNames(REFIID.ByValue 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,
+ public HRESULT Invoke(DISPID dispIdMember, REFIID.ByValue riid, LCID lcid,
+ WORD wFlags, DISPPARAMS.ByReference pDispParams,
+ VARIANT.ByReference pVarResult, EXCEPINFO.ByReference pExcepInfo,
IntByReference puArgErr) {
return this.getIDispatch().Invoke(dispIdMember, riid, lcid, wFlags,
pDispParams, pVarResult, pExcepInfo, puArgErr);
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMException.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMException.java
index eefc7d6c26..8431a63733 100644
--- a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMException.java
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMException.java
@@ -72,7 +72,7 @@ public COMException(String message) {
*/
public COMException(String message, EXCEPINFO pExcepInfo,
IntByReference puArgErr) {
- super(message + " (puArgErr=" + puArgErr.getValue() + ")");
+ super(message + " (puArgErr=" + (null==puArgErr?"":puArgErr.getValue()) + ")");
this.pExcepInfo = pExcepInfo;
this.puArgErr = puArgErr;
}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/ConnectionPoint.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/ConnectionPoint.java
new file mode 100644
index 0000000000..fb5132f134
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/ConnectionPoint.java
@@ -0,0 +1,56 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.platform.win32.Guid.IID;
+import com.sun.jna.platform.win32.WinDef.DWORD;
+import com.sun.jna.platform.win32.WinDef.DWORDByReference;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
+
+public class ConnectionPoint extends Unknown implements IConnectionPoint {
+
+ public ConnectionPoint(Pointer pointer) {
+ super(pointer);
+ }
+
+ @Override
+ public HRESULT GetConnectionInterface(IID iid) {
+ final int vTableId = 3;
+ return (HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(), iid }, HRESULT.class);
+ }
+
+ void GetConnectionPointContainer() {
+ final int vTableId = 4;
+
+ }
+
+ @Override
+ public HRESULT Advise(IUnknownCallback pUnkSink, DWORDByReference pdwCookie) {
+ final int vTableId = 5;
+
+ return (HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(), pUnkSink.getPointer(),
+ pdwCookie }, HRESULT.class);
+ }
+
+ @Override
+ public HRESULT Unadvise(DWORD dwCookie) {
+ final int vTableId = 6;
+
+ return (HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(), dwCookie }, HRESULT.class);
+ }
+
+ void EnumConnections() {
+ final int vTableId = 7;
+ }
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/ConnectionPointContainer.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/ConnectionPointContainer.java
new file mode 100644
index 0000000000..481905c1fb
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/ConnectionPointContainer.java
@@ -0,0 +1,50 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.platform.win32.Guid.REFIID;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
+import com.sun.jna.ptr.PointerByReference;
+
+public class ConnectionPointContainer extends Unknown implements
+ IConnectionPointContainer {
+
+ public ConnectionPointContainer(Pointer pointer) {
+ super(pointer);
+ }
+
+ public HRESULT EnumConnectionPoints() {
+ // I think the magic number here is worked out by counting the number of
+ // methods in the full interface, as this inherits IUnknown, which
+ // has 3 methods, we start here at 3 (0 indexed).
+ final int vTableId = 3;
+
+
+// return (HRESULT) this._invokeNativeObject(3,
+// new Object[] { this.getPointer(), riid, ppCP }, HRESULT.class);
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public HRESULT FindConnectionPoint(REFIID riid, PointerByReference ppCP) {
+ // I think the magic number here is worked out by counting the number of
+ // methods in the full interface,
+ // this as this inherits IUnknown, which has 3 methods, we have here 4.
+ // second in this class
+ final int vTableId = 4;
+ return (HRESULT) this._invokeNativeObject(vTableId,
+ new Object[] { this.getPointer(), riid, ppCP }, HRESULT.class);
+ }
+
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/Dispatch.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/Dispatch.java
index 71fd3d546f..c5f6577c42 100644
--- a/contrib/platform/src/com/sun/jna/platform/win32/COM/Dispatch.java
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/Dispatch.java
@@ -16,6 +16,7 @@
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.IID;
+import com.sun.jna.platform.win32.Guid.REFIID;
import com.sun.jna.platform.win32.OaIdl.DISPID;
import com.sun.jna.platform.win32.OaIdl.DISPIDByReference;
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
@@ -24,6 +25,7 @@
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.WinDef.WORD;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
@@ -97,7 +99,7 @@ public HRESULT GetTypeInfo(UINT iTInfo, LCID lcid,
* the rg disp id
* @return the hresult
*/
- public HRESULT GetIDsOfNames(IID riid, WString[] rgszNames, int cNames,
+ public HRESULT GetIDsOfNames(REFIID.ByValue riid, WString[] rgszNames, int cNames,
LCID lcid, DISPIDByReference rgDispId) {
return (HRESULT) this._invokeNativeObject(5,
new Object[] { this.getPointer(), riid, rgszNames, cNames,
@@ -125,8 +127,8 @@ public HRESULT GetIDsOfNames(IID riid, WString[] rgszNames, int cNames,
* the pu arg err
* @return the hresult
*/
- public HRESULT Invoke(DISPID dispIdMember, IID riid, LCID lcid,
- DISPID wFlags, DISPPARAMS pDispParams,
+ public HRESULT Invoke(DISPID dispIdMember, REFIID.ByValue riid, LCID lcid,
+ WORD wFlags, DISPPARAMS.ByReference pDispParams,
VARIANT.ByReference pVarResult, EXCEPINFO.ByReference pExcepInfo,
IntByReference puArgErr) {
return (HRESULT) this
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchListener.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchListener.java
new file mode 100644
index 0000000000..0043ab114f
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchListener.java
@@ -0,0 +1,104 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.Arrays;
+import java.util.List;
+
+import com.sun.jna.CallbackThreadInitializer;
+import com.sun.jna.Native;
+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.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.WinDef.WORD;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
+import com.sun.jna.ptr.IntByReference;
+import com.sun.jna.ptr.PointerByReference;
+
+public class DispatchListener extends Structure {
+ public DispatchListener(IDispatchCallback callback) {
+ this.vtbl = this.constructVTable();
+ this.initVTable(callback);
+ super.write();
+ }
+ public DispatchVTable.ByReference vtbl;
+
+ @Override
+ protected List getFieldOrder() {
+ return Arrays.asList(new String[] { "vtbl" });
+ }
+
+ protected DispatchVTable.ByReference constructVTable() {
+ return new DispatchVTable.ByReference();
+ }
+
+ protected void initVTable(final IDispatchCallback callback) {
+ this.vtbl.QueryInterfaceCallback = new DispatchVTable.QueryInterfaceCallback() {
+ @Override
+ public HRESULT invoke(Pointer thisPointer, REFIID.ByValue refid, PointerByReference ppvObject) {
+ return callback.QueryInterface(refid, ppvObject);
+ }
+ };
+ this.vtbl.AddRefCallback = new DispatchVTable.AddRefCallback() {
+ @Override
+ public int invoke(Pointer thisPointer) {
+ return callback.AddRef();
+ }
+ };
+ this.vtbl.ReleaseCallback = new DispatchVTable.ReleaseCallback() {
+ @Override
+ public int invoke(Pointer thisPointer) {
+ return callback.Release();
+ }
+ };
+ this.vtbl.GetTypeInfoCountCallback = new DispatchVTable.GetTypeInfoCountCallback() {
+ @Override
+ public HRESULT invoke(Pointer thisPointer, UINTByReference pctinfo) {
+ return callback.GetTypeInfoCount(pctinfo);
+ }
+ };
+ this.vtbl.GetTypeInfoCallback = new DispatchVTable.GetTypeInfoCallback() {
+ @Override
+ public HRESULT invoke(Pointer thisPointer, UINT iTInfo, LCID lcid, PointerByReference ppTInfo) {
+ return callback.GetTypeInfo(iTInfo, lcid, ppTInfo);
+ }
+ };
+ this.vtbl.GetIDsOfNamesCallback = new DispatchVTable.GetIDsOfNamesCallback() {
+ @Override
+ public HRESULT invoke(Pointer thisPointer, REFIID.ByValue riid, WString[] rgszNames, int cNames, LCID lcid,
+ DISPIDByReference rgDispId) {
+ return callback.GetIDsOfNames(riid, rgszNames, cNames, lcid, rgDispId);
+ }
+ };
+ this.vtbl.InvokeCallback = new DispatchVTable.InvokeCallback() {
+ @Override
+ public HRESULT invoke(Pointer thisPointer, DISPID dispIdMember, REFIID.ByValue riid, LCID lcid, WORD wFlags,
+ DISPPARAMS.ByReference pDispParams, VARIANT.ByReference pVarResult, EXCEPINFO.ByReference pExcepInfo,
+ IntByReference puArgErr) {
+
+ return callback.Invoke(dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
+ }
+ };
+
+ }
+
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchVTable.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchVTable.java
new file mode 100644
index 0000000000..16fb47fd51
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchVTable.java
@@ -0,0 +1,89 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), All Rights Reserved
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+package com.sun.jna.platform.win32.COM;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.sun.jna.Pointer;
+import com.sun.jna.Structure;
+import com.sun.jna.WString;
+import com.sun.jna.platform.win32.COM.UnknownVTable.AddRefCallback;
+import com.sun.jna.platform.win32.COM.UnknownVTable.QueryInterfaceCallback;
+import com.sun.jna.platform.win32.COM.UnknownVTable.ReleaseCallback;
+import com.sun.jna.platform.win32.Guid.REFIID;
+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.WinDef.WORD;
+import com.sun.jna.platform.win32.WinNT;
+import com.sun.jna.ptr.IntByReference;
+import com.sun.jna.ptr.PointerByReference;
+import com.sun.jna.win32.DLLCallback;
+import com.sun.jna.win32.StdCallLibrary;
+
+public class DispatchVTable extends Structure {
+ public static class ByReference extends DispatchVTable implements Structure.ByReference {
+ }
+
+ public QueryInterfaceCallback QueryInterfaceCallback;
+ public AddRefCallback AddRefCallback;
+ public ReleaseCallback ReleaseCallback;
+ public GetTypeInfoCountCallback GetTypeInfoCountCallback;
+ public GetTypeInfoCallback GetTypeInfoCallback;
+ public GetIDsOfNamesCallback GetIDsOfNamesCallback;
+ public InvokeCallback InvokeCallback;
+
+ @Override
+ protected List getFieldOrder() {
+ return Arrays.asList(new String[] { "QueryInterfaceCallback", "AddRefCallback", "ReleaseCallback","GetTypeInfoCountCallback", "GetTypeInfoCallback",
+ "GetIDsOfNamesCallback", "InvokeCallback" });
+ }
+
+ public static interface QueryInterfaceCallback extends StdCallLibrary.StdCallCallback {
+ WinNT.HRESULT invoke(Pointer thisPointer, REFIID.ByValue refid, PointerByReference ppvObject);
+ }
+
+ public static interface AddRefCallback extends StdCallLibrary.StdCallCallback {
+ int invoke(Pointer thisPointer);
+ }
+
+ public static interface ReleaseCallback extends StdCallLibrary.StdCallCallback {
+ int invoke(Pointer thisPointer);
+ }
+
+ public static interface GetTypeInfoCountCallback extends StdCallLibrary.StdCallCallback {
+ WinNT.HRESULT invoke(Pointer thisPointer, UINTByReference pctinfo);
+ }
+
+ public static interface GetTypeInfoCallback extends StdCallLibrary.StdCallCallback {
+ WinNT.HRESULT invoke(Pointer thisPointer, UINT iTInfo, LCID lcid, PointerByReference ppTInfo);
+ }
+
+ public static interface GetIDsOfNamesCallback extends StdCallLibrary.StdCallCallback {
+ WinNT.HRESULT invoke(Pointer thisPointer, REFIID.ByValue riid, WString[] rgszNames, int cNames, LCID lcid,
+ DISPIDByReference rgDispId);
+ }
+
+ public static interface InvokeCallback extends StdCallLibrary.StdCallCallback {
+ WinNT.HRESULT invoke(Pointer thisPointer, DISPID dispIdMember, REFIID.ByValue riid, LCID lcid, WORD wFlags,
+ DISPPARAMS.ByReference pDispParams, VARIANT.ByReference pVarResult, EXCEPINFO.ByReference pExcepInfo,
+ IntByReference puArgErr);
+ }
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/EnumMoniker.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/EnumMoniker.java
new file mode 100644
index 0000000000..38127674ea
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/EnumMoniker.java
@@ -0,0 +1,71 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.platform.win32.WinNT;
+import com.sun.jna.platform.win32.WinDef.ULONG;
+import com.sun.jna.platform.win32.WinDef.ULONGByReference;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
+import com.sun.jna.ptr.PointerByReference;
+
+public class EnumMoniker extends Unknown implements IEnumMoniker {
+
+ public EnumMoniker(Pointer pointer) {
+ super(pointer);
+ }
+
+ // The magic number values for (vTableId) below, are worked out by
+ // counting the number of methods in the full interface (0 indexed), as this
+ // inherits IUnknown, which has 3 methods, we start here at 3.
+
+ @Override
+ public HRESULT Next(ULONG celt, PointerByReference rgelt, ULONGByReference pceltFetched) {
+ final int vTableId = 3;
+
+ WinNT.HRESULT hr = (WinNT.HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(), celt,
+ rgelt, pceltFetched }, WinNT.HRESULT.class);
+
+ return hr;
+ }
+
+ @Override
+ public HRESULT Skip(ULONG celt) {
+ final int vTableId = 4;
+
+ WinNT.HRESULT hr = (WinNT.HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(), celt },
+ WinNT.HRESULT.class);
+
+ return hr;
+ }
+
+ @Override
+ public HRESULT Reset() {
+ final int vTableId = 5;
+
+ WinNT.HRESULT hr = (WinNT.HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(), },
+ WinNT.HRESULT.class);
+
+ return hr;
+ }
+
+ @Override
+ public HRESULT Clone(PointerByReference ppenum) {
+ final int vTableId = 6;
+
+ WinNT.HRESULT hr = (WinNT.HRESULT) this._invokeNativeObject(vTableId,
+ new Object[] { this.getPointer(), ppenum }, WinNT.HRESULT.class);
+
+ return hr;
+ }
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IConnectionPoint.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IConnectionPoint.java
new file mode 100644
index 0000000000..643f741794
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IConnectionPoint.java
@@ -0,0 +1,66 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), All Rights Reserved
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+package com.sun.jna.platform.win32.COM;
+
+import com.sun.jna.platform.win32.Guid.IID;
+import com.sun.jna.platform.win32.WinDef.DWORD;
+import com.sun.jna.platform.win32.WinDef.DWORDByReference;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
+import com.sun.jna.platform.win32.WinNT;
+
+public interface IConnectionPoint extends IUnknown {
+ final static IID IID_IConnectionPoint = new IID(
+ "B196B286-BAB4-101A-B69C-00AA00341D07");
+
+ /**
+ *
+ *
+ * @param iid
+ * @return
+ */
+ HRESULT GetConnectionInterface(IID iid);
+
+ /**
+ *
+ * When Advise is called, the called COM object will callback 'QueryInterface' asking for a number of
+ * different interfaces, for example:
+ * - {00000003-0000-0000-C000-000000000046} - IMarshal
+ * - {00000003-0000-0000-C000-000000000046}
+ * - {0000001B-0000-0000-C000-000000000046} - IdentityUnmarshal
+ * - {00000000-0000-0000-C000-000000000046} - IUnknown
+ * - {00000018-0000-0000-C000-000000000046} - IStdMarshalInfo
+ * - {00000019-0000-0000-C000-000000000046} - IExternalConnection
+ * - {4C1E39E1-E3E3-4296-AA86-EC938D896E92} - (some unknown private interface)
+ * - interface of this ConnectionPoint
+ *
+ *
+ * {@code
+ * HRESULT Advise(
+ * [in] IUnknown *pUnkSink,
+ * [out] DWORD *pdwCookie
+ * );
+ * }
+ *
+ * @param pUnkSink
+ * @param pdwCookie
+ * @return
+ */
+ WinNT.HRESULT Advise(IUnknownCallback pUnkSink, DWORDByReference pdwCookie);
+
+ /**
+ *
+ * @param dwCookie
+ * @return
+ */
+ HRESULT Unadvise(DWORD dwCookie);
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IConnectionPointContainer.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IConnectionPointContainer.java
new file mode 100644
index 0000000000..e0e354002d
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IConnectionPointContainer.java
@@ -0,0 +1,35 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), All Rights Reserved
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+package com.sun.jna.platform.win32.COM;
+
+import com.sun.jna.platform.win32.Guid.IID;
+import com.sun.jna.platform.win32.Guid.REFIID;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
+import com.sun.jna.ptr.PointerByReference;
+
+public interface IConnectionPointContainer extends IUnknown {
+ public final static IID IID_IConnectionPointContainer = new IID("B196B284-BAB4-101A-B69C-00AA00341D07");
+
+ /**
+ * @code{
+ * HRESULT FindConnectionPoint(
+ * [in] REFIID riid,
+ * [out] IConnectionPoint **ppCP
+ * );
+ * }
+ * @param riid
+ * @param ppCP
+ * @return
+ */
+ public HRESULT FindConnectionPoint( REFIID riid, PointerByReference ppCP );
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IDispatch.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IDispatch.java
index 8906ab543e..e4904cb983 100644
--- a/contrib/platform/src/com/sun/jna/platform/win32/COM/IDispatch.java
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IDispatch.java
@@ -14,6 +14,7 @@
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.IID;
+import com.sun.jna.platform.win32.Guid.REFIID;
import com.sun.jna.platform.win32.OaIdl.DISPID;
import com.sun.jna.platform.win32.OaIdl.DISPIDByReference;
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
@@ -22,6 +23,7 @@
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.WinDef.WORD;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
@@ -45,11 +47,11 @@ public interface IDispatch extends IUnknown {
public HRESULT GetTypeInfo(UINT iTInfo, LCID lcid,
PointerByReference ppTInfo);
- public HRESULT GetIDsOfNames(IID riid, WString[] rgszNames, int cNames,
+ public HRESULT GetIDsOfNames(REFIID.ByValue riid, WString[] rgszNames, int cNames,
LCID lcid, DISPIDByReference rgDispId);
- public HRESULT Invoke(DISPID dispIdMember, IID riid, LCID lcid,
- DISPID wFlags, DISPPARAMS pDispParams,
+ public HRESULT Invoke(DISPID dispIdMember, REFIID.ByValue riid, LCID lcid,
+ WORD wFlags, DISPPARAMS.ByReference pDispParams,
VARIANT.ByReference pVarResult, EXCEPINFO.ByReference pExcepInfo,
IntByReference puArgErr);
}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IDispatchCallback.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IDispatchCallback.java
new file mode 100644
index 0000000000..2140cfd295
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IDispatchCallback.java
@@ -0,0 +1,18 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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;
+
+
+public interface IDispatchCallback extends IDispatch, IUnknownCallback {
+
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IEnumMoniker.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IEnumMoniker.java
new file mode 100644
index 0000000000..b3f3618f99
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IEnumMoniker.java
@@ -0,0 +1,94 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.ptr.PointerByReference;
+import com.sun.jna.platform.win32.Guid.IID;
+import com.sun.jna.platform.win32.WinDef.ULONG;
+import com.sun.jna.platform.win32.WinDef.ULONGByReference;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
+
+/**
+ * Enumerates the components of a moniker or the monikers in a table of monikers.
+ *
+ * @see MSDN
+ *
+ */
+public interface IEnumMoniker extends IUnknown {
+
+ public final static IID IID = new IID("{00000102-0000-0000-C000-000000000046}");
+
+ /**
+ * Creates a new enumerator that contains the same enumeration state as the
+ * current one.
+ *
+ * This method makes it possible to record a particular point in the
+ * enumeration sequence and then return to that point at a later time. The
+ * caller must release this new enumerator separately from the first
+ * enumerator.
+ *
+ * {@code
+ * HRESULT Clone(
+ * [out] IEnumMoniker **ppenum
+ * );
+ * }
+ *
+ * @see MSDN
+ */
+ HRESULT Clone(PointerByReference ppenum);
+
+ /**
+ * Retrieves the specified number of items in the enumeration sequence.
+ *
+ * Note: The caller is responsible for calling Release through each pointer
+ * enumerated.
+ *
+ * {@code
+ * HRESULT Next(
+ * [in] ULONG celt,
+ * [out] IMoniker **rgelt,
+ * [in, out] ULONG *pceltFetched
+ * );
+ * }
+ *
+ * @see MSDN
+ *
+ */
+ HRESULT Next(ULONG celt, PointerByReference rgelt, ULONGByReference pceltFetched);
+
+ /**
+ * Resets the enumeration sequence to the beginning.
+ *
+ * {@code
+ * HRESULT Reset();
+ * }
+ *
+ * @see MSDN
+ *
+ */
+ HRESULT Reset();
+
+ /**
+ * Skips over the specified number of items in the enumeration sequence.
+ *
+ * {@code
+ * HRESULT Skip(
+ * [in] ULONG celt
+ * );
+ * }
+ *
+ * @see MSDN
+ *
+ */
+ HRESULT Skip(ULONG celt);
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IMoniker.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IMoniker.java
new file mode 100644
index 0000000000..7535089a1d
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IMoniker.java
@@ -0,0 +1,94 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.platform.win32.WTypes.BSTRByReference;
+import com.sun.jna.platform.win32.WTypes.LPSTR;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
+
+
+/**
+ * Enables you to use a moniker object, which contains information that uniquely
+ * identifies a COM object.
+ *
+ * (Unimplemented, placeholder only at present)
+ *
+ * @see MSDN
+ *
+ */
+public interface IMoniker extends IPersistStream {
+
+ /**
+ * Binds to the specified object. The binding process involves finding the
+ * object, putting it into the running state if necessary, and providing the
+ * caller with a pointer to a specified interface on the identified object.
+ *
+ * {@code
+ * HRESULT BindToObject(
+ * [in] IBindCtx *pbc,
+ * [in] IMoniker *pmkToLeft,
+ * [in] REFIID riidResult,
+ * [out] void **ppvResult
+ * );
+ * }
+ *
+ * @see MSDN
+ */
+ void BindToObject();
+
+ void BindToStorage();
+
+ void Reduce();
+
+ void ComposeWith();
+
+ void Enum();
+
+ void IsEqual();
+
+ void Hash();
+
+ void IsRunning();
+
+ void GetTimeOfLastChange();
+
+ void Inverse();
+
+ void CommonPrefixWith();
+
+ /**
+ * Retrieves the display name for the moniker.
+ *
+ * {@code
+ * HRESULT GetDisplayName(
+ * [in] IBindCtx *pbc,
+ * [in] IMoniker *pmkToLeft,
+ * [out] LPOLESTR *ppszDisplayName
+ * );
+ *
+ * @see MSDN
+ *
+ * }
+ */
+ HRESULT GetDisplayName(Pointer pbc, Pointer pmkToLeft, BSTRByReference ppszDisplayName);
+
+ void ParseDisplayName();
+
+ void IsSystemMoniker();
+
+ void RelativePathTo();
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IPersist.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IPersist.java
new file mode 100644
index 0000000000..8b60559db5
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IPersist.java
@@ -0,0 +1,40 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.CLSID;
+
+/**
+ * Provides the CLSID of an object that can be stored persistently in the
+ * system. Allows the object to specify which object handler to use in the
+ * client process, as it is used in the default implementation of marshaling.
+ *
+ * @see MSDN
+ *
+ */
+public interface IPersist extends IUnknown {
+
+ /**
+ * Retrieves the class identifier (CLSID) of the object.
+ *
+ * {@code
+ * HRESULT GetClassID(
+ * [out] CLSID *pClassID
+ * );
+ * }
+ *
+ * MSDN
+ */
+ CLSID GetClassID();
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IPersistStream.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IPersistStream.java
new file mode 100644
index 0000000000..5604e373f5
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IPersistStream.java
@@ -0,0 +1,57 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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;
+
+
+/**
+ * Enables the saving and loading of objects that use a simple serial stream for their storage needs.
+ *
+ * @see MSDN
+ *
+ */
+public interface IPersistStream extends IPersist {
+
+ /**
+ * Determines whether an object has changed since it was last saved to its
+ * stream.
+ *
+ * (Unimplemented)
+ *
+ */
+ boolean IsDirty();
+
+ /**
+ * Initializes an object from the stream where it was saved previously
+ *
+ * (Unimplemented)
+ *
+ */
+
+ void Load(IStream stm);
+
+ /**
+ * Saves an object to the specified stream.
+ *
+ * (Unimplemented)
+ *
+ */
+ void Save(IStream stm);
+
+ /**
+ * Retrieves the size of the stream needed to save the object.
+ *
+ * (Unimplemented)
+ *
+ */
+ void GetSizeMax();
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IRunningObjectTable.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IRunningObjectTable.java
new file mode 100644
index 0000000000..9a5709a3e5
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IRunningObjectTable.java
@@ -0,0 +1,152 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.platform.win32.Guid.IID;
+import com.sun.jna.platform.win32.WinBase.FILETIME;
+import com.sun.jna.platform.win32.WinDef.DWORD;
+import com.sun.jna.platform.win32.WinDef.DWORDByReference;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
+import com.sun.jna.ptr.PointerByReference;
+
+/**
+ * Manages access to the running object table (ROT), a globally accessible
+ * look-up table on each workstation.
+ *
+ * @see MSDN
+ *
+ */
+public interface IRunningObjectTable extends IUnknown {
+
+ public final static IID IID = new IID("{00000010-0000-0000-C000-000000000046}");
+
+ /**
+ * Creates and returns a pointer to an enumerator that can list the monikers
+ * of all the objects currently registered in the running object table
+ * (ROT).
+ *
+ * {@code
+ * HRESULT EnumRunning(
+ * [out] IEnumMoniker **ppenumMoniker
+ * );
+ * }
+ *
+ * @see MSDN
+ *
+ */
+ HRESULT EnumRunning(PointerByReference ppenumMoniker);
+
+ /**
+ *
+ * Determines whether the object identified by the specified moniker is
+ * running, and if it is, retrieves a pointer to that object.
+ *
+ * {@code
+ * HRESULT GetObject(
+ * [in] IMoniker *pmkObjectName,
+ * [out] IUnknown **ppunkObject
+ * );
+ * }
+ *
+ * @see MSDN
+ *
+ */
+ HRESULT GetObject(Pointer pmkObjectName, PointerByReference ppunkObject);
+
+ /**
+ * Retrieves the time that an object was last modified.
+ *
+ * {@code
+ * HRESULT GetTimeOfLastChange(
+ * [in] IMoniker *pmkObjectName,
+ * [out] FILETIME *pfiletime
+ * );
+ * }
+ *
+ * @see MSDN
+ *
+ */
+ HRESULT GetTimeOfLastChange(Pointer pmkObjectName, FILETIME.ByReference pfiletime);
+
+ /**
+ * Determines whether the object identified by the specified moniker is
+ * currently running.
+ *
+ * {@code
+ * HRESULT IsRunning(
+ * [in] IMoniker *pmkObjectName
+ * );
+ * }
+ *
+ * @see MSDN
+ *
+ */
+ HRESULT IsRunning(Pointer pmkObjectName);
+
+ /**
+ * Records the time that a running object was last modified.
+ *
+ * {@code
+ * HRESULT NoteChangeTime(
+ * [in] DWORD dwRegister,
+ * [in] FILETIME *pfiletime
+ * );
+ * }
+ *
+ * @see MSDN
+ *
+ */
+ HRESULT NoteChangeTime(DWORD dwRegister, FILETIME pfiletime);
+
+ /**
+ * Registers an object and its identifying moniker in the running object
+ * table (ROT).
+ *
+ * {@code
+ * HRESULT Register(
+ * [in] DWORD grfFlags,
+ * [in] IUnknown *punkObject,
+ * [in] IMoniker *pmkObjectName,
+ * [out] DWORD *pdwRegister
+ * );
+ * }
+ *
+ * @see MSDN
+ *
+ */
+ HRESULT Register(DWORD grfFlags, Pointer punkObject, Pointer pmkObjectName, DWORDByReference pdwRegister);
+
+ /**
+ * Removes an entry from the running object table (ROT) that was previously
+ * registered by a call to IRunningObjectTable.Register.
+ *
+ * {@code
+ * HRESULT Revoke(
+ * [in] DWORD dwRegister
+ * );
+ * }
+ *
+ * @see MSDN
+ *
+ */
+ HRESULT Revoke(DWORD dwRegister);
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IStream.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IStream.java
new file mode 100644
index 0000000000..a7fa02570d
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IStream.java
@@ -0,0 +1,29 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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;
+
+/**
+ * The IStream interface lets you read and write data to stream objects. Stream
+ * objects contain the data in a structured storage object, where storages
+ * provide the structure. Simple data can be written directly to a stream but,
+ * most frequently, streams are elements nested within a storage object. They
+ * are similar to standard files.
+ *
+ * (Place holder, incomplete)
+ *
+ * @see MSDN
+ *
+ */
+public interface IStream {
+
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IUnknown.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IUnknown.java
index 073cbe0e60..061f6114e8 100644
--- a/contrib/platform/src/com/sun/jna/platform/win32/COM/IUnknown.java
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IUnknown.java
@@ -13,6 +13,7 @@
package com.sun.jna.platform.win32.COM;
import com.sun.jna.platform.win32.Guid.IID;
+import com.sun.jna.platform.win32.Guid.REFIID;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.PointerByReference;
@@ -31,7 +32,7 @@ public interface IUnknown {
public final static IID IID_IUNKNOWN = new IID(
"{00000000-0000-0000-C000-000000000046}");
- public HRESULT QueryInterface(IID riid, PointerByReference ppvObject);
+ public HRESULT QueryInterface(REFIID.ByValue riid, PointerByReference ppvObject);
public int AddRef();
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IUnknownCallback.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IUnknownCallback.java
new file mode 100644
index 0000000000..d1ae76c95f
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IUnknownCallback.java
@@ -0,0 +1,19 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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;
+
+public interface IUnknownCallback extends IUnknown {
+ Pointer getPointer();
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/Moniker.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/Moniker.java
new file mode 100644
index 0000000000..db695646d5
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/Moniker.java
@@ -0,0 +1,173 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.WTypes.BSTRByReference;
+import com.sun.jna.platform.win32.WTypes.LPSTR;
+import com.sun.jna.platform.win32.WinNT;
+import com.sun.jna.platform.win32.Guid.CLSID;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
+
+public class Moniker extends Unknown implements IMoniker {
+
+ public static class ByReference extends Moniker implements Structure.ByReference {
+ }
+
+ public Moniker() {
+ }
+
+ public Moniker(Pointer pointer) {
+ super(pointer);
+ }
+
+ // There are 8 virtual methods in the ancestors of this class/interfaces
+ static final int vTableIdStart = 7;
+
+ @Override
+ public void BindToObject() {
+ final int vTableId = vTableIdStart + 1;
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void BindToStorage() {
+ final int vTableId = vTableIdStart + 2;
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void Reduce() {
+ final int vTableId = vTableIdStart + 3;
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void ComposeWith() {
+ final int vTableId = vTableIdStart + 4;
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void Enum() {
+ final int vTableId = vTableIdStart + 5;
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void IsEqual() {
+ final int vTableId = vTableIdStart + 6;
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void Hash() {
+ final int vTableId = vTableIdStart + 7;
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void IsRunning() {
+ final int vTableId = vTableIdStart + 8;
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void GetTimeOfLastChange() {
+ final int vTableId = vTableIdStart + 9;
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void Inverse() {
+ final int vTableId = vTableIdStart + 10;
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void CommonPrefixWith() {
+ final int vTableId = vTableIdStart + 11;
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void RelativePathTo() {
+ final int vTableId = vTableIdStart + 12;
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public HRESULT GetDisplayName(Pointer pbc, Pointer pmkToLeft, BSTRByReference ppszDisplayName) {
+ final int vTableId = vTableIdStart + 13;
+
+ WinNT.HRESULT hr = (WinNT.HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(), pbc,
+ pmkToLeft, ppszDisplayName }, WinNT.HRESULT.class);
+
+ return hr;
+ }
+
+ @Override
+ public void ParseDisplayName() {
+ final int vTableId = vTableIdStart + 14;
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void IsSystemMoniker() {
+ final int vTableId = vTableIdStart + 15;
+
+ throw new UnsupportedOperationException();
+ }
+
+ // ------------------------ IPersistStream ----------------------------
+ @Override
+ public boolean IsDirty() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void Load(IStream stm) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void Save(IStream stm) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void GetSizeMax() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public CLSID GetClassID() {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/RunningObjectTable.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/RunningObjectTable.java
new file mode 100644
index 0000000000..e635c500d8
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/RunningObjectTable.java
@@ -0,0 +1,110 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.WinBase.FILETIME;
+import com.sun.jna.platform.win32.WinDef.DWORD;
+import com.sun.jna.platform.win32.WinDef.DWORDByReference;
+import com.sun.jna.platform.win32.WinNT;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
+import com.sun.jna.ptr.PointerByReference;
+
+public class RunningObjectTable extends Unknown implements IRunningObjectTable {
+
+ public static class ByReference extends RunningObjectTable implements Structure.ByReference {
+ }
+
+ public RunningObjectTable() {
+ }
+
+ public RunningObjectTable(Pointer pointer) {
+ super(pointer);
+ }
+
+ // The magic number values for (vTableId) below, are worked out by
+ // counting the number of methods in the full interface (0 indexed), as this
+ // inherits IUnknown, which has 3 methods, we start here at 3.
+
+ @Override
+ public HRESULT Register(DWORD grfFlags, Pointer punkObject, Pointer pmkObjectName, DWORDByReference pdwRegister) {
+ final int vTableId = 3;
+
+ WinNT.HRESULT hr = (WinNT.HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(),
+ grfFlags, punkObject, pmkObjectName, pdwRegister }, WinNT.HRESULT.class);
+
+ return hr;
+ }
+
+ @Override
+ public HRESULT Revoke(DWORD dwRegister) {
+ final int vTableId = 4;
+
+ WinNT.HRESULT hr = (WinNT.HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(),
+ dwRegister }, WinNT.HRESULT.class);
+
+ return hr;
+ }
+
+ @Override
+ public HRESULT IsRunning(Pointer pmkObjectName) {
+ final int vTableId = 5;
+
+ WinNT.HRESULT hr = (WinNT.HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(),
+ pmkObjectName }, WinNT.HRESULT.class);
+
+ return hr;
+ }
+
+ @Override
+ public HRESULT GetObject(Pointer pmkObjectName, PointerByReference ppunkObject) {
+ final int vTableId = 6;
+
+ WinNT.HRESULT hr = (WinNT.HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(),
+ pmkObjectName, ppunkObject }, WinNT.HRESULT.class);
+
+ return hr;
+ }
+
+ @Override
+ public HRESULT NoteChangeTime(DWORD dwRegister, FILETIME pfiletime) {
+ final int vTableId = 7;
+
+ WinNT.HRESULT hr = (WinNT.HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(),
+ dwRegister, pfiletime }, WinNT.HRESULT.class);
+
+ return hr;
+ }
+
+ @Override
+ public HRESULT GetTimeOfLastChange(Pointer pmkObjectName, FILETIME.ByReference pfiletime) {
+ final int vTableId = 8;
+
+ WinNT.HRESULT hr = (WinNT.HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(),
+ pmkObjectName, pfiletime }, WinNT.HRESULT.class);
+
+ return hr;
+ }
+
+ @Override
+ public HRESULT EnumRunning(PointerByReference ppenumMoniker) {
+ final int vTableId = 9;
+
+ WinNT.HRESULT hr = (WinNT.HRESULT) this._invokeNativeObject(vTableId, new Object[] { this.getPointer(),
+ ppenumMoniker }, WinNT.HRESULT.class);
+
+ return hr;
+ }
+
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/Unknown.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/Unknown.java
index 366be7d050..a3d993bff4 100644
--- a/contrib/platform/src/com/sun/jna/platform/win32/COM/Unknown.java
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/Unknown.java
@@ -15,6 +15,7 @@
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.Guid.IID;
+import com.sun.jna.platform.win32.Guid.REFIID;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.PointerByReference;
@@ -55,7 +56,7 @@ public Unknown(Pointer pvInstance) {
* the ppv object
* @return the hresult
*/
- public HRESULT QueryInterface(IID riid, PointerByReference ppvObject) {
+ public HRESULT QueryInterface(REFIID.ByValue riid, PointerByReference ppvObject) {
return (HRESULT) this._invokeNativeObject(0,
new Object[] { this.getPointer(), riid, ppvObject },
HRESULT.class);
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownListener.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownListener.java
new file mode 100644
index 0000000000..8c9322b1bb
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownListener.java
@@ -0,0 +1,66 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.Arrays;
+import java.util.List;
+
+import com.sun.jna.Pointer;
+import com.sun.jna.Structure;
+import com.sun.jna.platform.win32.Guid;
+import com.sun.jna.platform.win32.Guid.REFIID;
+import com.sun.jna.platform.win32.WinError;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
+import com.sun.jna.ptr.PointerByReference;
+
+public class UnknownListener extends Structure {
+
+ public UnknownListener(IUnknownCallback callback) {
+ this.vtbl = this.constructVTable();
+ this.initVTable(callback);
+ super.write();
+ }
+
+ public UnknownVTable.ByReference vtbl;
+
+ @Override
+ protected List getFieldOrder() {
+ return Arrays.asList(new String[] { "vtbl" });
+ }
+
+ protected UnknownVTable.ByReference constructVTable() {
+ return new UnknownVTable.ByReference();
+ }
+
+ protected void initVTable(final IUnknownCallback callback) {
+ this.vtbl.QueryInterfaceCallback = new UnknownVTable.QueryInterfaceCallback() {
+ @Override
+ public HRESULT invoke(Pointer thisPointer, REFIID.ByValue refid, PointerByReference ppvObject) {
+ return callback.QueryInterface(refid, ppvObject);
+ }
+ };
+ this.vtbl.AddRefCallback = new UnknownVTable.AddRefCallback() {
+ @Override
+ public int invoke(Pointer thisPointer) {
+ return callback.AddRef();
+ }
+ };
+ this.vtbl.ReleaseCallback = new UnknownVTable.ReleaseCallback() {
+ @Override
+ public int invoke(Pointer thisPointer) {
+ return callback.Release();
+ }
+ };
+ }
+
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownVTable.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownVTable.java
new file mode 100644
index 0000000000..ec53e1be8b
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownVTable.java
@@ -0,0 +1,49 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.Arrays;
+import java.util.List;
+
+import com.sun.jna.Pointer;
+import com.sun.jna.Structure;
+import com.sun.jna.platform.win32.Guid.REFIID;
+import com.sun.jna.platform.win32.WinNT;
+import com.sun.jna.ptr.PointerByReference;
+import com.sun.jna.win32.StdCallLibrary;
+
+public class UnknownVTable extends Structure {
+ public static class ByReference extends UnknownVTable implements Structure.ByReference {
+ }
+
+ public QueryInterfaceCallback QueryInterfaceCallback;
+ public AddRefCallback AddRefCallback;
+ public ReleaseCallback ReleaseCallback;
+
+ @Override
+ protected List getFieldOrder() {
+ return Arrays.asList(new String[] { "QueryInterfaceCallback", "AddRefCallback", "ReleaseCallback" });
+ }
+
+ public static interface QueryInterfaceCallback extends StdCallLibrary.StdCallCallback {
+ WinNT.HRESULT invoke(Pointer thisPointer, REFIID.ByValue refid, PointerByReference ppvObject);
+ }
+
+ public static interface AddRefCallback extends StdCallLibrary.StdCallCallback {
+ int invoke(Pointer thisPointer);
+ }
+
+ public static interface ReleaseCallback extends StdCallLibrary.StdCallCallback {
+ int invoke(Pointer thisPointer);
+ }
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/util/AbstractComEventCallbackListener.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/AbstractComEventCallbackListener.java
new file mode 100644
index 0000000000..0204d83da4
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/AbstractComEventCallbackListener.java
@@ -0,0 +1,29 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.util;
+
+import com.sun.jna.platform.win32.COM.IDispatchCallback;
+
+public abstract class AbstractComEventCallbackListener implements IComEventCallbackListener {
+
+ public AbstractComEventCallbackListener() {
+ this.dispatchCallback = null;
+ }
+
+ IDispatchCallback dispatchCallback;
+ public void setDispatchCallbackListener(IDispatchCallback dispatchCallback) {
+ this.dispatchCallback = dispatchCallback;
+ }
+
+
+}
diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java
new file mode 100644
index 0000000000..7a8ccc31ee
--- /dev/null
+++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java
@@ -0,0 +1,273 @@
+/* Copyright (c) 2014 Dr David H. Akehurst (itemis), 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.util;
+
+import java.lang.Thread.UncaughtExceptionHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+
+import com.sun.jna.Pointer;
+import com.sun.jna.WString;
+import com.sun.jna.platform.win32.Guid;
+import com.sun.jna.platform.win32.WinDef;
+import com.sun.jna.platform.win32.Guid.IID;
+import com.sun.jna.platform.win32.Guid.REFIID;
+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;
+import com.sun.jna.platform.win32.Variant.VARIANT;
+import com.sun.jna.platform.win32.Variant.VariantArg;
+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.WinDef.WORD;
+import com.sun.jna.platform.win32.WinError;
+import com.sun.jna.platform.win32.WinNT.HRESULT;
+import com.sun.jna.platform.win32.COM.COMException;
+import com.sun.jna.platform.win32.COM.Dispatch;
+import com.sun.jna.platform.win32.COM.DispatchListener;
+import com.sun.jna.platform.win32.COM.IDispatch;
+import com.sun.jna.platform.win32.COM.IDispatchCallback;
+import com.sun.jna.platform.win32.COM.Unknown;
+import com.sun.jna.platform.win32.COM.util.annotation.ComEventCallback;
+import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
+import com.sun.jna.ptr.IntByReference;
+import com.sun.jna.ptr.PointerByReference;
+
+public class CallbackProxy implements IDispatchCallback {
+
+ public CallbackProxy(Factory factory, Class> comEventCallbackInterface,
+ IComEventCallbackListener comEventCallbackListener) {
+ this.factory = factory;
+ this.comEventCallbackInterface = comEventCallbackInterface;
+ this.comEventCallbackListener = comEventCallbackListener;
+ this.listenedToRiid = this.createRIID(comEventCallbackInterface);
+ this.dsipIdMap = this.createDispIdMap(comEventCallbackInterface);
+ this.dispatchListener = new DispatchListener(this);
+ this.executorService = Executors.newSingleThreadExecutor(new ThreadFactory() {
+ @Override
+ public Thread newThread(Runnable r) {
+ Thread thread = new Thread(r, "COM Event Callback executor");
+ thread.setDaemon(true);
+ thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
+ @Override
+ public void uncaughtException(Thread t, Throwable e) {
+ CallbackProxy.this.factory.comThread.uncaughtExceptionHandler.uncaughtException(t, e);
+ }
+ });
+ return thread;
+ }
+ });
+ }
+
+ Factory factory;
+ Class> comEventCallbackInterface;
+ IComEventCallbackListener comEventCallbackListener;
+ REFIID.ByValue listenedToRiid;
+ public DispatchListener dispatchListener;
+ Map dsipIdMap;
+ ExecutorService executorService;
+
+ REFIID.ByValue createRIID(Class> comEventCallbackInterface) {
+ ComInterface comInterfaceAnnotation = comEventCallbackInterface.getAnnotation(ComInterface.class);
+ if (null == comInterfaceAnnotation) {
+ throw new COMException(
+ "advise: Interface must define a value for either iid via the ComInterface annotation");
+ }
+ String iidStr = comInterfaceAnnotation.iid();
+ if (null == iidStr || iidStr.isEmpty()) {
+ throw new COMException("ComInterface must define a value for iid");
+ }
+ return new REFIID.ByValue(new IID(iidStr).getPointer());
+ }
+
+ Map createDispIdMap(Class> comEventCallbackInterface) {
+ Map map = new HashMap();
+
+ for (Method meth : comEventCallbackInterface.getMethods()) {
+ ComEventCallback annotation = meth.getAnnotation(ComEventCallback.class);
+ if (null != annotation) {
+ int dispId = annotation.dispid();
+ if (-1 == dispId) {
+ dispId = this.fetchDispIdFromName(annotation);
+ }
+ map.put(new DISPID(dispId), meth);
+ }
+ }
+
+ return map;
+ }
+
+ int fetchDispIdFromName(ComEventCallback annotation) {
+ // TODO
+ return -1;
+ }
+
+ void invokeOnThread(final DISPID dispIdMember, final REFIID.ByValue riid, LCID lcid, WORD wFlags,
+ final DISPPARAMS.ByReference pDispParams) {
+ // decode arguments
+ // must decode them on this thread, and create a proxy for any COM objects (IDispatch)
+ // this will AddRef on the COM object so that it is not cleaned up before we can use it
+ // on the thread that does the java callback.
+ List