Skip to content

Commit a6e0963

Browse files
Merge pull request #803 from matthiasblaesing/faq_ascii_unicode
Add FAQ for Windows API function naming
2 parents 1468004 + 3d306cf commit a6e0963

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

www/FrequentlyAskedQuestions.md

+20
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,23 @@ If you're using Proguard, you should also add the following to your Proguard rul
217217
-keep class com.sun.jna.* { *; }
218218
-keepclassmembers class * extends com.sun.jna.* { public *; }
219219
```
220+
221+
On Windows, MSDN shows that TheFuncName is in somelib.dll but JNA throws UnsatisifiedLinkError: The specified procedure could not be found.
222+
-------------------------------------------------------------------------------------------------------------------------------------------
223+
224+
Make sure you're on a version of Windows that contains the function.
225+
226+
Some windows functions are documented as TheFuncName but are actually implemented
227+
as TheFuncNameA and TheFuncNameW in the library. You can see this with
228+
Dependency Walker (depends.exe) from http://dependencywalker.com when you open
229+
the DLL.
230+
231+
The convention is, that the “A” suffix indicates a function expecting ANSI/
232+
windows code page encoding and a “W” suffix indicates a function expecting wide
233+
(unicode, UTF-16) strings.
234+
235+
JNA won't automatically resolve one or the other variant. You should use a
236+
a combination of TypeMapper and FunctionMapper (see
237+
`com.sun.jna.win32.W32APIOptions.DEFAULT_OPTIONS`) so that you can leave off the
238+
“-A” or “-W” suffix (you never need to use both simultaneously) and use
239+
“String” rather than explicit “WString”.

0 commit comments

Comments
 (0)