惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
Intezer
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
N
News | PayPal Newsroom
T
Tenable Blog
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Secure Thoughts
P
Privacy International News Feed
IT之家
IT之家
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
博客园_首页
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
Martin Fowler
Martin Fowler
NISL@THU
NISL@THU
I
InfoQ
D
DataBreaches.Net
有赞技术团队
有赞技术团队
K
Kaspersky official blog
Security Latest
Security Latest
The Register - Security
The Register - Security
Hugging Face - Blog
Hugging Face - Blog
S
Security @ Cisco Blogs
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
AI
AI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic

博客园 - 追忆似水年华

dotNet平台下的SNS软件的比较与选用(一) 对于IM市场的思考 杂谈DNN - 追忆似水年华 - 博客园 点评顾雏军 - 追忆似水年华 - 博客园 我要开始研究DNN了 关于《民工》 张纪中 vs 管虎 呵呵,msn7的端口修改了。 C#实现的根据年月日计算星期几的函数 记得有人说过,人生有两大欢乐,一是拥有后可以细细品味,二就是追求之中的备感充实。 谁用过 install shield x 呀,我遇到麻烦了. 不好意思 又来问问题了. 忽然想起了刘伶 忽然想起我读书时 写的两句话 用vs制作安装程序的时候 如何获取用户输入的序列号,并进行判定 关于向页面注册javascript的技术 我读《Microsoft .NET框架程序设计(修订版)》------DoItNow的读书笔记7 也谈const VS readonly 关于键盘模拟的问题 我读《Microsoft .NET框架程序设计(修订版)》------DoItNow的读书笔记6 发现了MSDN的两个错误 不知道大家的看法如何
install sheild调用外部函数(在dll内)
追忆似水年华 · 2004-11-09 · via 博客园 - 追忆似水年华

好久没有来写点东西了,不过最近慢的晕头转向. 今天就写一点IS(install sheild)调用外部函数的东西吧.
我们的项目是这样的,软件的序列号和注册码是写在加密狗里面的, 在安装的时候判断用户输入的序列号注册码是否跟狗内的一致,如果一致可以容许继续安装,如果不一致就要退出. 读取狗内的信息,并判断是否一致的方法是写在一个dll内的函数中.

最初这个dll是用vb做的. 不过vb做的dll好像没有 Export的功能,其外部其他程序是无法调用的,所以后来改用 vc++来处理. 以下是IS中调用这个函数的具体方法:

1.在IS的开头声明dll内函数的原型
prototype cdecl INT InstallDoggyCheck.GetVersionFlag (BYREF string);
prototype cdecl INT InstallDoggyCheck.GetRegCodeFlag(BYREF string,BYREF string);

2.   拷贝加密狗的动态链接库
     SetFileInfo (SUPPORTDIR ^ "Rockey2.dll", FILE_ATTRIBUTE, FILE_ATTR_NORMAL, "");
     //SetFileInfo (SUPPORTDIR ^ "InstallDoggyCheck.dll", FILE_ATTRIBUTE, FILE_ATTR_NORMAL, "");
     CopyFile (SUPPORTDIR ^ "Rockey2.dll",WINDIR ^ "SYSTEM32\\Rockey2.dll"); 
     CopyFile (SUPPORTDIR ^ "Rockey2.lib",WINDIR ^ "SYSTEM32\\Rockey2.lib"); 

3.动态载入含有函数的dll(就是用vc++写的那个)
szDLL = SUPPORTDIR ^ "InstallDoggyCheck.dll";
  nResult = UseDLL (szDLL);
  if (nResult = 0) then
   //MessageBox ("动态库调入内存成功!", INFORMATION);
  else
   MessageBox ("动态库调入内存失败!", INFORMATION);
   abort;
  endif;

4.调用dll内的函数
nResult = InstallDoggyCheck.GetVersionFlag(svEdit1);
  //NumToStr (svString, nResult);
  //MessageBox(svString,SEVERE);
  if(nResult!=1) then
   MessageBox("请确定你是否正确地安装了加密狗输入了序列号!",SEVERE);
   glSNNum= glSNNum+ 1;
   if(glSNNum<=3) then
    goto Dlg_AskSN;
   else
    abort;
   endif;
  endif;
5.卸载dll
if (UnUseDLL (szDLL) < 0) then
   MessageBox("卸载动态库失败,仍在内存中!", SEVERE);
  else
   //MessageBox("从内存中卸载动态库成功!", INFORMATION);
  endif;

说明:1. 声明原型 函数调用部分dll的名字必须 与实际dll的名字完全对应,包括大小写.
        2. 在IS和vc++中传递参数. IS中的sting,要对应vc++中的LPSTR,(不可以对应
char*等其他类型).

        3.IS中调用外部函数 还有其他方法,不过这个动态载入卸载dll的方法最灵活,方便.