|
23 | 23 | */
|
24 | 24 | package com.sun.jna.platform.win32;
|
25 | 25 |
|
| 26 | +import com.sun.jna.Native; |
26 | 27 | import com.sun.jna.NativeLong;
|
27 | 28 | import com.sun.jna.Pointer;
|
28 | 29 | import com.sun.jna.Structure;
|
29 | 30 | import com.sun.jna.Structure.FieldOrder;
|
30 | 31 | import com.sun.jna.platform.win32.WinNT.HANDLE;
|
31 | 32 | import com.sun.jna.Union;
|
32 | 33 |
|
33 |
| -import java.text.ParseException; |
34 |
| - |
35 | 34 | import static com.sun.jna.platform.win32.WinDef.*;
|
| 35 | +import java.nio.charset.StandardCharsets; |
36 | 36 |
|
37 | 37 | /**
|
38 | 38 | * Ported from WinGDI.h.
|
@@ -276,19 +276,24 @@ public static class ByReference extends DEVMODE implements Structure.ByReference
|
276 | 276 | * Converts dmDeviceName from raw byte[] to String
|
277 | 277 | */
|
278 | 278 | public String getDmDeviceName() {
|
279 |
| - int offset = fieldOffset("dmDeviceName"); |
280 |
| - return CHAR_WIDTH == 1 ? getPointer().getString(offset) : getPointer().getWideString(offset); |
| 279 | + if(CHAR_WIDTH == 1) { |
| 280 | + return Native.toString(dmFormName); |
| 281 | + } else { |
| 282 | + return new String(dmDeviceName, StandardCharsets.UTF_16LE); |
| 283 | + } |
281 | 284 | }
|
282 | 285 |
|
283 | 286 | /**
|
284 | 287 | * Converts dmFormName from raw byte[] to String
|
285 | 288 | */
|
286 | 289 | public String getDmFormName() {
|
287 |
| - int offset = fieldOffset("dmFormName"); |
288 |
| - return CHAR_WIDTH == 1 ? getPointer().getString(offset) : getPointer().getWideString(offset); |
| 290 | + if(CHAR_WIDTH == 1) { |
| 291 | + return Native.toString(dmFormName); |
| 292 | + } else { |
| 293 | + return new String(dmFormName, StandardCharsets.UTF_16LE); |
| 294 | + } |
289 | 295 | }
|
290 | 296 |
|
291 |
| - |
292 | 297 | public static class DUMMYUNIONNAME extends Union {
|
293 | 298 | public DUMMYSTRUCTNAME dummystructname;
|
294 | 299 |
|
|
0 commit comments