VS2005安装包问题

casablanca1985 2008-06-05 05:03:42
Hi,我不太清楚如何使用installer类并获取安装信息。
我现在想实现一个简单的功能,就是在Custom Actions中,把CustomActionData传递给一个dll,
我取名叫call_Action.dll,具体步骤我就不写了,我只写大致的框架。
我的call_Action.dll中实现Instller类继承的代码如下(主要是从msdn上考的):
// This is the main DLL file.

#include "stdafx.h"
#include "windows.h"
#include "stdio.h"
#include "string"

#include "Call_Action.h"

#using <System.dll>
#using <System.Configuration.Install.dll>

using namespace System;
using namespace System::Collections;
using namespace System::Collections::Specialized;
using namespace System::ComponentModel;
using namespace System::Configuration::Install;





// Set 'RunInstaller' attribute to true.

[RunInstaller(true)]
EXPORTS ref class MyInstallerClass: public Installer
{
private:
void InstallBase()
{
InstallContext^ myInstallContext;
//Console::WriteLine(myInstallContext->Parameters["Myfile"]);
//Console::WriteLine("我是一条龙啊");


}


public:
MyInstallerClass()
{

}

// Override the 'Install' method.
virtual void Install( IDictionary^ savedState ) override
{
FILE *myfile;
myfile=fopen("G:\\project\\Call_Custom_Install\\debug\\myfile.txt","at+");
if(myfile)
{
fputc('c',myfile);
}
InstallContext^ myInstallContext;
fprintf(myfile,"%s",myInstallContext->Parameters["Myfile"]);
fprintf(myfile,"%s","sdfsd");
fclose(myfile);
Installer::Install( savedState );
this->InstallBase();//调用上面的方法;
}

// Override the 'Commit' method.
virtual void Commit( IDictionary^ savedState ) override
{
Installer::Commit( savedState );
}


// Override the 'Rollback' method.
virtual void Rollback( IDictionary^ savedState ) override
{
Installer::Rollback( savedState );
}
public:
IDictionary^ g_savedState;

};

int main()
{

Console::WriteLine( "Usage : installutil.exe Installer.exe " );
}


[backcolor=#FF3300]void yy()[/backcolor]
{

MyInstallerClass My_insall;
My_insall.Install(My_insall.g_savedState);
//My_insall.g_savedState
//FILE *myfile;
//InstallContext^ myInstallContext;
//myfile=fopen("G:\\project\\Call_Custom_Install\\debug\\myfile.txt","at+");
//if(myfile)
//{
// fprintf(myfile,"%s",myInstallContext->Parameters["Myfile"]);
// //fprintf(myfile,"%s","sdfsd");
// //fputc(myInstallContext->Parameters["Myfile"],myfile);
//}
//fclose(myfile);

}

我在Custom Action中的参数是这样填的:
InstallerClass:flase EntryPoint:yy CustomActionData:/Myfile="ddd"
结果是,的确进到了yy函数,并调用了install函数,但是问题是myInstallContext->Parameters["Myfile"]取出来的值是空的,我不知道怎么去调用这么个函数(补充下,我的dll工程是clr的class library)
我本来尝试过吧yy()写成yy(IDictionary^ savedState)的,然后custom action参数是这样写的:
InstallerClass:true EntryPoint:yy CustomActionData:/Myfile="ddd" 安装包是完成了,但是call
dll这个步骤好像被终止掉了,所以现在的问题是IDictionary^ savedState 在那里用?它是在那里被赋值的?如何能够解决我现在这个问题,能吧Myfile这个参数传进去,让myInstallContext->Parameters["Myfile"]取到?



补充下:我本来是想把MyInstallerClass类给EXPORTS的,这样就能在custom action里直接entrypoint:install ,可好像不准exports,所以我就借用了yy()这个函数来中转下,但我感觉IDictionary^ savedState 在非installer继承类中使用是无效的,对吗?

谢谢~
Nicholas.
...全文
171 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuhaozx 2008-07-28
  • 打赏
  • 举报
回复
mark

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