المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Auto Dial-Up Method not working on 64-bit machine



C# Programming
05-06-2013, 09:25 AM
Here is the method auto dial up without the login dialoge
public uint Connect(string EntryName, string UserName, string Password, out IntPtr RasConn){ uint retVal; uint r=0; RasConn=IntPtr.Zero; byte[] bRASDIALPARAMS =new byte[1464]; fixed (byte* pAddr = bRASDIALPARAMS) { byte* pCurrent = pAddr; Marshal.WriteInt32((IntPtr)pCurrent, bRASDIALPARAMS.Length); pCurrent += 4; foreach (byte b in Encoding.Unicode.GetBytes(EntryName)) { Marshal.WriteByte((IntPtr)pCurrent, b); pCurrent++; } pCurrent = pAddr + 0x192;//0x192 - offset for RASDIALPARAMS.UserName foreach (byte b in Encoding.Unicode.GetBytes(UserName)) { Marshal.WriteByte((IntPtr)pCurrent, b); pCurrent++; } pCurrent = pAddr + 0x394;//0x394 - offset for RASDIALPARAMS.Password foreach (byte b in Encoding.Unicode.GetBytes(Password)) { Marshal.WriteByte((IntPtr)pCurrent, b); pCurrent++; } retVal = RAS.RasDial(IntPtr.Zero, IntPtr.Zero, (IntPtr)pAddr, 0, IntPtr.Zero, ref RasConn); } return retVal;} [DllImport("rasapi32.dll", CharSet = CharSet.Auto)]public extern static uint RasDial( IntPtr dialExtensions, IntPtr phoneBookPath, IntPtr rasDialParam, uint NotifierType, IntPtr notifier, ref IntPtr pRasConn );


It works fine on my xp machine,but move it to win7 the Connect() method returns erro 632,what's wrong in win7,does anyone have a clue? http://www.barakasoft.com/script/Forums/Images/smiley_cry.gif