visual studio制作位图
- 提问者网友:寂寞梧桐
- 2021-03-17 16:56
- 五星知识达人网友:迟山
- 2021-03-17 17:13
- 1楼网友:不甚了了
- 2021-03-17 17:25
学学使用安装类。
下面是个c#做的安装类示例,安装完成后对c#做的dll进行注册注册,process来调用一个程序,这里使用的是控制台,在控制台调用使用regasm来完成对dll的注册。
using system; using system.collections.generic; using system.componentmodel; using system.configuration.install; using system.diagnostics;
namespace install { [runinstaller(true)] public partial class installer1 : installer { public installer1() { initializecomponent(); this.afterinstall += new installeventhandler(installer1_afterinstall);
} public void installer1_afterinstall(object sender, installeventargs e) { string path = this.context.parameters["targetdir"]; //关闭进程 system.diagnostics.process[] process = system.diagnostics.process.getprocessesbyname("w3wp"); foreach (system.diagnostics.process p in process) { system.console.writeline(p.tostring()); p.kill(); } string filename = system.environment.getenvironmentvariable("windir") + @"\microsoft.net\framework\v2.0.50727\regasm"; string appname = path + "dbconn.dll"; process proc = new process();
proc.startinfo.filename = filename; proc.startinfo.arguments = " " + appname + " /codebase"; proc.startinfo.useshellexecute = false; proc.startinfo.createnowindow = true; proc.startinfo.redirectstandardoutput = true; proc.start(); string output = proc.standardoutput.readtoend(); proc.waitforexit();
system.console.writeline(output); system.console.readline(); }
} }