3个小问题

wisenowa 2002-10-23 09:45:24
如下:
1 如何用程序实现重新启动IIS服务组件即WWW服务?
2 如何得到当前IE的地址栏地址以及标题,注意:当前的IE或者最后打开的,只要一个
3 如何用程序实现,在新的窗口打开一个网站,注意:新的窗口?

thx
...全文
22 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wisenowa 2002-10-24
  • 打赏
  • 举报
回复
谢过各位

第2个问题如何做到?
wisenowa 2002-10-23
  • 打赏
  • 举报
回复
没人?
lesstif 2002-10-23
  • 打赏
  • 举报
回复
第一个问题这么做比较简单
WinExec('net stop iisadmin',...)
jxk 2002-10-23
  • 打赏
  • 举报
回复
unit Unit_Service;

interface
uses Windows, Messages, SysUtils,Winsvc,Dialogs;

function StartServices(Const SvrName: String): Boolean;
function StopServices(Const SvrName: String): Boolean;
function QueryServiceStatu(Const SvrName: String): String;
function CreateServices(Const SvrName,FilePath: String): Boolean;
function DeleteServices(Const SvrName: String): Boolean;

implementation


//开启服务
function StartServices(Const SvrName: String): Boolean;
var
a,b: SC_HANDLE;
c: PChar;
begin
Result := False;

a := OpenSCManager(nil,nil,SC_MANAGER_ALL_ACCESS);

if a <= 0 then Exit;

b := OpenService(a,PChar(SvrName),SERVICE_ALL_ACCESS);

if b <= 0 then Exit;

try
Result := StartService(b,0,c);

CloseServiceHandle(b);
CloseServiceHandle(a);
except
CloseServiceHandle(b);
CloseServiceHandle(a);
Exit;
end;
end;


//停止服务
function StopServices(Const SvrName: String): Boolean;
var
a,b: SC_HANDLE;
d: TServiceStatus;
begin
Result := False;

a := OpenSCManager(nil,nil,SC_MANAGER_ALL_ACCESS);

if a <= 0 then Exit;

b := OpenService(a,PChar(SvrName),SERVICE_ALL_ACCESS);

if b <= 0 then Exit;

try
Result := ControlService(b,SERVICE_CONTROL_STOP,d);

CloseServiceHandle(a);
CloseServiceHandle(b);
except
CloseServiceHandle(a);
CloseServiceHandle(b);
Exit;
end;
end;


//查询当前服务的状态
function QueryServiceStatu(Const SvrName: String): String;
var
a,b: SC_HANDLE;
d: TServiceStatus;
begin
Result := '未安装';

a := OpenSCManager(nil,nil,SC_MANAGER_ALL_ACCESS);

if a <= 0 then Exit;

b := OpenService(a,PChar(SvrName),SERVICE_ALL_ACCESS);

if b <= 0 then Exit;

try
QueryServiceStatus(b,d);

if d.dwCurrentState = SERVICE_RUNNING then
Result := '启动' //Run
else if d.dwCurrentState = SERVICE_RUNNING then
Result := 'Wait' //Runing
else if d.dwCurrentState = SERVICE_START_PENDING then
Result := 'Wait' //Pause
else if d.dwCurrentState = SERVICE_STOP_PENDING then
Result := '停止' //Pause
else if d.dwCurrentState = SERVICE_PAUSED then
Result := '暂停' //Pause
else if d.dwCurrentState = SERVICE_STOPPED then
Result := '停止' //Stop
else if d.dwCurrentState = SERVICE_CONTINUE_PENDING then
Result := 'Wait' //Pause
else if d.dwCurrentState = SERVICE_PAUSE_PENDING then
Result := 'Wait'; //Pause

CloseServiceHandle(a);
CloseServiceHandle(b);
except
CloseServiceHandle(a);
CloseServiceHandle(b);
Exit;
end;
end;


{建立服务}
function CreateServices(Const SvrName,FilePath: String): Boolean;
var
a,b: SC_HANDLE;
begin
Result := False;

if FilePath ='' then Exit;

a := OpenSCManager(nil,nil,SC_MANAGER_CREATE_SERVICE);

if a <= 0 then Exit;
try
b := CreateService(a,PChar(SvrName),
PChar(SvrName),
SERVICE_ALL_ACCESS,
SERVICE_INTERACTIVE_PROCESS or SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,SERVICE_ERROR_NORMAL,
PChar(FilePath),nil,nil,nil,nil,nil);

if b <= 0 then begin
ShowMessage( SysErrorMessage( GetlastError ));
Exit;
end;

CloseServiceHandle(a);
CloseServiceHandle(b);

Result := True;
except
CloseServiceHandle(a);
CloseServiceHandle(b);
Exit;
end;
end;


{卸载服务}
function DeleteServices(Const SvrName: String): Boolean;
var
a,b: SC_HANDLE;
begin
Result := False;

a := OpenSCManager(nil,nil,SC_MANAGER_ALL_ACCESS);

if a <= 0 then Exit;

b := OpenService(a,PChar(SvrName),STANDARD_RIGHTS_REQUIRED);

if b <= 0 then Exit;

try
Result := DeleteService(b);

if not Result then
ShowMessage( SysErrorMessage( GetlastError ));

CloseServiceHandle(b);
CloseServiceHandle(a);

except
CloseServiceHandle(b);
CloseServiceHandle(a);
Exit;
end;
end;
wisenowa 2002-10-23
  • 打赏
  • 举报
回复
重赏之下

也没有勇夫?

哎...
TechnoFantasy 2002-10-23
  • 打赏
  • 举报
回复
回答第三个,首先引用microsoft iinternet control控件:
Dim xx As New InternetExplorer

xx.Visible = True
xx.Navigate "www.applevb.com"
neilwq 2002-10-23
  • 打赏
  • 举报
回复
俺有勇无谋

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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