You are on page 1of 1

Imports System.CodeDom.

Compiler
Imports System.Runtime.CompilerServices

Module Compiler
Sub Compile(ByVal Source As String, ByVal Output As String, Optional icon As
String = "")
Dim providerOptions As New Dictionary(Of String, String)
providerOptions.Add("CompilerVersion", "v2.0")
Dim provider As New VBCodeProvider(providerOptions)
Dim options As New CompilerParameters
options.GenerateExecutable = True
options.OutputAssembly = Output
options.IncludeDebugInformation = True
options.ReferencedAssemblies.Add("System.dll")
options.ReferencedAssemblies.Add("System.Data.dll")
options.ReferencedAssemblies.Add("System.Windows.Forms.dll")
options.ReferencedAssemblies.Add("System.Management.dll")
options.CompilerOptions = "/filealign:0x00000200 /optimize+
/platform:X86 /debug- /target:winexe"
Dim parameters2 As CompilerParameters = options
If icon <> "" Then
parameters2.CompilerOptions = (parameters2.CompilerOptions & "
/win32icon:" & icon)
End If
Dim results As CompilerResults =
provider.CompileAssemblyFromSource(options, New String() {Source})
If Not (results.Errors.Count <= 0) Then
Dim enumerator As IEnumerator = results.Errors.GetEnumerator
Do While enumerator.MoveNext
Dim objectValue As Object =
RuntimeHelpers.GetObjectValue(enumerator.Current)

Interaction.MsgBox(objectValue.ToString, MsgBoxStyle.Critical)
Loop
If TypeOf enumerator Is IDisposable Then
TryCast(enumerator, IDisposable).Dispose()
End If
End If
End Sub
End Module

��� ��� ������� ���� ��� ����� exe ����� ���������

��� Visual Basic


?
1
Compile(Source,Output,Icon)

�� �������
Source : ������ ���� ���� ��� ������ ��
Output : ���� �����
Icon : ��� ������� ���� ��������

����� ����� ��� �� ������ ��� ����� �� ���� ��� ���� �� ...

����� �� ���� �����

You might also like