Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New FAQ entry on ASCII/Unicode functions in Windows #377

Closed
ringerc opened this issue Oct 30, 2014 · 3 comments
Closed

New FAQ entry on ASCII/Unicode functions in Windows #377

ringerc opened this issue Oct 30, 2014 · 3 comments

Comments

@ringerc
Copy link

ringerc commented Oct 30, 2014

Q: On Windows, MSDN shows that TheFuncName is in somelib.dll but JNA throws UnsatisifiedLinkError: The specified procedure could not be found.

A: Make sure you're on a version of Windows that contains the function.

A: Some windows functions are documented as TheFuncName but are actually implemented as TheFuncNameA and TheFuncNameW in the library. You can see this with Dependency Walker (depends.exe) from http://dependencywalker.com when you open the DLL. JNA won't automatically resolve the wide-string variant, so you should explicitly declare the wide-string name variant or use a FunctionMapper like W32APIFunctionMapper.

@ringerc
Copy link
Author

ringerc commented Oct 30, 2014

See also related Stack Overflow post with example: http://stackoverflow.com/q/26644491/398670

@dblock
Copy link
Member

dblock commented Oct 30, 2014

You should contribute this to the JNA documentation.

@twall
Copy link
Contributor

twall commented Oct 30, 2014

This is useful, thanks.

It’s preferable to use a combination of TypeMapper and FunctionMapper (see com.sun.jna.win32.W32APIOptions.DEFAULT_OPTIONS) so that you can leave off the “-A” or “-W” suffix (you never need to use both simultaneously) and use “String” rather than explicit “WString”.

On Oct 29, 2014, at 11:10 PM, Craig Ringer [email protected] wrote:

Q: On Windows, MSDN shows that TheFuncName is in somelib.dll but JNA throws UnsatisifiedLinkError: The specified procedure could not be found.

A: Make sure you're on a version of Windows that contains the function.

A: Some windows functions are documented as TheFuncName but are actually implemented as TheFuncNameA and TheFuncNameW in the library. You can see this with Dependency Walker (depends.exe) from http://dependencywalker.com when you open the DLL. JNA won't automatically resolve the wide-string variant, so you should explicitly declare the wide-string name variant or use a FunctionMapper.


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants