Run the C #. Net program without installing. NET Framework
First of all, it should be noted that Feixin is also written in C #, but we do not use installation when running C. net Framework. net Virtual program, which calls the main program of Apsara stack.
Similarly, we need to use this ready-made Virtual Machine to run our C #.. Net program. in netframework windows, you can also run C #.. Net program.
The specific method is as follows. Copy the vmdotnet/v2.0.50727file in the Apsara stack folder to your cve-netdirectory. The file contains a program fetionvm.exe, which is used to run my C # main program. The Calling method is as follows:
"Fetionvm.exe C # program path" (excluding quotation marks). Then, we only need to use C/C ++, VB, Delphi, and other Windows programs that run directly after class, write a program to call the virtual machine to run our C #.. Net program.
The following Delphi is an example:
First, the folder Name of the Virtual Machine under the program directory is vm, and the compiled C program name is acs.exe. The Delphi code is as follows:
Unit unit1;
Interface
Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs, registry;
Type
Tform1 = Class (tform)
Procedure formcreate (Sender: tobject );
Private
{Private Declarations}
Public
{Public declarations}
End;
VaR
Form1: tform1;
Implementation
{$ R *. DFM}
Procedure tform1.formcreate (Sender: tobject );
VaR
Reg: Tregistry;
Begin
Reg: = Tregistry. Create;
Reg. rootkey: = HKEY_LOCAL_MACHINE;
If Reg. keyexists ('Software/Microsoft /. netframework/v2.0.50727 ') Then // use the registry to determine whether the system is installed. if netframework V2.0 exists, run the C # program directly. If no, call the C # program through the VM.
Begin
Winexec ('./Vm/acs.exe', sw_show );
End
Else // call the virtual machine if the key value does not exist
Begin
Form1.visible: = false;
Winexec ('./Vm/fetionvm.exe./Vm/acs.exe', sw_show );
End;
Reg. closekey;
Reg. Free;
Exitprocess (0 );
Application. Terminate;
End;
End.
// ------------------------ Write the main program
Select project> View Source and add the statement.
Application. showmainform: = false; // hide the main program form
Then generate a program
Then put the EXE program produced by Delphi under the program directory and run it to directly call our C # Program
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/wazhpi/archive/2008/12/29/3634763.aspx