forked from kohsuke/com4j
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNative.java
More file actions
150 lines (128 loc) · 4.36 KB
/
Copy pathNative.java
File metadata and controls
150 lines (128 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package com4j;
import java.nio.ByteBuffer;
/**
* Native methods implemented in the dll.
*
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
* @author Michael Schnell (ScM)
*/
class Native {
/**
* Initializes the native code.
*/
static native void init();
/**
* Creates a COM object and returns its pointer.
*/
static native long createInstance( String clsid, int clsctx, long iid1, long iid2 );
/**
* Calls {@code GetActiveObject} Win32 API.
*/
static native long getActiveObject( long clsid1, long clsid2 );
/**
* Equivalent of {@code GetObject} in VB.
*
* See http://support.microsoft.com/kb/122288
*/
static native long getObject( String fileName, String progId );
/**
* returns a pointer to the running object table.
* @return a pointer to the running object table
*/
static native long getRunningObjectTable();
/**
* Returns an enum moniker for the given running object table.
* @param rotPointer the pointer to the running object table
* @return an enum moniker for the given running object table
*/
static native long getEnumMoniker(long rotPointer);
/**
* Returns a pointer to the next object of the running object table.
* @param rotPointer a pointer to the running object table
* @param enumMonikerPointer a pointer to an enum moniker
* @return a pointer to the next object of the running object table
*/
static native long getNextRunningObject(long rotPointer, long enumMonikerPointer);
/**
* Calls <tt>IUnknown.AddRef</tt>.
*/
static native int addRef( long pComObject );
/**
* Calls <tt>IUnknown.Release</tt>.
*/
static native int release( long pComObject );
/**
* Invokes a method.
*
* @throws ComException
* if the invocation returns a failure HRESULT, and the return type
* is not HRESULT.
*/
static native Object invoke( long pComObject, long vtIndex,
Object[] args, int[] parameterConversions,
int returnIndex, boolean returnIsInOut, int returnConversion );
/**
* Invokes {@code IDispatch.Invoke}.
*/
static native Variant invokeDispatch(
long pComObject, int dispId, int flag, Object[] args );
/**
* Gets the error info.
*
* <p>
* This method is used after the <tt>invoke</tt> method fails,
* to obtain the <tt>IErrorInfo</tt> object. This method checks
* <tt>ISupportErrorInfo</tt>.
*
* @param pComObject
* The object that caused an error.
* @return
* the pointer to <tt>IErrorInfo</tt> or null if not available.
*/
static native long getErrorInfo( long pComObject, long iid1, long iid2 );
static IErrorInfo getErrorInfo( long pComObject, Class<? extends Com4jObject> _interface ) {
GUID guid = COM4J.getIID(_interface);
long p = getErrorInfo(pComObject,guid.v[0],guid.v[1]);
if(p==0) return null;
else return Wrapper.create(IErrorInfo.class,p);
}
/**
* Gets the error message string for the given HRESULT.
*
* @return null if none is found.
*/
static native String getErrorMessage( int hresult );
static native long queryInterface( long pComObject, long iid1, long iid2 );
static long queryInterface( long pComObject, GUID guid ) {
return queryInterface(pComObject, guid.v[0], guid.v[1]);
}
/**
* Loads a type library from a given file, wraps it, and returns its IUnknown.
*/
static native long loadTypeLibrary(String name);
/**
* Calls "CoInitialize"
*/
static native void coInitialize();
/**
* Calls "CoUninitialize"
*/
static native void coUninitialize();
/**
* Calls IConnectionPoint::Advise and subscribe to the event.
*
* @param connectionPoint
* interface pointer to the connection point.
* @return
* pointer to the native proxy
*/
static native long advise(long connectionPoint, EventProxy<?> eventProxy, long iid1, long iid2);
/**
* Shuts down the event subscription by calling IConnectionPoint::Unadvise.
*/
static native void unadvise(long nativeProxy);
/**
* Creates a direct buffer.
*/
static native ByteBuffer createBuffer(long ptr, int size);
}