Hello Alex,
Thank you for your reply. Unfortunately I still don't get it to work, I
still get an error-code 87 after calling RasGetEntryDialParams...
Can you see anything wrong from my code below???
Many thanks in advance,
Roberto.
[DllImport("coredll.dll", CharSet=CharSet.Auto, SetLastError=true)]
private static extern UInt32 RasGetEntryDialParams(
string lpszPhoneBook,
byte[] lpRasDialParams,
ref bool lpfPassword
);
public class RasDialParams : CustomMarshaler
{
private const int RAS_MaxEntryName = 20;
private const int RAS_MaxPhoneNumber = 128;
private const int RAS_MaxCallbackNumber = 48;
private const int UNLEN = 256;
private const int PWLEN = 256;
private const int DNLEN = 15;
public uint dwSize;
[CustomMarshalAs(SizeConst = RAS_MaxEntryName +1)]
public string szEntryName;
[CustomMarshalAs(SizeConst = RAS_MaxPhoneNumber +1)]
public string szPhoneNumber;
[CustomMarshalAs(SizeConst = RAS_MaxCallbackNumber +1)]
public string szCallbackNumber;
[CustomMarshalAs(SizeConst = UNLEN+1)]
public string szUserName;
[CustomMarshalAs(SizeConst = PWLEN+1)]
public string szPassword;
[CustomMarshalAs(SizeConst = DNLEN+1)]
public string szDomain;
public RasDialParams()
{
dwSize = (uint)GetSize();
this.data = new byte[dwSize];
//Write the dwSize into the byte array
this.Serialize();
}
}
private void button1_Click(object sender, System.EventArgs e)
{
RasDialParams DialParams = new RasDialParams();
bool Pass = true;
UInt32 ret = RasGetEntryDialParams ("Arcor", DialParams.ByteArray, ref
Pass); // Always returning with 87!!!
// Populate the fields from returned byte array
DialParams.Deserialize();
}