Click here to Skip to main content
15,902,276 members
Home / Discussions / C#
   

C#

 
GeneralRe: Remote Directory Information Pin
D Shen5-Sep-02 9:18
D Shen5-Sep-02 9:18 
GeneralAssembly.LoadFrom using a network share... Pin
Ryan Cromwell4-Sep-02 2:14
Ryan Cromwell4-Sep-02 2:14 
GeneralRe: Assembly.LoadFrom using a network share... Pin
Philip Fitzsimons4-Sep-02 2:21
Philip Fitzsimons4-Sep-02 2:21 
GeneralRe: Assembly.LoadFrom using a network share... Pin
Ryan Cromwell4-Sep-02 3:07
Ryan Cromwell4-Sep-02 3:07 
GeneralRe: Assembly.LoadFrom using a network share... Pin
Philip Fitzsimons4-Sep-02 3:09
Philip Fitzsimons4-Sep-02 3:09 
GeneralRe: Assembly.LoadFrom using a network share... Pin
Ryan Cromwell5-Sep-02 2:37
Ryan Cromwell5-Sep-02 2:37 
GeneralRe: Assembly.LoadFrom using a network share... Pin
leppie4-Sep-02 5:14
leppie4-Sep-02 5:14 
GeneralMarshalling: Rasap32.dll : EnumEntries Pin
leppie3-Sep-02 23:12
leppie3-Sep-02 23:12 
Hi all

This does not seem to work, very weird. The function returns 632 which translates to "An incorrect structure size was detected". Now this is the definition of the Structure according to MSDN and header file.

typedef struct _RASENTRYNAME { 
  DWORD  dwSize; 
  TCHAR  szEntryName[RAS_MaxEntryName + 1]; 
#if (WINVER >= 0x500)
  DWORD dwFlags;
  TCHAR  szPhonebookPath[MAX_PATH + 1];
#endif
} RASENTRYNAME; 


I definine as :

[StructLayout(LayoutKind.Sequential)]
public class RASENTRYNAME 
{ 
	public int  dwSize; 
	[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)Max.MaxEntryName + 1)]
	public string  szEntryName; 
	public int dwFlags;
	[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256 + 1)]
	public string  szPhonebookPath;
}


The function def:

[DllImport("rasapi32", EntryPoint = "RasEnumEntries", CharSet = CharSet.Ansi)]
public static extern int EnumEntries(object menull, System.Text.StringBuilder phonebookpath,[In, Out] IntPtr rasentry, ref int size, out int entries);


And use it as :

RASENTRYNAME rasentry = new RASENTRYNAME();
size = rasentry.dwSize = Marshal.SizeOf(typeof(RASENTRYNAME));
size *= 10; //this is dumb, but we have to "guess" buffer size or specify enough size, same below
IntPtr prasentry = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(RASENTRYNAME)) * 10);
first = prasentry;
Marshal.StructureToPtr(rasentry, prasentry, true);
result = RASWrapper.EnumEntries(null, null, prasentry, ref size, out numcon);
for (int i = 0; i < numcon; i++)
{
	Marshal.PtrToStructure(prasentry,rasentry); 
	prasentry = new IntPtr(prasentry.ToInt32() + Marshal.SizeOf(typeof(RASENTRYNAME)));
}
Marshal.FreeHGlobal(first);


The other Enum functions in the DLL works fine, RasEnumConnections & RasEnumDevices, using the same code structure. Giving me correct values and doing exactly what it should.

I have tried everything (no kidding), but what is wrong here? Is the DLL broken?

Thanx all Smile | :)

MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc
for more info. Big Grin | :-D
GeneralRe: Marshalling: Rasap32.dll : EnumEntries Pin
Stephane Rodriguez.3-Sep-02 23:29
Stephane Rodriguez.3-Sep-02 23:29 
GeneralRe: Marshalling: Rasap32.dll : EnumEntries Pin
leppie3-Sep-02 23:43
leppie3-Sep-02 23:43 
GeneralRe: Marshalling: Rasap32.dll : EnumEntries Pin
Stephane Rodriguez.3-Sep-02 23:59
Stephane Rodriguez.3-Sep-02 23:59 
GeneralRe: Marshalling: Rasap32.dll : EnumEntries Pin
leppie4-Sep-02 0:16
leppie4-Sep-02 0:16 
GeneralRe: Marshalling: Rasap32.dll : EnumEntries Pin
Stephane Rodriguez.4-Sep-02 0:25
Stephane Rodriguez.4-Sep-02 0:25 
GeneralRe: Marshalling: Rasap32.dll : EnumEntries Pin
leppie4-Sep-02 0:48
leppie4-Sep-02 0:48 
GeneralRe: Marshalling: Rasap32.dll : EnumEntries Pin
Stephane Rodriguez.4-Sep-02 1:24
Stephane Rodriguez.4-Sep-02 1:24 
GeneralRe: Marshalling: Rasap32.dll : EnumEntries Pin
leppie4-Sep-02 1:48
leppie4-Sep-02 1:48 
GeneralRe: Marshalling: Rasap32.dll : EnumEntries Pin
leppie4-Sep-02 1:55
leppie4-Sep-02 1:55 
GeneralRe: Marshalling: Rasap32.dll : EnumEntries Pin
Stephane Rodriguez.4-Sep-02 2:13
Stephane Rodriguez.4-Sep-02 2:13 
GeneralRe: Marshalling: Rasap32.dll : EnumEntries Pin
leppie4-Sep-02 2:32
leppie4-Sep-02 2:32 
GeneralRe: Marshalling: Rasap32.dll : EnumEntries Pin
leppie4-Sep-02 2:38
leppie4-Sep-02 2:38 
GeneralSOLVED HALELUJAH Pin
leppie4-Sep-02 2:52
leppie4-Sep-02 2:52 
GeneralRe: SOLVED HALELUJAH Pin
Stephane Rodriguez.4-Sep-02 3:06
Stephane Rodriguez.4-Sep-02 3:06 
GeneralError with shdocvw.dll, while building a .msi Pin
troz3-Sep-02 22:19
troz3-Sep-02 22:19 
GeneralRe: Error with shdocvw.dll, while building a .msi Pin
leppie3-Sep-02 22:48
leppie3-Sep-02 22:48 
GeneralRe: Error with shdocvw.dll, while building a .msi Pin
troz3-Sep-02 23:08
troz3-Sep-02 23:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.