Skip to content

Instantly share code, notes, and snippets.

@kimukou
Created December 7, 2010 09:12
Show Gist options
  • Save kimukou/731605 to your computer and use it in GitHub Desktop.
Save kimukou/731605 to your computer and use it in GitHub Desktop.
jnatest.groovy
@Grab('net.java.dev.jna:jna:3.2.7')
import com.sun.jna.*
import com.sun.jna.win32.*
interface Kernel32Library extends StdCallLibrary {
Kernel32Library INSTANCE = Native.loadLibrary("kernel32", Kernel32Library.class)
boolean SetCurrentDirectoryA(String dir)
public static class SYSTEMTIME extends Structure {
public short wYear
public short wMonth
public short wDayOfWeek
public short wDay
public short wHour
public short wMinute
public short wSecond
public short wMilliseconds
}
void GetSystemTime(SYSTEMTIME result)
}
Kernel32Library.INSTANCE.SetCurrentDirectoryA("c:/Documents and Settings")
println "cmd /C cd".execute().text
println "--------------"
Kernel32Library.SYSTEMTIME time = new Kernel32Library.SYSTEMTIME()
Kernel32Library.INSTANCE.GetSystemTime(time)
println time.toString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment