4 messages in net.java.dev.jna.usersRe: [jna-users] Mapping for LPCTSTR a...
FromSent OnAttachments
tho...@atunes.orgJan 31, 2008 12:39 pm 
Timothy WallJan 31, 2008 1:42 pm 
Paul LoyFeb 1, 2008 5:24 am 
Timothy WallFeb 1, 2008 5:43 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:Re: [jna-users] Mapping for LPCTSTR and LPTSTRActions...
From:Timothy Wall (twal@dev.java.net)
Date:Feb 1, 2008 5:43:18 am
List:net.java.dev.jna.users

On Feb 1, 2008, at 8:24 AM, Paul Loy wrote:

private static final int CHAR_BYTE_WIDTH = 2;

Native.WCHAR_SIZE provides this information, so you don't have to hard-code it.

/** * Unicode (wchar_t*) version of GetShortPathName()<br /> * <br /> * DWORD WINAPI GetShortPathNameW( * __in LPCTSTR lpszLongPath, * __out LPTSTR lpdzShortPath, * __in DWORD cchBuffer * ); */ NativeLong GetShortPathNameW(WString inPath, Memory outPathBuffer, NativeLong outPathBufferSize); }

While NativeLong doesn't hurt, "long" on windows is always 32-bit (even on win64), so you could use Java "int" here instead.

In most cases, a primitive array ("char[]"), Memory, or an NIO Buffer are interchangeable for the buffer argument (you can even declare all three at the same time if you want to compare them).