Here's a support file that we insert into some VB to C# conversions to cover
aspects of 'My' that aren't converted in-line:
//----------------------------------------------------------------------------------------
// Copyright © 2005 - 2007 Tangible Software Solutions Inc.
//
// This file provides classes to reproduce most of the My.Computer and My.User
// functionality in VB. Calls to My.Computer.Cli pboard,
My.Computer.Fil eSystem,
// and My.Computer.Reg istry have been converted where they were referenced.
//
// Note: My.Settings is converted elsewhere to the standard C#
Properties.Sett ings.
// Note: My.Resources is converted elsewhere to the standard C#
Properties.Reso urces.
// Note: My.Application calls are redirected to the converted
My.MyApplicatio n.
//----------------------------------------------------------------------------------------
using Microsoft.Visua lBasic.Applicat ionServices;
using Microsoft.Visua lBasic.Devices;
using System.Security .Principal;
using System.Windows. Forms;
namespace My
{
internal static class Computer
{
//Instant C# Notes:
//Calls to My.Computer.Cli pboard have been redirected to
System.Windows. Forms.Clipboard
//Calls to My.Computer.Fil eSystem have been redirected to
Microsoft.Visua lBasic.FileIO.F ileSystem
//Calls to My.Computer.Reg istry have been redirected to
Microsoft.Win32 .Registry
internal readonly static Audio Audio;
internal readonly static Clock Clock;
internal readonly static ComputerInfo Info;
internal readonly static Keyboard Keyboard;
internal readonly static Mouse Mouse;
internal readonly static string Name;
internal readonly static Network Network;
internal readonly static Ports Ports;
internal readonly static Screen Screen;
static Computer()
{
Audio = new Audio();
Clock = new Clock();
Info = new ComputerInfo();
Keyboard = new Keyboard();
Mouse = new Mouse();
Network = new Network();
Ports = new Ports();
Screen = Screen.PrimaryS creen;
ServerComputer ThisServerCompu ter = new ServerComputer( );
Name = ThisServerCompu ter.Name;
}
}
internal static class User
{
private static Microsoft.Visua lBasic.Applicat ionServices.Use r ThisUser =
new Microsoft.Visua lBasic.Applicat ionServices.Use r();
internal static IPrincipal CurrentPrincipa l
{
get
{
return ThisUser.Curren tPrincipal;
}
}
internal static bool IsAuthenticated
{
get
{
return ThisUser.IsAuth enticated;
}
}
internal static string Name
{
get
{
return ThisUser.Name;
}
}
internal static void InitializeWithW indowsUser()
{
ThisUser.Initia lizeWithWindows User();
}
internal static bool IsInRole(BuiltI nRole ThisRole)
{
return ThisUser.IsInRo le(ThisRole);
}
internal static bool IsInRole(string ThisRole)
{
return ThisUser.IsInRo le(ThisRole);
}
}
}
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
C++ to Ruby
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB or C# to C++/CLI
"Scott M." wrote:
I've tried following the simple instructions to be able to use MyServices
within C#...Add a project reference to Microsoft.Visua lBasic.dll and add:
"using Microsoft.Visua lBasic.MyServic es;" to the code module. After that, I
expected to be able to use MyClock or MyComputerInfo, but none of the "My"
stuff appears in the intellisense. I've tried rebuilding (after adding the
reference and the using statement) and still no luck.
What am I doing wrong?
-Scott