ASP组件的问题 ( 积分: 300 )

  • 主题发起人 主题发起人 jianguobu
  • 开始时间 开始时间
J

jianguobu

Unregistered / Unconfirmed
GUEST, unregistred user!
-----ActivexX Library
library DnsControl;

{%File 'DnsControl.asp'}
{%File 'Dns.asp'}

uses
ComServ,
DnsControl_TLB in 'DnsControl_TLB.pas',
Unit_Dns in 'Unit_Dns.pas' {Dns: CoClass};

exports
DllGetClassObject,
DllCanUnloadNow,
DllRegisterServer,
DllUnregisterServer;

{$R *.TLB}

{$R *.RES}

begin
end.

--------Active Server Object
unit Unit_Dns;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
ComObj, ActiveX, AspTlb, DnsControl_TLB, StdVcl, Windows, ShellApi, SysUtils, WinSock;

const
FileName='Error.txt';

type
TDns = class(TASPObject, IDns)
private
function GetLocalName: String;
protected
procedure OnEndPage
safecall;
procedure OnStartPage(const AScriptingContext: IUnknown)
safecall;
procedure ZoneAdd(DomainName: OleVariant)
safecall;
procedure ZoneDelete(DomainName: OleVariant)
safecall;
end;

implementation

uses ComServ;

procedure SaveInfo(FileName,str: string)
stdcall;
var
f: textfile;
begin
{保存为文件信息}
assignfile(f, FileName);
if fileexists(FileName) = false then rewrite(f)
else append(f);
if strcomp(pchar(str), pchar('#13#10')) = 0 then writeln(f, '')
else writeln(f, str);
closefile(f);
end;

function TDns.GetLocalName: String;
var
ComputerName: array[0..MAX_COMPUTERNAME_LENGTH+1] of char;
Size: Dword;
begin
Size := MAX_COMPUTERNAME_LENGTH+1;
if GetComputerName(ComputerName, Size) then
result:=StrPas(Computername)
else result:='Unkown';
end;

procedure TDns.OnEndPage;
begin
inherited OnEndPage;
end;

procedure TDns.OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
end;

procedure TDns.ZoneAdd(DomainName: OleVariant);
var
Str : String;
begin
Str := '/K d:/autodns/dnscmd '+Trim(GetLocalName)+' /ZoneAdd '+ DomainName + ' /Primary';
SaveInfo(FileName,DateTimeToStr(Now)+' 在做站点时生成的语句:'+Str);
ShellExecute(0,'open','cmd.exe',pchar('/K d:/autodns/dnscmd CXDNNET /ZoneAdd abc.com /Primary'),nil,SW_SHOWNORMAL);//测试用
// ShellExecute(0,'open','cmd.exe',pchar(str),nil,SW_SHOWNORMAL);
end;

procedure TDns.ZoneDelete(DomainName: OleVariant);
var
Str : String;
begin
Str := '/K d:/autodns/dnscmd '+Trim(GetLocalName)+' /ZoneDelete '+ DomainName + ' /f';
SaveInfo(FileName,DateTimeToStr(Now)+' 在做站点删除时生成的语句:'+Str);
ShellExecute(0,'open','cmd.exe',pchar(str),nil,SW_Hide );
end;

initialization
TAutoObjectFactory.Create(ComServer, TDns, Class_Dns,
ciMultiInstance, tmApartment);
end.

用asp调用不能在dns服务器里创建域名,在DNS服务器里不能看到有新建,而用
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, shellapi;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
ShellExecute(0,'open','cmd.exe',pchar('/K d:/autodns/dnscmd CXDNNET /ZoneAdd abc.com /Primary'),nil,SW_SHOWNORMAL);
end;

end.

能在dns服务器里创建域名,請问为什么?
 
-----ActivexX Library
library DnsControl;

{%File 'DnsControl.asp'}
{%File 'Dns.asp'}

uses
ComServ,
DnsControl_TLB in 'DnsControl_TLB.pas',
Unit_Dns in 'Unit_Dns.pas' {Dns: CoClass};

exports
DllGetClassObject,
DllCanUnloadNow,
DllRegisterServer,
DllUnregisterServer;

{$R *.TLB}

{$R *.RES}

begin
end.

--------Active Server Object
unit Unit_Dns;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
ComObj, ActiveX, AspTlb, DnsControl_TLB, StdVcl, Windows, ShellApi, SysUtils, WinSock;

const
FileName='Error.txt';

type
TDns = class(TASPObject, IDns)
private
function GetLocalName: String;
protected
procedure OnEndPage
safecall;
procedure OnStartPage(const AScriptingContext: IUnknown)
safecall;
procedure ZoneAdd(DomainName: OleVariant)
safecall;
procedure ZoneDelete(DomainName: OleVariant)
safecall;
end;

implementation

uses ComServ;

