rasdial在x64位Vista和Windows XP上返回632 [英] rasdial returns 632 on x64 bit Vista nd Windows XP

查看:151
本文介绍了rasdial在x64位Vista和Windows XP上返回632的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在x64(AMD64)Vista和Windows上安装了32位应用程序

XP。 rasdial在x64机器上返回632 - ERROR_INVALID_SIZE;但

rasdial在32位机器上正确安装相同的32位应用程序

。任何线索?

I have a 32-bit application installed on x64 (AMD64) Vista and Windows
XP. The rasdial returns 632 - ERROR_INVALID_SIZE on x64 machine; but
the rasdial behaves properly installing the same 32-bit application on
a 32-bit machine. Any clue?

推荐答案

那么,你对RasDial的声明是什么?


- -

- Nicholas Paldino [.NET / C#MVP]

- mv * @ spam.guard.caspershouse.com


< hq **** @ hotmail.comwrote in message

news:11 *** ******************@e9g2000prf.googlegrou ps.com ...
Well, what is your declaration for RasDial?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<hq****@hotmail.comwrote in message
news:11*********************@e9g2000prf.googlegrou ps.com...

>我有一个32在x64(AMD64)Vista和Windows上安装的应用程序

XP。 rasdial在x64机器上返回632 - ERROR_INVALID_SIZE;但

rasdial在32位机器上正确安装相同的32位应用程序

。任何线索?
>I have a 32-bit application installed on x64 (AMD64) Vista and Windows
XP. The rasdial returns 632 - ERROR_INVALID_SIZE on x64 machine; but
the rasdial behaves properly installing the same 32-bit application on
a 32-bit machine. Any clue?



1。 Rasdial:


[DllImport(" rasapi32.dll",CharSet = CharSet.Auto)]

public extern static uint RasDial(

[In] RASDIALEXTENSIONS lpRasDialExtensions,

[In] string lpszPhonebook,

[In] RASDIALPARAMS lpRasDialParams,

uint dwNotifierType,

IntPtr lpvNotifier,

ref IntPtr lphRasConn

);


2. RASDIALPARAMS:


[StructLayout(LayoutKind.Sequential,CharSet = CharSet .Auto)]

公共类RASDIALPARAMS

{

public int dwSize = Marshal.SizeOf(typeof(RASDIALPARAMS));

[MarshalAs(UnmanagedType.ByValTStr,SizeConst = 256 + 1)]

public string szEntryName = null;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst = 128 + 1)]

public string szPhoneNumber = null;

[MarshalAs(UnmanagedType.ByValTStr) ,SizeConst = 128 + 1)]

public string szCallbackNumber = null;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst = 256 + 1)]

公共字符串szUserName = null;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst = 256 + 1)]

public string szPassword = null;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst = 15 + 1)]

public string szDomain = null;

public int dwSubEntry = 0;

public int dwCallbackId = 0;

}


3.用法:


RASDIALPARAMS rdp = new RASDIALPARAMS();

rdp.dwSize = Marshal.SizeOf(rdp);

rdp.szEntryName =" Entry Name;

IntPtr notifyHandle =(IntPtr)null;

IntPtr connectionHandle =(IntPtr)null;

uint dwSucc = RASWrapper.RasDial(null,null ,rdp,0xFFFFFFFF,

notifyHandle,ref connectionHandle);

1. Rasdial:

[DllImport("rasapi32.dll",CharSet=CharSet.Auto)]
public extern static uint RasDial(
[In]RASDIALEXTENSIONS lpRasDialExtensions,
[In]string lpszPhonebook,
[In]RASDIALPARAMS lpRasDialParams,
uint dwNotifierType,
IntPtr lpvNotifier,
ref IntPtr lphRasConn
);

2. RASDIALPARAMS:

[StructLayout(LayoutKind.Sequential,CharSet=CharSet .Auto)]
public class RASDIALPARAMS
{
public int dwSize=Marshal.SizeOf(typeof(RASDIALPARAMS));
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=256+1)]
public string szEntryName=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=128+1)]
public string szPhoneNumber=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=128+1)]
public string szCallbackNumber=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=256+1)]
public string szUserName=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=256+1)]
public string szPassword=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=15+1)]
public string szDomain=null;
public int dwSubEntry=0;
public int dwCallbackId=0;
}

3. Usage:

