

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
5 messages in net.java.dev.jna.usersRe: [jna-users] Can't Find Native Fun...| From | Sent On | Attachments |
|---|---|---|
| Dick Adams | Dec 27, 2008 6:15 pm | |
| Timothy Wall | Dec 28, 2008 12:18 am | |
| Dick Adams | Dec 28, 2008 5:33 am | |
| Timothy Wall | Dec 28, 2008 9:09 am | |
| Steve Sobol (JDN) | Dec 28, 2008 9:47 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] Can't Find Native Function | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | Dec 28, 2008 12:18:02 am | |
| List: | net.java.dev.jna.users | |
Look at the JNA example kernel32 API definition, including the options passed to the Native.loadLibrary call.
There is a function name mapper which converts GetFileAttributes into GetFileAttributes{A|W}.
On Dec 27, 2008, at 9:16 PM, Dick Adams wrote:
I'm getting an error message trying to call the Windows GetFileAttributes() function (I'm running Windows XP). Can anyone see what I'm doing wrong?
ERROR MESSAGE:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'GetFileAttributes': The specified procedure could not be found.
at com.sun.jna.Function.<init>(Function.java:129) at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:250) at com.sun.jna.Library$Handler.invoke(Library.java:191) at $Proxy0.GetFileAttributes(Unknown Source) at com.atomware.Publisher.accept(Publisher.java:70) at com.atomware.io.Directory.accept(Directory.java:80) at java.io.File.listFiles(Unknown Source) at com.atomware.io.Directory.getMatchingFiles(Directory.java:107) at com.atomware.io.TreeWalker.walk(TreeWalker.java:53) at com.atomware.Publisher.publish(Publisher.java:87) at com.atomware.Publisher.main(Publisher.java:33)
CODE:
import java.io.File;
import com.sun.jna.Native; import com.sun.jna.win32.StdCallLibrary;
/** * Provides access to the Microsoft Windows KERNEL32.DLL. */ public class WindowsKernel {
// = = = = = = = = = = = = = = = = = = = = = = = = ====================================================================== /** * Accesses native Windows API from Java */ public interface API extends StdCallLibrary {
/** The API Instance */ API INSTANCE = (API)Native.loadLibrary(LIBRARY_NAME, API.class);
/** * Retrieves a set of FAT file system attributes for a specified file or directory. * Many file attributes are already from the Java {@link File} class, but certain ones, * such as the archive bit, are available only by calling this method. * @param fileName The file name. * @return The bit-mapped attributes. */ int GetFileAttributes(String fileName); } // = = = = = = = = = = = = = = = = = = = = = = = = ======================================================================
/** Value: {@value} */ public static final String LIBRARY_NAME = "C:/WINDOWS/SYSTEM32/ kernel32.dll"; }







