installshield 怎么调用C#,C++dll,有源码最好
解决方案 »
- C# 处理退出窗口时,处理假死状态,在线等
- 使用Facebook API获取facebook相册问题
- DataGridView 清空数据
- 如何判断一个最长不超过4字符的字符串是否只有字母数字组成或“****”
- 有处理过海量数据的高手进!
- 谁现实这种功能?急啊,谢谢!!!!!!
- 如何把string型赋值给byte型
- 在DataGrid里修改了数据,会触发什么事件?
- 为什么在ORACLE10g里修改数据失败?
- Call自己的构造函数在C#里应该怎么做的?
- c#中怎么禁用和开启无线网卡?
- 程序集“D:\项目\FolderTree\FolderTree\obj\Debug\FolderTree.dll”不包含任何 UserControl 类型
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函数调用就可。
我先prototype cdecl(bool) a.RegExValidatePassword(BYREF STRING,BYREF STRING,BYREF STRING);(返回值类型要不要加,我看有的资料加,有的没加)
三个参数对应输入注册码的三个textbox,调用dll里面的函数RegExValidatePassword,返回bool值,具体步骤是什么?老出错
这里没有那么严格,可以不加。
prototype cdecl a.RegExValidatePassword(BYREF STRING,BYREF STRING,BYREF STRING);
a这里应该是你DLL的名字。
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该怎么搞?
先把dll放在Support Files的Language Independent下,然后在安装脚本中找到临时目录,在该目录下搜索dll文件。
如:
GetEnvVar("TEMP", tempdir);//得到临时目录
FindAllFiles ( tempdir, "xxx.dll" , tempdir, CONTINUE );//在临时目录下搜索xxx.dll文件
tempdir//这个是DLL的路径。
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该怎么搞?
新建项目的时候。选择--Windouws控件库。就行了。
按照上面步骤调用有问题吗?
dll程序
zhucema.cpp
bool MyDllFunc(string a,string b,string c)
{
if(a=="PRCODE"&&b=="0011"&&c=="9900000015")
{
return true;
}
else
{
return false;
}
}
zhucema.h
extern "C" __declspec(dllexport) bool _cdecl MyDllFunc(string a,string b,string c);
这个例子说是我那种方法可以的
这样参数注定了你无法调用成功。
你还是使用导出C接口的DLL吧
extern "C" __declspec(dllexport) bool _cdecl MyDllFunc(const char* a,const char* b,const char* c);