在没有.net framework框架的计算机上部署.net程序,只要写一个win32的引导程序,然后再这个程序中安装.net framework,安装了.net framework后,再运行.net下的打包文件就可以了。 本文的win32程序是使用vb6.0写的,文件夹组织: ---setup win32的exe程序 --huanjing dotNetFramework和mdac文件 --xfzj .net应用程序 --backup .net应用程序 引导程序代码如下:VERSION 5.00 Begin VB.Form Form1 Appearance = 0 'Flat BackColor = &H80000005& Caption = "安装徐房租监管理系统" ClientHeight = 5220 ClientLeft = 60 ClientTop = 450 ClientWidth = 4470 FillColor = &H008080FF& Icon = "Form1.frx":0000 LinkTopic = "Form1" MousePointer = 99 'Custom Picture = "Form1.frx":0442 ScaleHeight = 5220 ScaleWidth = 4470 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 BackColor = &H00FFFFFF& Caption = "安 装 运 行 环 境" Height = 375 Left = 1080 Style = 1 'Graphical TabIndex = 2 Top = 1560 Width = 2295 End Begin VB.CommandButton Command3 Appearance = 0 'Flat BackColor = &H00FFFFFF& Caption = "安装徐房租监备份系统" Height = 375 Left = 1080 Style = 1 'Graphical TabIndex = 1 Top = 3960 Width = 2250 End Begin VB.CommandButton Command2 Appearance = 0 'Flat BackColor = &H00FFFFFF& Caption = "安装徐房租监管理系统" Height = 375 Left = 1080 Style = 1 'Graphical TabIndex = 0 Top = 2880 Width = 2250 End Begin VB.Image Image3 Height = 1215 Left = 240 Picture = "Form1.frx":7C69 Top = 3720 Width = 3810 End Begin VB.Image Image2 Height = 1020 Left = 360 Picture = "Form1.frx":B109 Top = 2640 Width = 3825 End Begin VB.Image Image1 Appearance = 0 'Flat DragMode = 1 'Automatic Height = 1155 Left = 240 MousePointer = 99 'Custom Picture = "Form1.frx":D7E4 Stretch = -1 'True Top = 1440 Width = 3840 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Const HKEY_CLASSES_ROOT = &H80000000 Private Const HKEY_CURRENT_USER = &H80000001 Private Const HKEY_LOCAL_MACHINE = &H80000002 Private Const HKEY_USERS = &H80000003 Private Const HKEY_PERFORMANCE_DATA = &H80000004 Private Const HKEY_CURRENT_CONFIG = &H80000005 Private Const HKEY_DYN_DATA = &H80000006 '查询 hKey Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long '查询默认值 Private Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long '这个函数是取注册表值的最关键的函数 '查询具体值 Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As LongFunction GetDefaultValue(ByVal hKey As Long, ByVal Subkey As String, value As String) As Boolean'ERROR_MORE_DATA = 234&,不知道234&是什么意思 Dim ret As Long, lenS As Long, S As String 'hKey=HKEY_LOCAL_MACHINE 'Subkey="SOFTWARE\Microsoft\NET Framework Setup\NDP" '第三个参数为 返回读取的Default Value 'lenS为 传入 第三个参数 的长度,若成功读取了默认值default value,则返回default ret = RegQueryValue(hKey, Subkey, "", lenS)If ret <> 0 And ret <> 234& Then 'ERROR_MORE_DATA=234& GetDefaultValue = False Exit Function End If '先取得字符串的长度,然后再取字符串 ?好象是构造一个string类型的S把?S = String(lenS, Chr(0)) ret = RegQueryValue(hKey, Subkey, S, lenS) If ret <> 0 Then GetDefaultValue = False Exit Function End If '操作字符串,截取,把最后的一个Chr(0)去掉了 value = Left(S, lenS - 1) GetDefaultValue = True'注意这个函数的返回时候没有return 返回值的参数名和函数的名称一样End Function Private Sub Command1_Click() '安装框架 'Dim value As String 'Dim IsGet As Boolean '取得 默认值 'IsGet = GetDefaultValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\NET Framework Setup\NDP", value) 'If IsGet = True Then 'If value = "v1.1.4322" Then 'MsgBox "框架已经安装!" 'End If 'ElseIf value = "v1.1.4322" Then 'MsgBox "框架已经安装!" 'Else 'Dim res As Integer 'res = Shell("huanjing\dotNetFramework\dotnetfx.exe", vbNormalFocus) 'End If '安装MDAC27 '使用的是.net的exe文件 'Dim res2 As Integer 'res2 = Shell("huanjing\MDAC27\setupMdac.exe", vbNormalFocus)Dim ret1, ret2 As Integer Dim lenS As Long ret1 = RegQueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\.NETFramework\policy\v1.0", "", lenS) ret2 = RegQueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\.NETFramework\policy\v1.1", "", lenS) If ret1 = 0 Or ret2 = 0 Then MsgBox "框架已经安装!" 'End If 这里不要End If了 Else Dim res As Integer res = Shell("huanjing\dotNetFramework\dotnetfx.exe", vbNormalFocus) End If'安装MDAC27 '使用的是.net的exe文件 'Dim res3 As Integer 'huanjing\MDAC27\setupMdac.exe 'res3 = Shell("setupMdac.exe", vbNormalFocus) '这个方法还是他吗的不行 Dim hKey As Long, ret As Long, lenData As Long, typeData As Long Dim Name As String Name = "FullInstallVer" ret = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\DataAccess", hKey) If ret = 0 Then ret = RegQueryValueEx(hKey, Name, 0, typeData, ByVal vbNullString, lenData) ''''''''注意ByVal千万别忘了 Dim S As String S = String(lenData, Chr(0)) RegQueryValueEx hKey, Name, 0, typeData, ByVal S, lenData ''''''''注意ByVal千万别忘了 S = Left(S, InStr(S, Chr(0)) - 1) ''取得了注册表的值了 If S = "2.70.7713.4" Or S = "2.70.7713.0" Or S = "2.80.1022.0" Then MsgBox "MDAC 已经安装!" Else ''''安装MDAC res = Shell("huanjing\MDAC27\mdac_typ.exe", vbNormalFocus) End If Else ''''安装MDAC res = Shell("huanjing\MDAC27\mdac_typ.exe", vbNormalFocus) End If End Sub Private Sub Command2_Click() Dim res As Integer res = Shell("xfzj\setup.exe", vbNormalFocus) End SubPrivate Sub Command3_Click() Dim res As Integer res = Shell("backup\Setup.exe", vbNormalFocus) End Sub
不过不记得名字了你自己找找看
本文的win32程序是使用vb6.0写的,文件夹组织:
---setup win32的exe程序
--huanjing dotNetFramework和mdac文件
--xfzj .net应用程序
--backup .net应用程序
引导程序代码如下:VERSION 5.00
Begin VB.Form Form1
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "安装徐房租监管理系统"
ClientHeight = 5220
ClientLeft = 60
ClientTop = 450
ClientWidth = 4470
FillColor = &H008080FF&
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MousePointer = 99 'Custom
Picture = "Form1.frx":0442
ScaleHeight = 5220
ScaleWidth = 4470
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
BackColor = &H00FFFFFF&
Caption = "安 装 运 行 环 境"
Height = 375
Left = 1080
Style = 1 'Graphical
TabIndex = 2
Top = 1560
Width = 2295
End
Begin VB.CommandButton Command3
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Caption = "安装徐房租监备份系统"
Height = 375
Left = 1080
Style = 1 'Graphical
TabIndex = 1
Top = 3960
Width = 2250
End
Begin VB.CommandButton Command2
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Caption = "安装徐房租监管理系统"
Height = 375
Left = 1080
Style = 1 'Graphical
TabIndex = 0
Top = 2880
Width = 2250
End
Begin VB.Image Image3
Height = 1215
Left = 240
Picture = "Form1.frx":7C69
Top = 3720
Width = 3810
End
Begin VB.Image Image2
Height = 1020
Left = 360
Picture = "Form1.frx":B109
Top = 2640
Width = 3825
End
Begin VB.Image Image1
Appearance = 0 'Flat
DragMode = 1 'Automatic
Height = 1155
Left = 240
MousePointer = 99 'Custom
Picture = "Form1.frx":D7E4
Stretch = -1 'True
Top = 1440
Width = 3840
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_USERS = &H80000003
Private Const HKEY_PERFORMANCE_DATA = &H80000004
Private Const HKEY_CURRENT_CONFIG = &H80000005
Private Const HKEY_DYN_DATA = &H80000006
'查询 hKey
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
'查询默认值
Private Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long
'这个函数是取注册表值的最关键的函数
'查询具体值
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As LongFunction GetDefaultValue(ByVal hKey As Long, ByVal Subkey As String, value As String) As Boolean'ERROR_MORE_DATA = 234&,不知道234&是什么意思
Dim ret As Long, lenS As Long, S As String
'hKey=HKEY_LOCAL_MACHINE
'Subkey="SOFTWARE\Microsoft\NET Framework Setup\NDP"
'第三个参数为 返回读取的Default Value
'lenS为 传入 第三个参数 的长度,若成功读取了默认值default value,则返回default
ret = RegQueryValue(hKey, Subkey, "", lenS)If ret <> 0 And ret <> 234& Then
'ERROR_MORE_DATA=234&
GetDefaultValue = False
Exit Function
End If
'先取得字符串的长度,然后再取字符串 ?好象是构造一个string类型的S把?S = String(lenS, Chr(0))
ret = RegQueryValue(hKey, Subkey, S, lenS)
If ret <> 0 Then
GetDefaultValue = False
Exit Function
End If
'操作字符串,截取,把最后的一个Chr(0)去掉了
value = Left(S, lenS - 1)
GetDefaultValue = True'注意这个函数的返回时候没有return 返回值的参数名和函数的名称一样End Function
Private Sub Command1_Click()
'安装框架
'Dim value As String
'Dim IsGet As Boolean
'取得 默认值
'IsGet = GetDefaultValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\NET Framework Setup\NDP", value)
'If IsGet = True Then
'If value = "v1.1.4322" Then
'MsgBox "框架已经安装!"
'End If
'ElseIf value = "v1.1.4322" Then
'MsgBox "框架已经安装!"
'Else
'Dim res As Integer
'res = Shell("huanjing\dotNetFramework\dotnetfx.exe", vbNormalFocus)
'End If
'安装MDAC27
'使用的是.net的exe文件
'Dim res2 As Integer
'res2 = Shell("huanjing\MDAC27\setupMdac.exe", vbNormalFocus)Dim ret1, ret2 As Integer
Dim lenS As Long
ret1 = RegQueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\.NETFramework\policy\v1.0", "", lenS)
ret2 = RegQueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\.NETFramework\policy\v1.1", "", lenS)
If ret1 = 0 Or ret2 = 0 Then
MsgBox "框架已经安装!"
'End If 这里不要End If了
Else
Dim res As Integer
res = Shell("huanjing\dotNetFramework\dotnetfx.exe", vbNormalFocus)
End If'安装MDAC27
'使用的是.net的exe文件
'Dim res3 As Integer
'huanjing\MDAC27\setupMdac.exe
'res3 = Shell("setupMdac.exe", vbNormalFocus)
'这个方法还是他吗的不行
Dim hKey As Long, ret As Long, lenData As Long, typeData As Long
Dim Name As String
Name = "FullInstallVer"
ret = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\DataAccess", hKey)
If ret = 0 Then
ret = RegQueryValueEx(hKey, Name, 0, typeData, ByVal vbNullString, lenData) ''''''''注意ByVal千万别忘了
Dim S As String
S = String(lenData, Chr(0))
RegQueryValueEx hKey, Name, 0, typeData, ByVal S, lenData ''''''''注意ByVal千万别忘了
S = Left(S, InStr(S, Chr(0)) - 1) ''取得了注册表的值了
If S = "2.70.7713.4" Or S = "2.70.7713.0" Or S = "2.80.1022.0" Then
MsgBox "MDAC 已经安装!"
Else ''''安装MDAC
res = Shell("huanjing\MDAC27\mdac_typ.exe", vbNormalFocus)
End If
Else ''''安装MDAC
res = Shell("huanjing\MDAC27\mdac_typ.exe", vbNormalFocus)
End If
End Sub
Private Sub Command2_Click()
Dim res As Integer
res = Shell("xfzj\setup.exe", vbNormalFocus)
End SubPrivate Sub Command3_Click()
Dim res As Integer
res = Shell("backup\Setup.exe", vbNormalFocus)
End Sub
"莫名其妙嘛。既然用.net的winform,就没法离开framework啊"楼主先加强对.Net的认识吧