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_DI SK = 0X1;
//
[System.Runtime. InteropServices .DllImport("mpr .dll",
EntryPoint="WNe tAddConnection2 A", ExactSpelling=f alse,
CharSet=System. Runtime.Interop Services.CharSe t.Ansi, SetLastError=tr ue)]
public static extern Int32 WNetAddConnecti on2(ref NETRESOURCE
lpNetResource, [MarshalAs(Unman agedType.LPStr)] string lpPassword,
[MarshalAs(Unman agedType.LPStr)] string lpUserName, Int32 dwFlags);
//
[System.Runtime. InteropServices .DllImport("mpr .dll",
EntryPoint="WNe tCancelConnecti on2A", ExactSpelling=f alse,
CharSet=System. Runtime.Interop Services.CharSe t.Ansi, SetLastError=tr ue)]
public static extern long WNetCancelConne ction2(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_DI SK As Int32 = &H1
'
Declare Function WNetAddConnecti on2 Lib "mpr.dll" Alias _
"WNetAddConnect ion2A" (ByRef lpNetResource As NETRESOURCE, _
<MarshalAs(Unma nagedType.LPStr )> ByVal lpPassword As String, _
<MarshalAs(Unma nagedType.LPStr )> ByVal lpUserName As String, _
ByVal dwFlags As Int32) As Int32
'
Declare Function WNetCancelConne ction2 Lib "mpr.dll" Alias _
"WNetCancelConn ection2A" (ByVal lpName As String, _
ByVal dwFlags As Long, ByVal fForce As Long) As Long
Thanks,
-Gee.