请高手给我分析一下这段代码,关于dll的。(100分)

  • 主题发起人 ww20000309
  • 开始时间
W

ww20000309

Unregistered / Unconfirmed
GUEST, unregistred user!
我的代码为:
library exmapletest;

{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }

uses
SysUtils,
windows,
Classes;

procedure closewindows;export;stdcall;
begin
exitwindowsex(ewx_shutdown or ewx_poweroff ,0);
end;
exports closewindows index 1 name 'closewindows';
{$R *.res}

begin
end.
我想通过它在网页中实现windows关机。
但编译后用 regsvr32 注册时报错为:
d:/dll/exmapletest.dll was loaded,but the dllregisterserver entry point was
not found dllregisterserver may not be exported ,or a corrupt version of
d:/dll/exmapletest.dll may be in memory. consider using pview to detect and
remove it.
我是第一次编写dll文件,还请各位高手指点迷经。
 
这样的dll不需要用regsvr32注册就能用的,在你的主程序里静态或动态引用即可。
 
to 叮叮当当:
我是想在网页中用vbscript 调用,不注册那怎么用。
请给与指点,谢谢。
 
各位大侠请帮帮忙我今夜无眠。等待,谢谢。
 
你这个只是普通的dll,不需要注册,也不能在网页里调用。要在网页里用,你应该做一个
ActiveX,当然,可能也是个dll。
可以参考一下http://www.delphibbs.com/delphibbs/dispq.asp?lid=0940110
但要在网页中实现windows关机,不知道怎么做。
 
zw84611说的没错,你需要做的是ActiveX DLL。
 
具体说一下,我是用delphi中的webbrowse+htm页网做了一个触摸屏的程序本来是不想
有关机功能的,可是人家想要用一键关机,这真把我给难住了。
请各位大侠帮忙,谢谢.
 
应该可以的。
你照
http://www.delphibbs.com/delphibbs/dispq.asp?lid=0940110
做一个ActiveX,假设名字叫MyAct,添加一个接口,假设名字叫IClose,在里面添加一个关机的方法,
假设叫CloseMachine
然后在网页里做个按纽调用一段VBScript
例如:

<script language="VBScript">

Sub OnCloseMachine()

On Error Resume Next

set objClose=CreateObject("MyAct.Iclose")

Call objClose.CloseMachine()

end Sub

call OnCloseMachine()

</script>
 
你是说用的 WebBrowser 么?那就还是一个独立的Delphi EXE程序呀,怎么会不能控制关机?
 
我要做activex dll 怎么做做一个什么控件。
 
WebBrowser控件可以捕捉链接的点击,在事件里判断点击了关机链接,然后直接在Delphi主程序里进行关机调用就行了啊。
 
因为是整屏打开的人家,要求要密码验证。不是定时关机我想给他做成定时关机人家不
同意。
 
to 叮叮当当:
如何去做请给与指点我是一个菜手对webbrowse只了解一点谢谢。
 
你是不是整个程序界面就是WebBrowser?
给点你程序里与WebBrowser控件相关的代码看看。
 
to叮叮当当:
我的email是: ww20000309@yahoo.com.cn
谢谢。
 
你下载 http://shasal.com/Project1.exe ,运行后点击红色的“SCY战网测试器 v0.9 Beta8”,我的程序里检测到你按了这个链接就会弹出一个MessageBox,当然也可以写成关机的代码。
 
我的网易泡泡是pschen@21cn.com,Email也是这个。
 
to 叮叮当当:
我给你加分,你可以给我源代码吗。
 
加不加分无所谓,只要对你有帮助就好[:)]
源代码很简单的:

新建一个Application,在Form1上放一个WebBrowser控件,命名为“WEB”,然后给窗体的OnCreate事件和WEB的BeforeNavigate2事件加入处理程序。
如下:

procedure TForm1.WEBBeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
if URL = 'http://www.rtgame.com/cgi-bin/dl.pl?File=Downloads/Softwares/BNTester0.9Beta8.zip' then
begin
Cancel := True;
ShowMessage('执行关机代码!');
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
web.Navigate('www.rtgame.com');
end;
 
这样只要你把对URL的判断改为对HTM网页里关机链接的判断,再把
ShowMessage('执行关机代码!');
改为实际的关机代码就行了。
 
顶部