procedure SaveInfo(FileName,str: string)
stdcall;
var
f: textfile;
begin
{保存为文件信息}
assignfile(f, FileName);
if fileexists(FileName) = false then rewrite(f)
else append(f);
if strcomp(pchar(str), pchar('#13#10')) = 0 then writeln(f, '')
else writeln(f, str);
closefile(f);
end;

function TDns.GetLocalName: String;
var
ComputerName: array[0..MAX_COMPUTERNAME_LENGTH+1] of char;
Size: Dword;
begin
Size := MAX_COMPUTERNAME_LENGTH+1;
if GetComputerName(ComputerName, Size) then
result:=StrPas(Computername)
else result:='Unkown';
end;

procedure TDns.OnEndPage;
begin
inherited OnEndPage;
end;

procedure TDns.OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
end;

procedure TDns.ZoneAdd(DomainName: OleVariant);
var
Str : String;
begin
Str := '/K d:/autodns/dnscmd '+Trim(GetLocalName)+' /ZoneAdd '+ DomainName + ' /Primary';
SaveInfo(FileName,DateTimeToStr(Now)+' 在做站点时生成的语句:'+Str);
ShellExecute(0,'open','cmd.exe',pchar('/K d:/autodns/dnscmd CXDNNET /ZoneAdd abc.com /Primary'),nil,SW_SHOWNORMAL);//测试用
// ShellExecute(0,'open','cmd.exe',pchar(str),nil,SW_SHOWNORMAL);
end;

procedure TDns.ZoneDelete(DomainName: OleVariant);
var
Str : String;
begin
Str := '/K d:/autodns/dnscmd '+Trim(GetLocalName)+' /ZoneDelete '+ DomainName + ' /f';
SaveInfo(FileName,DateTimeToStr(Now)+' 在做站点删除时生成的语句:'+Str);
ShellExecute(0,'open','cmd.exe',pchar(str),nil,SW_Hide );
end;

initialization
TAutoObjectFactory.Create(ComServer, TDns, Class_Dns,
ciMultiInstance, tmApartment);
end.

用asp调用不能在dns服务器里创建域名,在DNS服务器里不能看到有新建,而用
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, shellapi;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
ShellExecute(0,'open','cmd.exe',pchar('/K d:/autodns/dnscmd CXDNNET /ZoneAdd abc.com /Primary'),nil,SW_SHOWNORMAL);
end;

end.

能在dns服务器里创建域名,請问为什么?
 
代码没仔细看,应该是IIS中没有执行权限
ShellExecute(0,'open','cmd.exe',pchar('/K d:/autodns/dnscmd CXDNNET /ZoneAdd abc.com /Primary'),nil,SW_SHOWNORMAL);

d:/autodns/dnscmd 要有执行权限
 
你是根据什么来判断它没有执行权限呢?
 
还有,asp调用组件后,在任务管理里的进程列表里可以看到CMD进程。
 
运行这一行,不需要IIS是否有执行权限,如果IIS没有执行权限ASP会运行失败,同时,那个dnscmd所在的目录肯定具备了执行权限,DLL注册后,在系统里以管理员权限限运行。目前并不是不能执行,是执行了无效果。也就是说,cmd.exe调用进入内存。只是后面的命令字串没有被正确执行。
 
还没人回
 
??????????回复回得
 
TO 楼主

您好,借你贴子用一下,刚注册.不能开贴.

关于QQ 发送信息的

为什么每篇同类的文章都说 'RICHEDIT'是发送文字的窗口,用SPY++查了总共有两个

'RICHEDIT',一个在'AfxWnd42'下.但两个都试了,没用.可能以前版本的可以,我用的这个是QQ2004 II

不行,试了一整天了.不能注入文字,但'RichEdit20A'(已发送的)这个却能在里面加字.

现求教,那个才是真正的发送文字的窗口。(200分,可商量)


我是这样写的:

WI:= 0;
WI := FindWindowEx(0,WI, '#32770',szText);
WI:= FindWindowEx(WI,0, '#32770','');
HWindow:= FindWindowEx(WI,0,'AfxWnd42',NIL);
HWindow := FindWindowEx(HWindow,0,'RICHEDIT',NIL);
SendMessage(HWindow, WM_SETTEXT, 256,integer(EDIT1.TEXT));



 
不懂这个问题, 来接分, 楼上咋冒出来个 "刘麻子 l", 请诸位注意鉴别, 谨防假冒 . [:D]
 
我还是把点名去掉,到时别人看了不来了。
 
一定分清。
 
to刘麻子.
QQ2004,的文本框是加了密.
不能用
SendMessage(HWindow, WM_SETTEXT, 256,integer(EDIT1.TEXT));
要用其它方法做.
你想要代码,请和我联系.QQ9238961.
 
呵呵,楼上的,刘麻子肯定不会要你的代码,他在系统编程方面可是高手了。
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
698
import
I
后退
顶部