制作.net安装项目收集
1.打开你的.net,用鼠标右击你的工程(解决方案),选择add new project(添加新建项目)。
2.选择setup and deployment projects(安装和部署项目)的 web setup project(web安装项目)。(注意setupproject的存放路径。通常默认)
3.vs的窗口会显示文件系统(you setup name)。用鼠标点击左栏下的"web application folder" 的加号,右键选中"web application folder",选择"添加项目输出",
同时选中primary output 和content files。
4.你的工程中会新增一个yousetupname的工程,就是安装的项目。保存一下,有时会出错。
5.因为.xml, .rpt, .gif文件不能自动加到项目中,所以要手动加。在解决方案资源管理器中,右击YouSetup project(你的安装项目名),选中"添加文件",然后把你的.rpt, .xml, .gif文件加入;
6.如果你用了crystal report,就要添加crystal reprot的支持文件。在解决方案资源管理器中,右击YouSetup project(你的安装项目名),选中"添加合并模块",在窗口中找到,并选中C:\Program Files\Common Files\Merge Modules\DotNETCrystalReports.msm, 打开,就加入了;
7.右击"目标计算机上的文件系统",选中属性,在属性窗口中,将productName设置为"你要打包的项目名"
8.右击"web应用程序文件夹",选中属性,在属性窗口中,将DefaultDocument设置为"你的默认登录页"即"起始页",
9.选中你的yousetupname工程,按右键,选中"生成";或在主菜单的"生成"中选中"生成yourSetupFileName";
10.然后,在C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\KaoQin\文件的存放路径下会有一个yousetupname的文件夹,下面还有一个debug的文件夹,你要的就是debug下面的所有文件。
11.将debug folder 下的文件考到你要安装的机器上,然后安装就可以了,如果有数据库,你可以将库事先还原过去,就可以用了。
12.如何部署包含水晶报表的程序(VS.NET 2002)
------------------------------------------------
1、原理:
发布使用水晶报表的项目需要包含三种组件:报表(*.rpt)、模块(*.msm)、运行库(*.msm),这些模块文件是在 C:\Program Files\Common Files\Merge Modules\ 目录里面。
(1)报表(*.rpt)
用户编程时创建的水晶报表文件。
(2)模块(*.msm)
Managed.msm
该模块包含了CR for VS .NET 的管理模块,如 CrystalDecisions、CrystalReports.Engine.DLL、CrystalDecisions.Web.DLL, 和 CrystalDecisions.Windows.Forms.DLL……
Managed_chs.msm
是该模块的中文版语言支持。
Database_Access.msm
该模块包含了数据库的驱动、与不同数据库的联结、报表导出为 RTF 和 HTML 格式的文档和图表组件。
Database_Access_chs.msm
是此模块的中文版语言支持。
Regwiz.msm
注册信息模块,非常重要,必需在这个模块输入水晶报表的注册序列号,如果不填,编译的时候就无法通过。
KeyCode MSM 处理 Crystal Decisions 密钥号码的安装,这样您的用户在查看报表时,就不会被要求注册他们的 Crystal版本。
(3)运行库(*.msm)
如果报表文件使用了 ADO.NET 的 dataset 数据集对象,那么 VC_CRT.msm 和 VC_STL.msm 模块也必须包含在安装工程中。而且这两个模块的文件安装属性的"Module Retargetable Folder"项必须修改成为系统目录
在VS.NET安装工程中,系统检测出来的依赖项只有 dotNETFXRedist_x86_chs.msm 和 Managed.msm这两个模块,其他的模块我们需要手动加入。
-------------------------
2、具体操作步骤:
(1)新建“安装和部署项目”-->“安装向导”
(2)选择项目类型(这里选“创建用于windows应用程序的安装程序”)-->下一步
(3)选择要包含的文件:添加你的程序文件和 C:\Program Files\Common Files\Merge Modules 下的 managed.msm、managed_chs.msm、database_access.msm、database_access_chs.msm、regwiz.msm、VC_CRT.msm、VC_STL.msm。-->完成
(4)打开解决方案-->右键点击regwiz.msm的属性,在“MergeMouduleProperties”里的“License Key”填入:AAP5GKS0000GDE100DS(这个是你生成Crystal Report是用到的注册号的密码!)
(5)生成解决方案(或直接按Ctrl+Shift+B)
图示介绍:http://www.yesky.com/20030327/1659638.shtml
读硬盘序列号:
using System;
using System.Runtime.InteropServices;
namespace ArLi.CommonPrj
{
public class getvol
{
[DllImport("kernel32.dll")]
private static extern int GetVolumeInformation(
string lpRootPathName,
string lpVolumeNameBuffer,
int nVolumeNameSize,
ref int lpVolumeSerialNumber,
int lpMaximumComponentLength,
int lpFileSystemFlags,
string lpFileSystemNameBuffer,
int nFileSystemNameSize
);
public static string GetVolOf(string drvID){
const int MAX_FILENAME_LEN = 256;
int retVal = 0;
int a =0;
int b =0;
string str1 = null;
string str2 = null;
int i = GetVolumeInformation(
drvID + @":\",
str1,
MAX_FILENAME_LEN,
ref retVal,
a,
b,
str2,
MAX_FILENAME_LEN
);
return retVal.ToString("x");
}
}
}
还有个问题首先得考虑的就是你的硬盘是不是SCSI硬盘
如果是,那么根本不存在"物理序列号",只可能取得卷标的序列号
如果是卷标序列号,要注意的是每次格式化硬盘的时候这个序列号都会变
代码可以参考:
http://www.csdn.net/Develop/Read_Article.asp?Id=25196
如果是物理序列号:
String HDid;
ManagementClass cimobject = new ManagementClass("Win32_DiskDrive");
ManagementObjectCollection moc = cimobject.GetInstances();
foreach(ManagementObject mo in moc)
{
HDid = (string)mo.Properties["Model"].Value;
MessageBox.Show(HDid );
}
硬盘序列号的类
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Win32;
namespace Wjb.ReadOrWriteIniAndReg
{
/// <summary>
/// HardDiskVal 的摘要说明。
/// 读取指定盘符的硬盘序列号
/// 功能:读取指定盘符的硬盘序列号
/// </summary>
public class HardDiskVal
{
[DllImport("kernel32.dll")]
private static extern int GetVolumeInformation(
string lpRootPathName,
string lpVolumeNameBuffer,
int nVolumeNameSize,
ref int lpVolumeSerialNumber,
int lpMaximumComponentLength,
int lpFileSystemFlags,
string lpFileSystemNameBuffer,
int nFileSystemNameSize
);
/// <summary>
/// 获得盘符为drvID的硬盘序列号,缺省为C
/// </summary>
/// <param name="drvID"></param>
/// <returns></returns>
public string HDVal(string drvID)
{
const int MAX_FILENAME_LEN = 256;
int retVal = 0;
int a =0;
int b =0;
string str1 = null;
string str2 = null;
int i = GetVolumeInformation(
drvID + @":\",
str1,
MAX_FILENAME_LEN,
ref retVal,
a,
b,
str2,
MAX_FILENAME_LEN
);
return retVal.ToString();
}
public string HDVal()
{
const int MAX_FILENAME_LEN = 256;
int retVal = 0;
int a =0;
int b =0;
string str1 = null;
string str2 = null;
int i = GetVolumeInformation(
"c:\\",
str1,
MAX_FILENAME_LEN,
ref retVal,
a,
b,
str2,
MAX_FILENAME_LEN
);
return retVal.ToString();
}
}
}
using System;
using System.Runtime.InteropServices;
namespace ArLi.CommonPrj {
#region how use this?
/*
string sVol = getvol.GetVolOf("C");
*/
#endregion
public class getvol{
[DllImport("kernel32.dll")]
private static extern int GetVolumeInformation(
string lpRootPathName,
string lpVolumeNameBuffer,
int nVolumeNameSize,
ref int lpVolumeSerialNumber,
int lpMaximumComponentLength,
int lpFileSystemFlags,
string lpFileSystemNameBuffer,
int nFileSystemNameSize
);
public static string GetVolOf(string drvID){
const int MAX_FILENAME_LEN = 256;
int retVal = 0;
int a =0;
int b =0;
string str1 = null;
string str2 = null;
int i = GetVolumeInformation(
drvID + @":\",
str1,
MAX_FILENAME_LEN,
ref retVal,
a,
b,
str2,
MAX_FILENAME_LEN
);
return retVal.ToString("x");
}
}
}
'获得硬盘序列号
Dim cmicWmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
Dim Uint32 As UInt32
For Each cmicWmiObj As ManagementObject In cmicWmi.Get
Uint32 = cmicWmiObj("signature")
Next
TextBox1.Text = Uint32.ToString
'获得CPU序列号
Dim Wmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_Processor")
Dim Uint32 As String
For Each WmiObj As ManagementObject In Wmi.Get
Uint32 = WmiObj("ProcessorId")
Next
TextBox1.Text = Uint32
'获得硬盘总容量
Dim Wmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
Dim Uint64 As UInt64
For Each WmiObj As ManagementObject In Wmi.Get
Uint64 = WmiObj("size")
Next
TextBox1.Text = Uint64.ToString
首先,引用System.Management;然后在代码中Imports System.Management;