码迷,mamicode.com
首页 > 其他好文 > 详细

C 对Microsoft VisualBasic My对象兰台妙选【月儿原创】

时间:2019-03-02 18:47:32      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:段子   .post   oca   lin   vbs   for   protect   获取   能力   

C#对Microsoft.VisualBasic My对象兰台妙选

作者:清清月儿

主页:http://blog.csdn.net/21aspnet/           时间:2007.4.24

 1.添加引用
技术图片

2.引用Microsoft.VisualBasic 命名空间
技术图片

3.所有的My对象应用皆出自以下类库,本文仅抛砖引玉,更多请大家看MSDN
技术图片

4.应用-获取应用程序所在服务器信息
技术图片

说明:要添加using Microsoft.VisualBasic.Devices;
代码
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.VisualBasic.Devices;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
   
    protected void Button1_Click1(object sender, EventArgs e)
    {
        Microsoft.VisualBasic.Devices.Computer my = new Computer();
        TextBox1.Text = "机器名为:" + my.Name + "/r/n";
        TextBox1.Text += "操作系统信息为:" + my.Info.OSFullName +" "+my.Info.OSPlatform+" "+my.Info.OSVersion +"/r/n";
        TextBox1.Text += "物理内存为:" + my.Info.TotalPhysicalMemory + "/r/n";
        TextBox1.Text += "虚拟内存为:" + my.Info.TotalVirtualMemory + "/r/n";
        TextBox1.Text += "可用物理内存为:" + my.Info.AvailablePhysicalMemory + "/r/n";
        TextBox1.Text += "可用虚拟内存为:" + my.Info.AvailableVirtualMemory + "/r/n";    }
}

5.文件操作
技术图片

代码:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.VisualBasic.Devices;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
   
    protected void Button1_Click1(object sender, EventArgs e)
    {
        Microsoft.VisualBasic.Devices.Computer my = new Microsoft.VisualBasic.Devices.Computer();
        TextBox1.Text = my.FileSystem.ReadAllText(FileUpload1.PostedFile.FileName,Encoding.GetEncoding("gb2312"));
       
    }
}

6.读取系统注册表(这是最粗糙的读取,建议用递归+树形菜单展示全部
技术图片

代码
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.VisualBasic.Devices;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
   
   
    protected void Button1_Click(object sender, EventArgs e)
    {
        Microsoft.VisualBasic.Devices.Computer my = new Microsoft.VisualBasic.Devices.Computer();
        foreach (String k in my.Registry.CurrentUser.GetSubKeyNames())
        {
            TextBox1.Text += k + "/r/n";
        }

    }
}

可以Registry后点出ClassesRoot,LocalMachine等节点请自己尝试。

7.Microsoft.VisualBasic命名空间的字符串处理能力非常强大。
最常见的半角和全角互换,简体和繁体互换等等做起来非常轻松,既然可以这么轻松处理为什么要写很复杂的类呢?
技术图片

代码:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.VisualBasic;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
   
   
    protected void Button1_Click(object sender, EventArgs e)
    {
        TextBox2.Text = Strings.StrConv(TextBox1.Text, VbStrConv.Narrow, 0);
        TextBox4.Text = Strings.StrConv(TextBox3.Text, VbStrConv.TraditionalChinese, 0);

    }
}

 

VbStrConv.None

不执行任何转换

VbStrConv.LinguisticCasing

使用语言规则进行大小写,而不使用文件系统(默认)。仅当与 VbStrConv.UpperCase 和 VbStrConv.LowerCase 一起使用时才有效。

VbStrConv.UpperCase

将字符串转换为大写字符。

VbStrConv.LowerCase

将字符串转换为小写字符。

VbStrConv.ProperCase

将字符串中每个单词的第一个字母转换为大写。

VbStrConv.Wide *

将字符串中的窄(半角)字符转换为宽(全角)字符。

VbStrConv.Narrow *

将字符串中的宽(全角)字符转换为窄(半角)字符。

VbStrConv.Katakana **

将字符串中的平假名字符转换为片假名字符。

VbStrConv.Hiragana **

将字符串中的片假名字符转换为平假名字符。

VbStrConv.SimplifiedChinese *

将繁体中文字符转换为简体中文字符。

VbStrConv.TraditionalChinese *

将简体中文字符转换为繁体中文字符。

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net

C 对Microsoft VisualBasic My对象兰台妙选【月儿原创】

标签:段子   .post   oca   lin   vbs   for   protect   获取   能力   

原文地址:https://www.cnblogs.com/siwnchs/p/10462212.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!