use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class ObjectFactory method getRunningObjectTable.
/**
* CoInitialize must be called be fore this method. Either explicitly or
* implicitly via other methods.
*
* @return running object table
*/
public IRunningObjectTable getRunningObjectTable() {
assert COMUtils.comIsInitialized() : "COM not initialized";
final PointerByReference rotPtr = new PointerByReference();
HRESULT hr = Ole32.INSTANCE.GetRunningObjectTable(new WinDef.DWORD(0), rotPtr);
COMUtils.checkRC(hr);
com.sun.jna.platform.win32.COM.RunningObjectTable raw = new com.sun.jna.platform.win32.COM.RunningObjectTable(rotPtr.getValue());
IRunningObjectTable rot = new RunningObjectTable(raw, this);
return rot;
}
use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class Netapi32Util method getGlobalGroups.
/**
* Get the names of global groups on a computer.
* @param serverName Name of the computer.
* @return An array of group names.
*/
public static Group[] getGlobalGroups(String serverName) {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesRead = new IntByReference();
IntByReference totalEntries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetGroupEnum(serverName, 1, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null);
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
throw new Win32Exception(rc);
}
LMAccess.GROUP_INFO_1 group = new LMAccess.GROUP_INFO_1(bufptr.getValue());
LMAccess.GROUP_INFO_1[] groups = (LMAccess.GROUP_INFO_1[]) group.toArray(entriesRead.getValue());
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
for (LMAccess.GROUP_INFO_1 lgpi : groups) {
LocalGroup lgp = new LocalGroup();
if (lgpi.grpi1_name != null) {
lgp.name = lgpi.grpi1_name.toString();
}
if (lgpi.grpi1_comment != null) {
lgp.comment = lgpi.grpi1_comment.toString();
}
result.add(lgp);
}
return result.toArray(new LocalGroup[0]);
} finally {
if (bufptr.getValue() != Pointer.NULL) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class Netapi32Util method getDomainName.
/**
* Get information about a computer.
* @param computerName computer name
* @return Domain or workgroup name.
*/
public static String getDomainName(String computerName) {
PointerByReference lpNameBuffer = new PointerByReference();
IntByReference bufferType = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType);
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
// type of domain: bufferType.getValue()
return lpNameBuffer.getValue().getWideString(0);
} finally {
if (lpNameBuffer.getPointer() != null) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class TypeLibUtil method GetTypeComp.
/**
* Gets the type comp.
*
* @return the i type comp. by reference
*/
public TypeComp GetTypeComp() {
PointerByReference ppTComp = new PointerByReference();
HRESULT hr = this.typelib.GetTypeComp(ppTComp);
COMUtils.checkRC(hr);
return new TypeComp(ppTComp.getValue());
}
use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class TypeLibUtil method getLibAttr.
/**
* Gets the lib attr.
*
* @return the lib attr
*/
public TLIBATTR getLibAttr() {
PointerByReference ppTLibAttr = new PointerByReference();
HRESULT hr = typelib.GetLibAttr(ppTLibAttr);
COMUtils.checkRC(hr);
return new TLIBATTR(ppTLibAttr.getValue());
}
Aggregations