10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include <stdlib.h>
25 #include <string.h>
26
27 #ifdef _WIN32
28
29 #include "jni.h"
30 #include "jni_util.h"
31 #include <windows.h>
32
33 JNIEXPORT jlong JNICALL Java_CheckHandles_getProcessHandleCount(JNIEnv *env)
34 {
35 DWORD handleCount;
36 HANDLE handle = GetCurrentProcess();
37 if (GetProcessHandleCount(handle, &handleCount)) {
38 return (jlong)handleCount;
39 } else {
40 return -1L;
41 }
42 }
43
44 #endif /* _WIN32 */
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include <stdlib.h>
25 #include <string.h>
26
27 #ifdef _WIN32
28
29 #include "jni.h"
30 #include <windows.h>
31
32 JNIEXPORT jlong JNICALL Java_CheckHandles_getProcessHandleCount(JNIEnv *env)
33 {
34 DWORD handleCount;
35 HANDLE handle = GetCurrentProcess();
36 if (GetProcessHandleCount(handle, &handleCount)) {
37 return (jlong)handleCount;
38 } else {
39 return -1L;
40 }
41 }
42
43 #endif /* _WIN32 */
|