use of com.sun.jna.ptr.IntByReference in project jna by java-native-access.
the class Netapi32Test method testNetGetJoinInformation.
public void testNetGetJoinInformation() {
IntByReference bufferType = new IntByReference();
assertEquals(W32Errors.ERROR_INVALID_PARAMETER, Netapi32.INSTANCE.NetGetJoinInformation(null, null, bufferType));
PointerByReference lpNameBuffer = new PointerByReference();
assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetGetJoinInformation(null, lpNameBuffer, bufferType));
assertTrue(lpNameBuffer.getValue().getString(0).length() > 0);
assertTrue(bufferType.getValue() > 0);
assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue()));
}
use of com.sun.jna.ptr.IntByReference in project jna by java-native-access.
the class Netapi32Test method testNetUserGetLocalGroups.
public void testNetUserGetLocalGroups() {
String currentUser = Secur32Util.getUserNameEx(EXTENDED_NAME_FORMAT.NameSamCompatible);
PointerByReference bufptr = new PointerByReference();
IntByReference entriesread = new IntByReference();
IntByReference totalentries = new IntByReference();
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserGetLocalGroups(null, currentUser, 0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries));
LOCALGROUP_USERS_INFO_0 lgroup = new LOCALGROUP_USERS_INFO_0(bufptr.getValue());
LOCALGROUP_USERS_INFO_0[] lgroups = (LOCALGROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
for (LOCALGROUP_USERS_INFO_0 localGroupInfo : lgroups) {
assertTrue(localGroupInfo.lgrui0_name.length() > 0);
}
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
}
use of com.sun.jna.ptr.IntByReference in project jna by java-native-access.
the class Netapi32Test method testNetShareAddShareInfo2.
public void testNetShareAddShareInfo2() throws Exception {
File fileShareFolder = createTempFolder();
SHARE_INFO_2 shi = new SHARE_INFO_2();
shi.shi2_netname = fileShareFolder.getName();
shi.shi2_type = LMShare.STYPE_DISKTREE;
shi.shi2_remark = "";
shi.shi2_permissions = LMAccess.ACCESS_ALL;
shi.shi2_max_uses = -1;
shi.shi2_current_uses = 0;
shi.shi2_path = fileShareFolder.getAbsolutePath();
shi.shi2_passwd = "";
// Write from struct to native memory.
shi.write();
IntByReference parm_err = new IntByReference(0);
int winError = // Use local computer
Netapi32.INSTANCE.NetShareAdd(// Use local computer
null, 2, shi.getPointer(), parm_err);
if (winError == W32Errors.ERROR_INVALID_PARAMETER) {
// fail with offset.
throw new Exception("testNetShareAddShareInfo2 failed with invalid parameter on structure offset: " + parm_err.getValue());
}
assertEquals("Failed to add share", LMErr.NERR_Success, winError);
Netapi32.INSTANCE.NetShareDel(null, shi.shi2_netname, 0);
}
use of com.sun.jna.ptr.IntByReference in project jna by java-native-access.
the class Netapi32Test method testNetShareDel.
public void testNetShareDel() throws Exception {
File fileShareFolder = createTempFolder();
SHARE_INFO_2 shi = new SHARE_INFO_2();
shi.shi2_netname = fileShareFolder.getName();
shi.shi2_type = LMShare.STYPE_DISKTREE;
shi.shi2_remark = "";
shi.shi2_permissions = LMAccess.ACCESS_ALL;
shi.shi2_max_uses = -1;
shi.shi2_current_uses = 0;
shi.shi2_path = fileShareFolder.getAbsolutePath();
shi.shi2_passwd = "";
// Write from struct to native memory.
shi.write();
IntByReference parm_err = new IntByReference(0);
assertEquals("Failed to add share", LMErr.NERR_Success, // Use local computer
Netapi32.INSTANCE.NetShareAdd(// Use local computer
null, 2, shi.getPointer(), parm_err));
assertEquals("Failed to delete share", LMErr.NERR_Success, Netapi32.INSTANCE.NetShareDel(null, shi.shi2_netname, 0));
}
use of com.sun.jna.ptr.IntByReference in project jna by java-native-access.
the class Netapi32Test method testNetGroupEnum.
public void testNetGroupEnum() {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesread = new IntByReference();
IntByReference totalentries = new IntByReference();
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetGroupEnum(null, 2, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries, null));
GROUP_INFO_2 group = new GROUP_INFO_2(bufptr.getValue());
GROUP_INFO_2[] groups = (GROUP_INFO_2[]) group.toArray(entriesread.getValue());
for (GROUP_INFO_2 grpi : groups) {
assertTrue(grpi.grpi2_name.length() > 0);
}
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
}
Aggregations