WinPack

Get answers to most commonly asked technical questions about WinPack. If you don’t find the answer here, please send us your question using the support forum and we will add it to this FAQ section after answering you.

Does WinPack library provide the wrapping for all Windows API?

No, it does not. It provides the wrapping only for the really useful features of the Windows platform that mostly are not available in Java.

Why is the NoSuchFunctionException thrown when I try to get the existing function from the user32 library? For example, new Library("user32").getFunction("GetWindowText")

Actually, there is no such "GetWindowText" function in the user32 library, but there are two appropriate "GetWindowTextA" and "GetWindowTextW" functions, representing ANSI and Unicode versions, respectively.

Is it possible to make a Swing window transparent using WinPack?

Yes, it is possible. There is a special Wnd class for this. Please view the WinPack Demo application that demonstrates such this ability.

Is it possible to change the standard rectangular shape of a Swing window to a custom one using WinPack?

Yes, it is possible. You can do this using the Wnd and Region classes from WinPack library. Please view the WinPack Demo application that demonstrates such this ability.

Is it possible and how to get an error code when calling a standard function from the Windows API?

Under the Windows platform, the Function.invoke() method returns the value that is an error code. This error code can be translated to an appropriate error message by using the LastError.getMessage(long errorCode) method.

Is it possible to get or handle window messages of a Swing window? If yes, how is it possible?

Yes, it is possible. WinPack provides a special WindowProc class which lets you substitute the standard window procedure of a Swing window and listen to its messages.

Is it possible to get information about the file system (such as DriveType, FreeDiskSpace, TotalDiskSize) using WinPack?

Yes. There is a special FileSystem class that provides such ability.

Does WinPack provide API for working with MAPI?

Yes, WinPack provides it. All MAPI related classes can be found in the com.jniwrapper.win32.mapi package.

Is it possible to terminate a process by using WinPack library? Is there any API for it?

Yes, in WinPack there is Processes API that allows you to manipulate processes, including process termination.

Why does the Process.close() method not terminate a process?

To terminate a process, you should use the Process.terminate(long exitCode) The close() method just closes the handle of a given process.

Does WinPack provide API for listening to the system events, such as removing/inserting a drive, inserting/ejecting a CD/DVD drive, etc?

Yes, we have added such ability to WinPack version 3.0. There is a special ShellEventsSubscriber class (from the com.jniwrapper.win32.shell.events package) that provides API for this purpose.

Is it possible to get the proxy setting of the Internet Explorer application using WinPack?

Yes, WinPack provides special API for this purpose. You can find it in the com.jniwrapper.win32.winhttp package.

Is there any API in WinPack for accessing global system variables?

There is a special com.jniwrapper.win32.system.SystemVariables class that provides such ability.

Is it possible to get a list of all running services on a remote computer using WinPack?

The Services API from WinPack library (com.jniwrapper.win32.service package) provides such ability.

I'm using WinPack's FileSystemWatcher to monitor a folder. When a file is added to the folder I get 1 FILE_ADDED event and 3 FILE_MODIFIED events. When a file is modified I get 4 FILE_MODIFIED events. Is this correct behaviour?

The number of receiving events depends on options of the FileSystemWatcher object. There are several kinds of notifications in the FileSystemWatcher.WatcherOptions class and they all set to true by default. That's why you get many FILE_MODIFIED events. But you can easily disable the unwanted ones. For example:

FileSystemWatcher watcher = new FileSystemWatcher(folder, true);

FileSystemWatcher.WatcherOptions options = watcher.getOptions();

options.setNotifyChangeAttributes(false);

options.setNotifyChangeSize(false);

and so on.