Getting WTSSessionId in a Java program
Is there a way to get the value of the WTSSessionID parameter in a Java program. I am wondering if JNI is the only way to accomplish this ?
Technically speaking, the answer to any question asking "...is JNI the only way?" is: No, it is not the only way. There are at least two alternatives to JNI. I've used JNA; there's another one called JNative; and who knows, there might be others. The advantage of these alternatives is that you don't have to create a new dll to act as a shim between Java and the native API.
There is no 100% Java way to obtain this Windows-specific value. You can execute a program and capture its output, or you can use JNI. You can use JNI with a DLL you write yourself, or you can use JNI with a tool (e.g. Jacob, JNA, or JNative), but in any of those cases you are invoking native code.
精彩评论