473,667 Members | 2,670 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert VB.NET to C#.NET

Gee
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.

Nov 17 '05 #1
3 4744

"Gee" <em*******@emma nuelsolutions.c o.uk> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
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.


Off top of head:

struct NETRESOURCE {
public int dwScope;
public int dwType;
public int dwUsage;
public string lpLocalName;
public string lpRemoteName;
public string lpComment;
public string lpProvider;
}

public const int NO_ERROR = 0;
public const int CONNECT_UPDATE_ PROVILE = 0x1;
public const int RESOURCETYPE_DI SK = 0x1;

[DllImport("mpr. dll")]
public static extern int WNetAddConnecti on2(
ref NETRESOURCE lpNetResource,
[MarshalAs(Unman agedType.LPStr)] string lpPassword,
[MarshalAs(Unman agedType.LPStr)] string lpUserName,
int dwFlags
);

[DllImport("mpr. dll")]
public static extern int WNetCancelConne ction2(
string lpName,
int dwFlags,
int fForce
);
HTH :)

Mythran

Nov 17 '05 #2
Gee
Thanks for that Mythran!

Was a great help :-)

-Gee.

Nov 17 '05 #3
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.

Nov 17 '05 #4

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

Similar topics

19
7272
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below. Specifically, I have a problem with this portion in the WHERE clause: DATEADD(Day,tblMyEventTableName.ReminderDays, @DateNow) Between CONVERT(smalldatetime,str(DATEPART(Month, @DateNow)+1) + '/' + str(DATEPART(Day, tblMyEventTableName.TaskDateTime)) + '/'...
1
1787
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance would be identical. I was 100% incorrect. The code below produces the results: CType Took: 0.2187528 seconds. Convert Took: 12.187656 seconds.
4
3619
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is of the type the object is instantiated with. In my test program I have Option<std::string> and Option<long>. Here's the code for OptionBase and Option along with a small helper function. In the code are comments describing my problem, look closely...
7
7099
by: whatluo | last post by:
Hi, all I'm now working on a program which will convert dec number to hex and oct and bin respectively, I've checked the clc but with no luck, so can anybody give me a hit how to make this done without strtol or s/printf function. Thanks, whatluo.
3
10270
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function and there you have it. So I enquired and found the Convert class with it's promising ToInt32 method, great... but it doesn't work. The thing keeps throwing Format Exceptions all over the place. What is the "C#" way to do this??? code int wmin,...
7
29224
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
4
4514
by: Edwin Knoppert | last post by:
In my code i use the text from a textbox and convert it to a double value. I was using Convert.ToDouble() but i'm used to convert comma to dot. This way i can assure the text is correct. However it seems this convert is determined by the local settings and comma is indeed used as decimal separator. Is there another way to convert a dotted value to a double variable? Like 1234.5 and not 1234,5
1
3592
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in some files and work on it. Let say, I want add new page to web project named websiteOrder.sln, i will open websiteOrder.sln in my local computer, connected to websiteOrder.sln located in Visual Source Safe 6.0(source safe located in another...
6
4256
by: Ken Fine | last post by:
This is a basic question. What is the difference between casting and using the Convert.ToXXX methods, from the standpoint of the compiler, in terms of performance, and in other ways? e.g. this.ContentID = (int)ci.Conid; vs. this.ContentID = Convert.ToInt32(ci.Conid); I tend to use the latter form because it seems more descriptive to me, but it would be good to know what's best practice. I'm guessing those methods
0
10753
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
0
8458
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8650
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.