From our Instant C# VB.NET to C# converter:
(note that you can keep using the explicit System types - e.g., Int32)
public struct NETRESOURCE
{
public Int32 dwScope;
public Int32 dwType;
public Int32 dwDisplayType;
public Int32 dwUsage;
public string lpLocalName;
public string lpRemoteName;
public string lpComment;
public string lpProvider;
}
//
public const Int32 NO_ERROR = 0;
public const Int32 CONNECT_UPDATE_PROFILE = 0X1;
public const Int32 RESOURCETYPE_DISK = 0X1;
//
[System.Runtime.InteropServices.DllImport("mpr.dll" ,
EntryPoint="WNetAddConnection2A", ExactSpelling=false,
CharSet=System.Runtime.InteropServices.CharSet.Ans i, SetLastError=true)]
public static extern Int32 WNetAddConnection2(ref NETRESOURCE
lpNetResource, [MarshalAs(UnmanagedType.LPStr)] string lpPassword,
[MarshalAs(UnmanagedType.LPStr)] string lpUserName, Int32 dwFlags);
//
[System.Runtime.InteropServices.DllImport("mpr.dll" ,
EntryPoint="WNetCancelConnection2A", ExactSpelling=false,
CharSet=System.Runtime.InteropServices.CharSet.Ans i, SetLastError=true)]
public static extern long WNetCancelConnection2(string lpName, long
dwFlags, long fForce);
David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter
"Gee" wrote:
Hi
Can anyone help me convert this to C# please?
Structure NETRESOURCE
Public dwScope As Int32
Public dwType As Int32
Public dwDisplayType As Int32
Public dwUsage As Int32
Public lpLocalName As String
Public lpRemoteName As String
Public lpComment As String
Public lpProvider As String
End Structure
'
Public Const NO_ERROR As Int32 = 0
Public Const CONNECT_UPDATE_PROFILE As Int32 = &H1
Public Const RESOURCETYPE_DISK As Int32 = &H1
'
Declare Function WNetAddConnection2 Lib "mpr.dll" Alias _
"WNetAddConnection2A" (ByRef lpNetResource As NETRESOURCE, _
<MarshalAs(UnmanagedType.LPStr)> ByVal lpPassword As String, _
<MarshalAs(UnmanagedType.LPStr)> ByVal lpUserName As String, _
ByVal dwFlags As Int32) As Int32
'
Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias _
"WNetCancelConnection2A" (ByVal lpName As String, _
ByVal dwFlags As Long, ByVal fForce As Long) As Long
Thanks,
-Gee.