Hi,
I am trying to call the Win32 function RasEntryDlg. In C, the function
and structure look like:
BOOL RasEntryDlg(
LPTSTR lpszPhonebook,
LPTSTR lpszEntry,
LPRASENTRYDLG lpInfo
);
typedef struct tagRASENTRYDLG {
IN DWORD dwSize;
IN HWND hwndOwner;
IN DWORD dwFlags;
IN LONG xDlg;
IN LONG yDlg;
OUT TCHAR szEntry[RAS_MaxEntryName + 1];
OUT DWORD dwError;
IN ULONG_PTR reserved;
IN ULONG_PRT reserved2;
} RASENTRYDLG;
And I defined the function and structure in C# as:
[DllImport("Rasdlg.dll", SetLastError = true, CharSet =
CharSet.Auto)]
public static extern bool RasEntryDlg(
string phoneBook,
string entryName,
ref RASENTRYDLG info);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct RASENTRYDLG
{
public int dwSize;
public IntPtr hwndOwner;
public int dwFlags;
public int xDlg;
public int yDlg;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=266)]
public char[] szEntry;
public int dwError;
public IntPtr reserved;
public IntPtr reserved2;
}
I passed Form.Handle as the hwndOwner and set the dwFlags to
RASEDFLAG_NewEntry. But the call to RasEntryDlg doesn't show the Ras
new phonebook entry dialog. The out parameter in RASENTRYDLG is not
modified either. (the return is false, but dwError = 0).
Is the C# part definitions correct? How to we define the OUT parameter
in the struct in C#?
Thanks!