473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do I marshal RASENTRYDLG in C#

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!

Aug 15 '07 #1
0 1037

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: syd | last post by:
Hello all, In my project, I have container classes holding lists of item classes. For example, a container class myLibrary might hold a list of item classes myNation and associated variables...
13
by: Just Me | last post by:
The following almost works. The problem is Marshal.PtrToStringAuto seems to terminate at the first null so I don't get the full string. Any suggestions on how to fix this? Or how to improve the...
6
by: william.thorpe.b | last post by:
I have recently switched from VS2003 to VS2005 and at the same time from V1 to V2 of the .NET Compact Framework. The target is a Windows CE 5.0 device and an ARMV4I processor. ...
2
by: Pierre Rouleau | last post by:
Hi all, When using Python 2.4.x on a Win32 box, marshal.loads(marshal.dumps(1e66666)) returns 1.0 instead of infinity as it should and does under Python 2.5 (also running on Win32 ). This...
5
by: Anurag | last post by:
I have been chasing a problem in my code since hours and it bolis down to this import marshal marshal.dumps(str(123)) != marshal.dumps(str("123")) Can someone please tell me why? when...
2
by: O.B. | last post by:
When using Marshal to copy data from a byte array to the structure below, only the first byte of the "other" array is getting copied from the original byte array. What do I need to specify to get...
0
by: Charming12 | last post by:
Hi All, I have a strange problem and due to my inefficiency with IntPtr i am unable to figure it out. I have an structure something like: public struct Detail { public int age; public...
0
by: xrxst32 | last post by:
Hello there, I have some doubts about the best practice for using COM automation, the Runtime Callable Wrapper (RCW) and Marshal.ReleaseComObject. So the question is/are: Do I need to release...
2
by: O.B. | last post by:
I have operation within a class that marshals the data into a byte array. Below are three different ways that work. Are there any downsides to using one over the the other? public virtual byte...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.