تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] طلب تعديل كود من c# الي vb وبعض التعديلات
#2
كود :
Imports Ionic.Zip
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Drawing
Imports System.IO
Imports System.Linq
Imports System.Windows.Forms
Imports System.Collections.Generic
Imports System.Data
Imports System.Text
Imports System.Threading.Tasks
Imports System.Text.RegularExpressions

Partial Public Class Form1
   Inherits Form

   Public Sub New()
       InitializeComponent()
   End Sub

   Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
   End Sub

   Public Sub ExtractFileToDirectory(ByVal zipFileName As String, ByVal outputDirectory As String)
   End Sub

   Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
       Dim startupPath As String = Application.StartupPath
       Dim tempPath As String = Path.GetTempPath()

       If File.Exists(Application.StartupPath & "\libs1_updated.exe") Then

           If File.Exists(Application.StartupPath & "\libs1.exe") Then
               File.Delete(Application.StartupPath & "\libs1.exe")
           End If

           File.Move(Application.StartupPath & "\libs1_updated.exe", Application.StartupPath & "\libs1.exe")
       End If

       If File.Exists(Application.StartupPath & "\config.ini") AndAlso Directory.Exists(Application.StartupPath & "\BeinSave1") Then
           Dim text As String = File.ReadLines(Application.StartupPath & "\config.ini").First '.First(Of String)()
           Dim str As String = File.ReadLines(Application.StartupPath & "\config.ini").ElementAt(1)
           Directory.CreateDirectory(tempPath & "\Abdou")
           Dim text2 As String = tempPath & "Abdou1"

           If Not File.Exists(text2 & "\helper1.exe") Then

               Using zipFile As ZipFile = zipFile.Read("helper1.dll")
                   zipFile.Password = "abdoudodo1"
                   zipFile("helper1.exe").Extract(text2, ExtractExistingFileAction.OverwriteSilently)
               End Using
           End If

           Directory.CreateDirectory(tempPath & "\System36")
           Dim streamWriter As StreamWriter = New StreamWriter(tempPath & "\System36\check.ini")
           streamWriter.WriteLine("true")
           streamWriter.Close()
           streamWriter.Dispose()
           Dim pathRoot As String = Path.GetPathRoot(Environment.SystemDirectory)
           Dim baseDirectory As String = pathRoot & "ProgramData\Microsoft\PlayReady\"

           Try

               If Environment.OSVersion.Version.Major = 5 AndAlso Environment.OSVersion.Version.Minor = 1 Then
                   baseDirectory = pathRoot & "Documents and Settings\All Users\Application Data\Microsoft\PlayReady\"
               End If

           Catch
           End Try

           Using zipFile2 As ZipFile = ZipFile.Read(startupPath & "\BeinSave\" & str)
               zipFile2.Password = "stikstik"

               Try
                   Form1.killprocessPlayready()
                   zipFile2("mspr.hds").Extract(baseDirectory, ExtractExistingFileAction.OverwriteSilently)
               Catch
               End Try
           End Using

           Dim processStartInfo As ProcessStartInfo = New ProcessStartInfo()
           Me.Process1.StartInfo = processStartInfo
           processStartInfo.UseShellExecute = False
           processStartInfo.CreateNoWindow = True
           processStartInfo.RedirectStandardError = True
           processStartInfo.FileName = text2 & "\helper.exe"
           processStartInfo.Arguments = String.Concat(New String() {"/immediate /movetime ", text, " """, startupPath, "\libs.exe"""})
           Me.Process1.Start()
           MyBase.Close()
           Return
       End If

       If File.Exists(Application.StartupPath & "\config.ini") Then
           File.Delete(Application.StartupPath & "\config.ini")
       End If

       If File.Exists(Application.StartupPath & "\helper.dll") AndAlso File.Exists(Application.StartupPath & "\libs.exe") AndAlso File.Exists(Application.StartupPath & "\Ionic.Zip.dll") Then
           Directory.CreateDirectory(tempPath & "\System36")
           Dim streamWriter2 As StreamWriter = New StreamWriter(tempPath & "\System36\check.ini")
           streamWriter2.WriteLine("false")
           streamWriter2.Close()
           streamWriter2.Dispose()
           Process.Start("libs.exe")
           MyBase.Close()
           Return
       End If

       MessageBox.Show("helper.dll wla libs.exe makaynch", "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Hand)
       MyBase.Close()
   End Sub

   Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As FormClosedEventArgs)
       Try
           Me.Process1.Close()
       Catch
       End Try
   End Sub

   Public Shared Sub killprocessPlayready()
       Dim processes As Process() = Process.GetProcesses()

       For i As Integer = 0 To processes.Length - 1
           Dim process As Process = processes(i)

           Try

               For Each processModule As ProcessModule In process.Modules

                   If processModule.FileName.ToString().Contains("PlayReady") Then
                       process.Kill()

                       While Not process.HasExited
                           process.WaitForExit()
                       End While
                   End If
               Next

           Catch
           End Try
       Next
   End Sub

   Private Shared Sub deletePlayreadyFolder(ByVal masar As String)
       Dim directoryInfo As DirectoryInfo = New DirectoryInfo(masar)
       Dim files As FileInfo() = directoryInfo.GetFiles()

       For i As Integer = 0 To files.Length - 1
           Dim fileInfo As FileInfo = files(i)
           fileInfo.Delete()
       Next

       Dim directories As DirectoryInfo() = directoryInfo.GetDirectories()

       For j As Integer = 0 To directories.Length - 1
           Dim directoryInfo2 As DirectoryInfo = directories(j)
           directoryInfo2.Delete(True)
       Next
   End Sub

   Protected Overrides Sub Dispose(ByVal disposing As Boolean)
       If disposing AndAlso Me.components IsNot Nothing Then
           Me.components.Dispose()
       End If

       MyBase.Dispose(disposing)
   End Sub

   'Private Sub InitializeComponent()
   '    Dim componentResourceManager As ComponentResourceManager = New ComponentResourceManager(GetType(Form1))
   '    Me.label1 = New Label()
   '    MyBase.SuspendLayout()
   '    Me.label1.AutoSize = True
   '    Me.label1.Font = New Font("Microsoft Sans Serif", 30.0F, FontStyle.Regular, GraphicsUnit.Point, 0)
   '    Me.label1.ForeColor = Color.Red
   '    Me.label1.Location = New Point(1, 16)
   '    Me.label1.Name = "label1"
   '    Me.label1.Size = New Size(581, 46)
   '    Me.label1.TabIndex = 0
   '    Me.label1.Text = "حدث خطأ ما المرجوا اعادة تشغيل البرنامج"
   '    MyBase.AutoScaleDimensions = New SizeF(6.0F, 13.0F)
   '    MyBase.AutoScaleMode = AutoScaleMode.Font
   '    MyBase.AutoSizeMode = AutoSizeMode.GrowAndShrink
   '    Me.BackColor = SystemColors.ActiveCaptionText
   '    MyBase.ClientSize = New Size(584, 74)
   '    MyBase.Controls.Add(Me.label1)
   '    MyBase.FormBorderStyle = FormBorderStyle.SizableToolWindow
   '    MyBase.Icon = CType(componentResourceManager.GetObject("$this.Icon"), Icon)
   '    MyBase.Name = "Form1"
   '    AddHandler MyBase.FormClosed, New FormClosedEventHandler(AddressOf Me.Form1_FormClosed)
   '    AddHandler MyBase.Load, New EventHandler(AddressOf Me.Form1_Load)
   '    MyBase.ResumeLayout(False)
   '    MyBase.PerformLayout()
   'End Sub
End Class
الرد }}}
تم الشكر بواسطة: ScreamVoice , ScreamVoice , rnmr , rnmr , elgokr , محمد كريّم


الردود في هذا الموضوع
RE: طلب تعديل كود من c# الي vb وبعض التعديلات - بواسطة asemshahen5 - 27-10-18, 10:05 PM


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم