Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 4th, 2006, 08:01 AM
Registered User
Join Date: Aug 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help me i must convert Code vb to C#

Sub shutdown()
        Dim t As Single
        Dim objWMIService, objComputer As Object
        'Now get some privileges
        objWMIService = GetObject("Winmgmts:{impersonationLevel=impersonat e,(Debug,Shutdown)}")
        For Each objComputer In objWMIService.InstancesOf("Win32_OperatingSystem")

            t = objComputer.Win32Shutdown(8 + 4, 0)

            If t <> 0 Then
                'Error occurred!!!
                'Shutdown your system
            End If
    End Sub


Reply With Quote
  #2 (permalink)  
Old September 4th, 2006, 10:45 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

Come on, this is trivial, have you even TRIED to convert it yourself. (I am not in the business of doing peoples work for them, Advice is free though)

"The one language all programmers understand is profanity."
Reply With Quote
  #3 (permalink)  
Old October 3rd, 2006, 04:43 AM
Authorized User
Join Date: Jul 2006
Location: Schiedam, zuid holland, Netherlands.
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts

public void shutdown()
        float t = 0F;
        object objWMIService = null;
//INSTANT C# NOTE: Commented this declaration since looping variables in 'foreach' loops are declared in the 'foreach' header in C#
// object objComputer = null;
        //Now get some privileges
        objWMIService = Microsoft.VisualBasic.Interaction.GetObject("Winmg mts:{impersonationLevel=impersonate,(Debug,Shutdow n)}", null);
        foreach (object objComputer in objWMIService.InstancesOf("Win32_OperatingSystem") )

            t = objComputer.Win32Shutdown(8 + 4, 0);

            if (t != 0)
                //Error occurred!!!
                //Shutdown your system

I hope this helps

Reply With Quote
  #4 (permalink)  
Old October 14th, 2006, 12:54 AM
Registered User
Join Date: Oct 2006
Location: Ahmedabad, Gujarat, India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to shriji.1111

Use Convertor to generate c# code from vb

Brijesh Shah
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
convert dsr file from vb to vb.net Shashi001 VB Components 1 September 22nd, 2006 12:24 PM
Help me convert C# to VB minhtri Pro VB.NET 2002/2003 1 June 8th, 2006 01:32 PM
convert vba code to vb tommy03 VB How-To 3 February 23rd, 2005 02:13 PM
Convert VB to C# code skdp VS.NET 2002/2003 2 March 1st, 2004 11:45 PM

All times are GMT -4. The time now is 11:47 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.