installshield 怎么调用C#,C++dll

zhongxingjun 2008-06-30 08:30:27
installshield 怎么调用C#,C++dll,有源码最好
...全文
412 26 打赏 收藏 转发到动态 举报
写回复
用AI写文章
26 条回复
切换为时间正序
请发表友善的回复…
发表回复
dengrenyi 2012-08-02
  • 打赏
  • 举报
回复
有没有结果啊。。。
scj_201 2012-01-31
  • 打赏
  • 举报
回复
学习一下
zhongxingjun 2008-07-01
  • 打赏
  • 举报
回复
自己顶
zhongxingjun 2008-07-01
  • 打赏
  • 举报
回复
还是无法装入
家鸣 2008-06-30
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 zhongxingjun 的回复:]
提示报错,无法装入DLL
[/Quote]
你DLL放到那去了? dll的路径不正确。
先把dll放在Support Files的Language Independent下,然后在安装脚本中找到临时目录,在该目录下搜索dll文件。
如:
GetEnvVar("TEMP", tempdir);//得到临时目录
FindAllFiles ( tempdir, "xxx.dll" , tempdir, CONTINUE );//在临时目录下搜索xxx.dll文件
tempdir//这个是DLL的路径。
家鸣 2008-06-30
  • 打赏
  • 举报
回复
都是字符串操作,参考C++中的类string。
zhongxingjun 2008-06-30
  • 打赏
  • 举报
回复
提示报错,无法装入DLL
家鸣 2008-06-30
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 zhongxingjun 的回复:]
路径对的,还报相同的错
[/Quote]
首先,确保你的DLL依赖的其他DLL也一起放到了相同的目录,然后把DLL的定义改成
extern "C" __declspec(dllexport) bool _cdecl MyDllFunc(const char* a,const char* b,const char* c);
zhongxingjun 2008-06-30
  • 打赏
  • 举报
回复
installshield给的例子里面的一个函数
function SdCustomRegExValidatePassword( svSerial_1, svSerial_2, svSerial_3 )
STRING svSub_svSerial_3;
NUMBER nCalculation;
begin
///////////////////////////////////////////////////////////
// Place your Serial Number Validation Code here
// This sample looks for:
// szSerial_1 = "PRCODE"
// szSerial_2 = "0011"
// szSeiral_3: Must be 10 digits long, and the
// last 6 digits must be a multiple
// of 15. For example:
// 9900000015
// 1000000030
///////////////////////////////////////////////////////////
if (svSerial_1 = "PRCODE") then
if (svSerial_2 = "0011") then
if ( StrLength(svSerial_3) != 10 ) then
return FALSE;
endif;
StrSub (svSub_svSerial_3, svSerial_3, 4, 6);
StrToNum (nCalculation, svSub_svSerial_3);
if (nCalculation = 0) then return FALSE;
endif;
// calculate remainder
nCalculation = (nCalculation % 15);
if (nCalculation = 0) then return TRUE;
endif;
endif;
endif;
return FALSE;
end;
想把它做成C++dll该怎么搞?
yagebu1983 2008-06-30
  • 打赏
  • 举报
回复
关注+学习!!
帮你顶!!
家鸣 2008-06-30
  • 打赏
  • 举报
回复
返回值类型要不要加,我看有的资料加,有的没加
这里没有那么严格,可以不加。
prototype cdecl a.RegExValidatePassword(BYREF STRING,BYREF STRING,BYREF STRING);
a这里应该是你DLL的名字。
zhongxingjun 2008-06-30
  • 打赏
  • 举报
回复
编译通不过,我写的DLL里面有单个参数,返回值是布尔型
我先prototype cdecl(bool) a.RegExValidatePassword(BYREF STRING,BYREF STRING,BYREF STRING);(返回值类型要不要加,我看有的资料加,有的没加)
三个参数对应输入注册码的三个textbox,调用dll里面的函数RegExValidatePassword,返回bool值,具体步骤是什么?老出错
家鸣 2008-06-30
  • 打赏
  • 举报
回复
调用C++的DLL如:
prototype cdecl Test.GetFileVersion(BYREF STRING);//先根据DLL声明函数

function NUMBER GetVersion(FilePath)
STRING szDLLDir;
NUMBER version;
begin
version= 0;
szDLLDir ="C:\\Test.dll";
if UseDLL(szDLLDir) < 0 then
MessageBox("ERROR: Could not load [" + szDLLDir +"].", SEVERE);
endif;
version = GetFileVersion(FilePath);//调用
if UnUseDLL(szDLLDir) < 0 then
MessageBox("ERROR: Could not unload [" +szDLLDir+"].", SEVERE);
endif;
return version;
end;

调用C#的Dll的话,目前还没有方法实现。不过也有变通的方法,就是把C#的改成exe, 然后通过LaunchAppAndWait函数调用就可。

烈火焚身 2008-06-30
  • 打赏
  • 举报
回复
up
  • 打赏
  • 举报
回复
通常这是无法完成的任务
  • 打赏
  • 举报
回复
[Quote=引用 20 楼 zhongxingjun 的回复:]
为什么?
[/Quote]
这个函数连C++自己都无法调用。
你还是使用导出C接口的DLL吧
zhongxingjun 2008-06-30
  • 打赏
  • 举报
回复
为什么?
  • 打赏
  • 举报
回复
extern "C" __declspec(dllexport) bool _cdecl MyDllFunc(string a,string b,string c);
这样参数注定了你无法调用成功。
zhongxingjun 2008-06-30
  • 打赏
  • 举报
回复
http://www.tianyablog.com/blogger/post_show.asp?blogid=228796&postid=10297862
这个例子说是我那种方法可以的
xiaomatian 2008-06-30
  • 打赏
  • 举报
回复
extern "C" __declspec(dllexport) bool _cdecl MyDllFunc(string a,string b,string c);这种形式只有相同的编译器才会认到你的函数MyDllFunc的,换个编译器就不可以了。在编译的时候会改名的,你是无法调用到函数名为MyDllFunc的函数的,你如果只是函数的到处的话用def文件来定义吧。或者你通过函数序号来查找(这种方式我很少用到,所以不知道行不行。)
加载更多回复(6)

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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