Visual Studio.net(2003)自带的编译器有vbc,csc等(用编译器,做出的程序,所占用的资源是最少)
可在盘(如:c:\)根目录下,新建---记事本(mycomputer.txt)--在该记事本里编写代码如下:
imports system
imports system.drawing
imports System.Windows.Forms
class exp
inherits form
shared sub main()
application.run(new exp())
end sub
#region "the detail developing course of new products..."
public sub new()
mybase.new()
initial()
end sub
private components as system.componentmodel.icontainer
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents DriveListBox1 As Microsoft.VisualBasic.Compatibility.VB6.DriveListBox
Friend WithEvents DirListBox1 As Microsoft.VisualBasic.Compatibility.VB6.DirListBox
Friend WithEvents FileListBox1 As Microsoft.VisualBasic.Compatibility.VB6.FileListBox
Friend WithEvents Timer1 As System.Windows.Forms.Timer
friend withevents timer2 as system.windows.forms.timer
Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
friend withevents contextmenu2 as system.windows.forms.contextmenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
friend withevents menuitem2 as system.windows.forms.menuitem
friend withevents menuitem3 as system.windows.forms.menuitem
friend withevents menuitem4 as system.windows.forms.menuitem
Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
friend withevents textbox2 as system.windows.forms.textbox
Friend WithEvents Label1 As System.Windows.Forms.Label
friend withevents label2 as system.windows.forms.label
friend withevents mybtn1 as system.windows.forms.button
<System.Diagnostics.DebuggerStepThrough()> Private Sub initial()
Me.components = New System.ComponentModel.Container
Me.Label1 = New System.Windows.Forms.Label
me.label2 = new system.windows.forms.label
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
me.timer2 = new system.windows.forms.timer(me.components)
Me.DriveListBox1 = New Microsoft.VisualBasic.Compatibility.VB6.DriveListBox
Me.DirListBox1 = New Microsoft.VisualBasic.Compatibility.VB6.DirListBox
Me.FileListBox1 = New Microsoft.VisualBasic.Compatibility.VB6.FileListBox
Me.ContextMenu1 = New System.Windows.Forms.ContextMenu
me.contextmenu2 = new system.windows.forms.contextmenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
me.menuitem2 = new system.windows.forms.menuitem
me.menuitem3 = new system.windows.forms.menuitem
me.menuitem4 = new system.windows.forms.menuitem
me.textbox2 = new system.windows.forms.textbox
me.mybtn1 = new system.windows.forms.button
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
Me.SuspendLayout()
Me.Timer1.Enabled = True
Me.Timer1.Interval = 2008
me.timer2.enabled =true
me.timer2.interval=1000
Me.DriveListBox1.Location = New System.Drawing.Point(232, 32)
Me.DriveListBox1.Name = "DriveListBox1"
Me.DriveListBox1.Size = New System.Drawing.Size(280, 22)
Me.DriveListBox1.TabIndex = 0
Me.DirListBox1.IntegralHeight = False
Me.DirListBox1.Location = New System.Drawing.Point(232, 56)
Me.DirListBox1.Name = "DirListBox1"
Me.DirListBox1.Size = New System.Drawing.Size(280, 120)
Me.DirListBox1.TabIndex = 1
Me.FileListBox1.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.FileListBox1.Location = New System.Drawing.Point(232, 176)
Me.FileListBox1.MultiColumn = True
Me.FileListBox1.Name = "FileListBox1"
Me.FileListBox1.Pattern = "*.*"
Me.FileListBox1.ScrollAlwaysVisible = True
Me.FileListBox1.Size = New System.Drawing.Size(280, 192)
Me.FileListBox1.TabIndex =2
Me.Label2.Location = New System.Drawing.Point(8, 392)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(504, 40)
Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1,me.menuitem2})
me.contextmenu2.menuitems.addrange(new system.windows.forms.menuitem(){me.menuitem3,me.menuitem4})
Me.MenuItem1.Text = "open"
me.menuitem2.text="Exit"
me.menuitem3.text = "Exit"
me.menuitem4.text="about"
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("宋体", 17.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label1.Location = New System.Drawing.Point(10, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(216, 80)
me.textbox2.text=""
me.textbox2.name="textbox2"
me.textbox2.location=new system.drawing.point(10,230)
me.textbox2.size=new system.drawing.size(120,27)
Me.textbox2.TabIndex =3
me.tooltip1.settooltip(me.textbox2,"输入系统自带可运行文件然后按ALT+R----实现的功能如:开始---运行--- ---确定--回车")
me.mybtn1.text="&Run"
me.mybtn1.name="mybtn1"
me.mybtn1.location=new system.drawing.point(10,270)
me.mybtn1.size=new system.drawing.size(66,27)
me.tooltip1.settooltip(me.mybtn1,"在上面的文本框中输入系统可执行文件或具体地址全称 然后按ALT+R 或点击我" & microsoft.VisualBasic.ControlChars.NewLine & "^_^实现的功能如:开始---运行--- ---确定--回车")
me.mybtn1.flatstyle =system.windows.forms.flatstyle.popup
Me.mybtn1.TabIndex =4
Me.ToolTip1.Active = true
Me.ToolTip1.AutoPopDelay = 50000
Me.ToolTip1.InitialDelay = 50000
Me.ToolTip1.ReshowDelay = 100
Me.ClientSize = New System.Drawing.Size(512, 438)
Me.MaximizeBox = False
Me.StartPosition = FormStartPosition.CenterScreen
Me.ShowInTaskbar = False
Me.FormBorderStyle = FormBorderStyle.Fixed3D
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.FileListBox1)
Me.Controls.Add(Me.DirListBox1)
Me.Controls.Add(Me.DriveListBox1)
Me.Controls.Add(Me.Label1)
me.controls.add(me.textbox2)
me.controls.add(me.mybtn1)
Me.Name = "Form1"
Me.Text = "welcome to the very works product workstation..."
Me.ToolTip1.settooltip(me,"welcome to share public knowledge")
Me.ResumeLayout(False)
end sub
#end region
Private check As Boolean
public sharedstr as string
public sub msgstr(byval str as string)
System.Windows.Forms.MessageBox.Show("信息提示您:" & microsoft.VisualBasic.ControlChars.NewLine & str & microsoft.VisualBasic.ControlChars.NewLine & " ^_^!","welcome to my work product office!" )
end sub
private sub exp_load(byval obj as system.object,byval e as eventargs)handles mybase.load
try
me.contextmenu=contextmenu2
me.mybtn1.visible=true
me.textbox2.focus()
me.tooltip1.settooltip(FileListBox1,"双击,右击,选择后可按ENTER键 即实现 ---简易资源管理器" & microsoft.VisualBasic.ControlChars.NewLine & "给一个微笑,会祝(助)你万事如意!")
try
me.focus()
me.show()
catch ex as exception
System.Windows.Forms.MessageBox.Show("请先安装,.net产品所需要的软件---dotnetfx.exe" & microsoft.VisualBasic.ControlChars.NewLine & ex.Message)
end try
catch sysex as systemexception
msgstr(sysex.message)
finally
me.show()
end try
end sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If check Then
Label1.Text = "欢迎来到 无尘坡 工作室"
check = False
Else
Label1.Text = "We are the best creater!"
check = True
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
me.text=microsoft.visualbasic.right(me.text,me.text.length-1) & microsoft.visualbasic.left(me.text,1)
End Sub
Private Sub DriveListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DriveListBox1.SelectedIndexChanged
Try
DirListBox1.Path = DriveListBox1.Drive
FileListBox1.Items.Clear()
me.label2.text=""
Catch ex As Exception
system.windows.forms.MessageBox.Show("本计算机没有该驱动器,请确认后重试:" & ex.Message, "系统信息,请检测:")
End Try
End Sub
Private Sub DirListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DirListBox1.SelectedIndexChanged
try
microsoft.visualbasic.ChDir(DirListBox1.Path)
FileListBox1.Path = DirListBox1.Path
catch ex as exception
msgstr(ex.message)
end try
End Sub
Private Sub FileListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileListBox1.SelectedIndexChanged
try
Label2.Text = DirListBox1.Path + "\" + FileListBox1.FileName
FileListBox1.Select()
FileListBox1.ContextMenu = ContextMenu1
catch ex as exception
msgstr(ex.message)
end try
End Sub
Private Sub FileListBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FileListBox1.Click
try
Label2.Text = "你选择了: " & DirListBox1.Path + "\" + FileListBox1.FileName & microsoft.visualbasic.controlchars.newline & "要打开,请双击,按回车或右击选择open"
catch ex as exception
msgstr(ex.message)
end try
End Sub
Private Sub FileListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles FileListBox1.DoubleClick
Try
System.Diagnostics.Process.Start(DirListBox1.Path + "\" + FileListBox1.FileName)
Catch ex As Exception
msgstr(ex.message)
End Try
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Try
System.Diagnostics.Process.Start(DirListBox1.Path + "\" + FileListBox1.FileName)
Catch ex As Exception
msgstr(ex.message)
End Try
End Sub
Private Sub FileListBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles FileListBox1.KeyPress
Dim keyascii As Integer =Microsoft.VisualBasic.Asc(e.KeyChar)
If keyascii = 13 Then
Try
System.Diagnostics.Process.Start(DirListBox1.Path + "\" + FileListBox1.FileName)
Catch ex As Exception
msgstr(ex.message)
End Try
End If
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
e.cancel=true
End Sub
private sub menuitem2_click(byval obj as system.object,byval e as system.eventargs)handles menuitem2.click
If MessageBox.Show("确定要退出本应用程序吗?", "欢迎光临--无尘坡工作室", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Information) = System.Windows.Forms.DialogResult.OK Then
end
Else
me.focus()
end if
end sub
private sub menuitem3_click(byval obj as system.object,byval e as system.eventargs)handles menuitem3.click
If MessageBox.Show("确定要退出本应用程序吗?", "欢迎光临--无尘坡工作室", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Information) = System.Windows.Forms.DialogResult.OK Then
end
Else
me.focus()
end if
end sub
private sub mybtn1_click(byval obj as system.object,byval e as system.eventargs)handles mybtn1.click
if not(textbox2.text is nothing) then
sharedstr=microsoft.VisualBasic.Trim(textbox2.text.tostring())
try
Dim myProcess As New System.Diagnostics.Process
myProcess.StartInfo.FileName = sharedstr
myprocess.start(sharedstr)
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized
myProcess.StartInfo.Arguments = "c:\autoexec.bat"
myProcess.Start()
Console.Read()
myProcess.Kill()
catch ex as exception
msgstr(ex.message)
finally
me.textbox2.focus()
me.TextBox2.SelectAll()
end try
end if
end sub
private sub menuitem4_click(byval obj as system.object,byval e as system.eventargs) handles menuitem4.click
try
system.windows.forms.messagebox.show("作者: " & "无尘坡" & microsoft.visualbasic.controlchars.newline & "QQ: " & "*********" & microsoft.visualbasic.controlchars.newline & _
"发布日期: " & "2006年4月2日" & microsoft.visualbasic.controlchars.newline & "邮箱: " & "dreamedtrue@yahoo.com.cn","欢迎来到----无尘坡工作室!",system.windows.forms.messageboxbuttons.ok,system.Windows.Forms.MessageBoxIcon.Information)
catch ex as exception
msgstr(ex.message)
end try
end sub
private sub textbox2_click(byval obj as system.object,byval e as system.eventargs) handles textbox2.click
me.textbox2.focus()
me.textbox2.selectall()
end sub
end class
然后:打开visual basic.net 2003 命令提示符,输入:
vbc /r:system.dll,system.windows.forms.dll,system.drawing.dll,microsoft.visualbasic.dll,microsoft.visualbasic.compatibility.dll /t:winexe /out:c:\mycomputer.exe c:\mycomputer.txt /verbose
回车
即可在c:\下看到mycomputer.exe(双击即可运行)
[此贴子已经被作者于2006-4-3 6:41:54编辑过]