use of com.sun.jna.platform.win32.WinRas.RASDIALPARAMS in project jna by java-native-access.
the class Rasapi32Util method getPhoneBookDialingParams.
/**
* get a phone book entry's dialing parameters
* @param entryName the phone book entry name
* @return the entry's dialing parameters parameters
* @throws Ras32Exception errors
*/
public static RASDIALPARAMS getPhoneBookDialingParams(String entryName) throws Ras32Exception {
synchronized (phoneBookMutex) {
RASDIALPARAMS.ByReference rasDialParams = new RASDIALPARAMS.ByReference();
System.arraycopy(rasDialParams.szEntryName, 0, entryName.toCharArray(), 0, entryName.length());
BOOLByReference lpfPassword = new BOOLByReference();
int err = Rasapi32.INSTANCE.RasGetEntryDialParams(null, rasDialParams, lpfPassword);
if (err != WinError.ERROR_SUCCESS)
throw new Ras32Exception(err);
return rasDialParams;
}
}
use of com.sun.jna.platform.win32.WinRas.RASDIALPARAMS in project jna by java-native-access.
the class Rasapi32Util method dialEntry.
/**
* Dial a phone book entry by name (Asynchronously - callback type 2)
* @param entryName The phone book entry name
* @param func2
* @return the HRASCONN for this connection
* @throws Ras32Exception errors
*/
public static HANDLE dialEntry(String entryName, RasDialFunc2 func2) throws Ras32Exception {
// get the RAS Credentials
RASCREDENTIALS.ByReference credentials = new RASCREDENTIALS.ByReference();
synchronized (phoneBookMutex) {
credentials.dwMask = WinRas.RASCM_UserName | WinRas.RASCM_Password | WinRas.RASCM_Domain;
int err = Rasapi32.INSTANCE.RasGetCredentials(null, entryName, credentials);
if (err != WinError.ERROR_SUCCESS)
throw new Ras32Exception(err);
}
// set the dialing parameters
RASDIALPARAMS.ByReference rasDialParams = new RASDIALPARAMS.ByReference();
System.arraycopy(entryName.toCharArray(), 0, rasDialParams.szEntryName, 0, entryName.length());
System.arraycopy(credentials.szUserName, 0, rasDialParams.szUserName, 0, credentials.szUserName.length);
System.arraycopy(credentials.szPassword, 0, rasDialParams.szPassword, 0, credentials.szPassword.length);
System.arraycopy(credentials.szDomain, 0, rasDialParams.szDomain, 0, credentials.szDomain.length);
// dial
HANDLEByReference hrasConn = new HANDLEByReference();
int err = Rasapi32.INSTANCE.RasDial(null, null, rasDialParams, 2, func2, hrasConn);
if (err != WinError.ERROR_SUCCESS) {
if (hrasConn.getValue() != null)
Rasapi32.INSTANCE.RasHangUp(hrasConn.getValue());
throw new Ras32Exception(err);
}
return hrasConn.getValue();
}
use of com.sun.jna.platform.win32.WinRas.RASDIALPARAMS in project jna by java-native-access.
the class Rasapi32Util method dialEntry.
/**
* Dial a phone book entry by name (Synchronously)
* @param entryName The phone book entry name
* @return result reference
* @throws Ras32Exception errors
*/
public static HANDLE dialEntry(String entryName) throws Ras32Exception {
// get the RAS Credentials
RASCREDENTIALS.ByReference credentials = new RASCREDENTIALS.ByReference();
synchronized (phoneBookMutex) {
credentials.dwMask = WinRas.RASCM_UserName | WinRas.RASCM_Password | WinRas.RASCM_Domain;
int err = Rasapi32.INSTANCE.RasGetCredentials(null, entryName, credentials);
if (err != WinError.ERROR_SUCCESS)
throw new Ras32Exception(err);
}
// set the dialing parameters
RASDIALPARAMS.ByReference rasDialParams = new RASDIALPARAMS.ByReference();
System.arraycopy(entryName.toCharArray(), 0, rasDialParams.szEntryName, 0, entryName.length());
System.arraycopy(credentials.szUserName, 0, rasDialParams.szUserName, 0, credentials.szUserName.length);
System.arraycopy(credentials.szPassword, 0, rasDialParams.szPassword, 0, credentials.szPassword.length);
System.arraycopy(credentials.szDomain, 0, rasDialParams.szDomain, 0, credentials.szDomain.length);
// dial
HANDLEByReference hrasConn = new HANDLEByReference();
int err = Rasapi32.INSTANCE.RasDial(null, null, rasDialParams, 0, null, hrasConn);
if (err != WinError.ERROR_SUCCESS) {
if (hrasConn.getValue() != null)
Rasapi32.INSTANCE.RasHangUp(hrasConn.getValue());
throw new Ras32Exception(err);
}
return hrasConn.getValue();
}
use of com.sun.jna.platform.win32.WinRas.RASDIALPARAMS in project jna by java-native-access.
the class Rasapi32Test method testRasGetEntryDialParams.
public void testRasGetEntryDialParams() {
RASDIALPARAMS.ByReference rasDialParams = new RASDIALPARAMS.ByReference();
System.arraycopy(rasDialParams.szEntryName, 0, "TEST".toCharArray(), 0, "TEST".length());
BOOLByReference lpfPassword = new BOOLByReference();
int err = Rasapi32.INSTANCE.RasGetEntryDialParams(null, rasDialParams, lpfPassword);
assertEquals(623, err);
}
Aggregations