1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
/* Copyright (c) 2011 Timothy Wall, All Rights Reserved
*
* The contents of this file is dual-licensed under 2
* alternative Open Source/Free licenses: LGPL 2.1 or later and
* Apache License 2.0. (starting with JNA version 4.0.0).
*
* You can freely decide which license you want to apply to
* the project.
*
* You may obtain a copy of the LGPL License at:
*
* http://www.gnu.org/licenses/licenses.html
*
* A copy is also included in the downloadable source code package
* containing JNA, in file "LGPL2.1".
*
* You may obtain a copy of the Apache License at:
*
* http://www.apache.org/licenses/
*
* A copy is also included in the downloadable source code package
* containing JNA, in file "AL2.0".
*/
package com.sun.jna.wince;
import junit.framework.TestCase;
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.*;
import java.util.List;
public class CoreDLLTest extends TestCase {
public static void main(java.lang.String[] argList) {
junit.textui.TestRunner.run(CoreDLLTest.class);
}
public interface CoreDLL extends StdCallLibrary {
CoreDLL INSTANCE = Native.load("coredll", CoreDLL.class, W32APIOptions.UNICODE_OPTIONS);
public static class SECURITY_ATTRIBUTES extends Structure {
public static final List<String> FIELDS = createFieldsOrder("dwLength", "lpSecurityDescriptor", "bInheritHandle");
public int dwLength;
public Pointer lpSecurityDescriptor;
public boolean bInheritHandle;
public SECURITY_ATTRIBUTES() {
dwLength = size();
}
@Override
protected List<String> getFieldOrder() {
return FIELDS;
}
}
public static class STARTUPINFO extends Structure {
public static final List<String> FIELDS = createFieldsOrder(
"cb", "lpReserved", "lpDesktop", "lpTitle", "dwX", "dwY", "dwXSize", "dwYSize",
"dwXCountChars", "dwYCountChars", "dwFillAttribute", "dwFlags", "wShowWindow",
"cbReserved2", "lpReserved2", "hStdInput", "hStdOutput", "hStdError");
public int cb;
public String lpReserved;
public String lpDesktop;
public String lpTitle;
public int dwX;
public int dwY;
public int dwXSize;
public int dwYSize;
public int dwXCountChars;
public int dwYCountChars;
public int dwFillAttribute;
public int dwFlags;
public short wShowWindow;
public short cbReserved2;
public ByteByReference lpReserved2;
public Pointer hStdInput;
public Pointer hStdOutput;
public Pointer hStdError;
public STARTUPINFO() {
cb = size();
}
@Override
protected List<String> getFieldOrder() {
return FIELDS;
}
}
public static class PROCESS_INFORMATION extends Structure {
public static final List<String> FIELDS = createFieldsOrder("hProcess", "hThread", "dwProcessId", "dwThreadId");
public Pointer hProcess;
public Pointer hThread;
public int dwProcessId;
public int dwThreadId;
public static class ByReference extends PROCESS_INFORMATION implements Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public PROCESS_INFORMATION() {
super();
}
public PROCESS_INFORMATION(Pointer memory) {
super(memory);
}
@Override
protected List<String> getFieldOrder() {
return FIELDS;
}
}
boolean CreateProcess(String lpApplicationName, String lpCommandLine,
SECURITY_ATTRIBUTES lpProcessAttributes,
SECURITY_ATTRIBUTES lpThreadAttributes,
boolean bInheritHandles, int dwCreationFlags,
Pointer lpEnvironment, String lpCurrentDirectory, STARTUPINFO lpStartupInfo,
PROCESS_INFORMATION lpProcessInformation) throws LastErrorException;
}
public void testCreateProcess() {
CoreDLL.PROCESS_INFORMATION processInformation = new CoreDLL.PROCESS_INFORMATION();
//String cmd = "/storage card/Program files/PHM Tools/regedit";
String cmd = null;
boolean status = CoreDLL.INSTANCE.CreateProcess(cmd, null, null, null,
false, 0x10, Pointer.NULL,
null, null, processInformation);
assertTrue("Process launch failed", status);
}
}
|