5 messages in net.java.dev.jna.users[jna-users] Can't Find Native Function
FromSent OnAttachments
Dick AdamsDec 27, 2008 6:15 pm 
Timothy WallDec 28, 2008 12:18 am 
Dick AdamsDec 28, 2008 5:33 am 
Timothy WallDec 28, 2008 9:09 am 
Steve Sobol (JDN)Dec 28, 2008 9:47 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[jna-users] Can't Find Native FunctionActions...
From:Dick Adams (9212@cox.net)
Date:Dec 27, 2008 6:15:41 pm
List:net.java.dev.jna.users

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"; }