RASDIALPARAMS rdp = new RASDIALPARAMS();
rdp.dwSize = Marshal.SizeOf(rdp);
rdp.szEntryName = "Entry Name;
IntPtr notifyHandle = (IntPtr)null;
IntPtr connectionHandle = (IntPtr)null;
uint dwSucc = RASWrapper.RasDial(null, null, rdp, 0xFFFFFFFF,
notifyHandle, ref connectionHandle);


RASDIALEXTENSIONS的定义是什么?您是否正在使用课程来定义它?
?我是这样假设的,所以你可以传入null。


我必须注意的一件事是在RASDIALPARAMS中定义了dwCallbackId

字段结构体。你将它定义为一个int,当

它应该是一个IntPtr。这可能解释了为什么在调用64位平台时大小错误




假设字符串的所有长度都是正确的,这个应该是

这个问题。


-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


< ; hq **** @ hotmail.comwrote in message

news:11 ********************** @ y27g2000pre.googlegr oups .com ...
What is the definition of RASDIALEXTENSIONS? Are you using a class to
define it? I''m assuming so, so that you can pass null in.

One thing I definitely notice is the definition of the dwCallbackId
field in the RASDIALPARAMS structure. You are defining it as an int, when
it should be an IntPtr. This would probably explain why the size is wrong
when calling on a 64-bit platform.

Assuming that all the lengths to the strings are correct, this should be
the issue.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<hq****@hotmail.comwrote in message
news:11**********************@y27g2000pre.googlegr oups.com...

1. Rasdial:


[DllImport(" rasapi32.dll",CharSet = CharSet) .Auto)]

public extern static uint RasDial(

[In] RASDIALEXTENSIONS lpRasDialExtensions,

[In] string lpszPhonebook,

[In] RASDIALPARAMS lpRasDialParams,

uint dwNotifierType,

IntPtr lpvNotifier,

ref IntPtr lphRasConn

);


2. RASDIALPARAMS:< br $>

[StructLayout(LayoutKind.Sequential,CharSet = CharSet .Auto)]

公共类RASDIALPARAMS

{

public int dwSize = Marshal.SizeOf(typeof(RASDIALPARAMS));

[MarshalAs(UnmanagedType.ByValTStr,SizeConst = 256 + 1)]

public string szEntryName = null;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst = 128 + 1)]

public string szPhoneNumber = null;

[MarshalAs( UnmanagedType.ByValTStr,SizeConst = 128 + 1)]

public string szCallbackNumber = null;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst = 256 + 1)]

public string szUserName = null;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst = 256 + 1)]

公共字符串szPassword = null;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst = 15 + 1)]

public string szDomain = null;

public int dwSubEntry = 0;

public int dwCallbackId = 0;

}


3.用法:


RASDIALPARAMS rdp = new RASDIALPARAMS();

rdp.dwSize = Marshal.SizeOf(rdp);

rdp.szEntryName ="条目名称;

IntPtr notifyHandle =(IntPtr)null;

IntPtr connectionHandle =(IntPtr)null;

uint dwSucc = RASWrapper.RasDial(null,null,rdp,0xFFFFFFFF,
notifyHandle,ref connectionHandle);
1. Rasdial:

[DllImport("rasapi32.dll",CharSet=CharSet.Auto)]
public extern static uint RasDial(
[In]RASDIALEXTENSIONS lpRasDialExtensions,
[In]string lpszPhonebook,
[In]RASDIALPARAMS lpRasDialParams,
uint dwNotifierType,
IntPtr lpvNotifier,
ref IntPtr lphRasConn
);

2. RASDIALPARAMS:

[StructLayout(LayoutKind.Sequential,CharSet=CharSet .Auto)]
public class RASDIALPARAMS
{
public int dwSize=Marshal.SizeOf(typeof(RASDIALPARAMS));
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=256+1)]
public string szEntryName=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=128+1)]
public string szPhoneNumber=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=128+1)]
public string szCallbackNumber=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=256+1)]
public string szUserName=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=256+1)]
public string szPassword=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=15+1)]
public string szDomain=null;
public int dwSubEntry=0;
public int dwCallbackId=0;
}

3. Usage:

RASDIALPARAMS rdp = new RASDIALPARAMS();
rdp.dwSize = Marshal.SizeOf(rdp);
rdp.szEntryName = "Entry Name;
IntPtr notifyHandle = (IntPtr)null;
IntPtr connectionHandle = (IntPtr)null;
uint dwSucc = RASWrapper.RasDial(null, null, rdp, 0xFFFFFFFF,
notifyHandle, ref connectionHandle);



这篇关于rasdial在x64位Vista和Windows XP上返回632的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