在dos 下用命令启动一个服务:NET START "Windows Desktop Reminder"

一下为用delphi启动服务:

Function RunProcess(sApp,sPara:String):Boolean;
begin
ZeroMemory(@sStartInfo, sizeof(sStartInfo));
SStartInfo.cb := sizeof(sStartInfo);
begin
SStartInfo.dwX:=0;
SStartInfo.dwY :=0;
SStartInfo.dwXSize:=0;
SStartInfo.dwYSize:=0;
SStartInfo.wShowWindow:=SW_HIDE;
SStartInfo.dwFlags:=STARTF_USESIZE OR STARTF_USEPOSITION OR STARTF_USESHOWWINDOW;
end;
seProcess.nLength := sizeof(seProcess);
seProcess.lpSecurityDescriptor := PChar(nil);
seProcess.bInheritHandle := true;
seThread.nLength := sizeof(seThread);
seThread.lpSecurityDescriptor := PChar(nil);
seThread.bInheritHandle := true;
Result:= CreateProcess(PChar(nil), PChar(sAPP+' '+sPara), @seProcess, @seThread,
false, CREATE_DEFAULT_ERROR_MODE,
Pchar(nil), Pchar(nil), sStartInfo, PProcInfo);
end; 
 procedure RunService(sService:String);
begin
RunProcess('Net.exe','Start "'+sService+'"'); // "Windows 2K/XP 登录桌面提示"');
end; procedure TForm1.FormCreate(Sender: TObject);
begin
width:=;
height:=;
RunService('Windows Desktop Reminder');
Application.Terminate;
end;

调用代码

 unit uStartFrm;

 interface

 uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs; type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; Function RunProcess(sApp,sPara:String):Boolean;
procedure RunService(sService:String); var
sStartInfo: STARTUPINFO;
seProcess, seThread: SECURITY_ATTRIBUTES;
PProcInfo: PROCESS_INFORMATION; var
Form1: TForm1; implementation {$R *.dfm} Function RunProcess(sApp,sPara:String):Boolean;
begin
ZeroMemory(@sStartInfo, sizeof(sStartInfo));
SStartInfo.cb := sizeof(sStartInfo);
begin
SStartInfo.dwX:=;
SStartInfo.dwY :=;
SStartInfo.dwXSize:=;
SStartInfo.dwYSize:=;
SStartInfo.wShowWindow:=SW_HIDE;
SStartInfo.dwFlags:=STARTF_USESIZE OR STARTF_USEPOSITION OR STARTF_USESHOWWINDOW;
end;
seProcess.nLength := sizeof(seProcess);
seProcess.lpSecurityDescriptor := PChar(nil);
seProcess.bInheritHandle := true;
seThread.nLength := sizeof(seThread);
seThread.lpSecurityDescriptor := PChar(nil);
seThread.bInheritHandle := true;
Result:= CreateProcess(PChar(nil), PChar(sAPP+' '+sPara), @seProcess, @seThread,
false, CREATE_DEFAULT_ERROR_MODE,
Pchar(nil), Pchar(nil), sStartInfo, PProcInfo);
end; procedure RunService(sService:String);
begin
RunProcess('Net.exe','Start "'+sService+'"'); // "Windows 2K/XP 登录桌面提示"');
end; procedure TForm1.FormCreate(Sender: TObject);
begin
width:=;
height:=;
RunService('Windows Desktop Reminder');
Application.Terminate;
end; end.

全部代码

启动windows的服务--《用delphi开发共享软件》-15.2桌面提示器的更多相关文章

  1. 字体和壁纸合并后再更改壁纸--《用delphi开发共享软件》-15.2桌面提示器

    procedure TFrmPlay.mnDeskPicClick(Sender: TObject); Var s:String; i:Integer; begin //s:=Path+'SetPic ...

  2. 《用delphi开发共享软件》-15.2桌面提示器

    打开一个配置文件: 打开一个配置文件 操作TStringGrid Procedure EmptyGrid(Var sg:TStringGrid); Var i:Integer; begin do sg ...

  3. windows 10 无法启动 windows update 服务 错误 0x80070005 拒绝访问

    windows 10 无法启动 windows update 服务 错误 0x80070005 拒绝访问: 解决方法: 首先重命名系统盘 windows目录下的代号为“SoftwareDistribu ...

  4. win7防火墙打不开(无法启动windows firewall服务)

    点击windows 7控制面板中防火墙的“推荐配置”没有反应:打开“服务”,无法启动windows firewall,并报错.  可能很多的win7用户都碰到过这样的一种情况,那就是win7的防火墙打 ...

  5. 设置随机启动--《用delphi开发共享软件》-15.1任务管理器

    在设置窗体中 chkAutoStart: TCheckBox; 在设置窗体中 chkAutoStart: TCheckBox; procedure TFrmSetup.FormCreate(Sende ...

  6. 软件打开时间、窗体透明度、背景色---《用delphi开发共享软件》-15.1任务管理器

    1.计算软件启动了多长时间:用定时器,每分钟触发一次: procedure TFrmMain.tmCheckLegalTimer(Sender: TObject);Var Minutes:LongIn ...

  7. 实现窗体随着鼠标移动(控件)--《用delphi开发共享软件》-15.1任务管理器

    private //窗体移动: OldPos,NewPos:TPoint; bMove:Boolean; procedure TForm1.FormMouseDown(Sender: TObject; ...

  8. Windows Installer 服务启动错误 14007 的解决办法

    问题: 在 本地计算机 无法启动 Windows Installer 服务. 错误代码 14007: 在活动的激活上下文中没有找到任何查找密钥. 这个问题似乎涉及到 Windows Installer ...

  9. Windows Time服务无法启动 错误5拒绝访问

    接着上次写的文章 XP和Win7设置系统自动同步系统时间方法 本文就把故障出现的过程和解决方法一共写下来,希望大家可以看到本文在解决此项服务的思路.大家以后出现类似的问题和问题可以一样使用此类方法解决 ...

随机推荐

  1. 非Unicode工程读取Unicode文件

    MyUnicodeReader.h #pragma once /******************************************************************** ...

  2. Maven Java EE Configuration Problem 的完美解决办法

    背景: 最近在修改项目的时候,发现修改了项目依赖以后会出现如下图:Maven Java EE Configuration Problem 的问题,对于有强迫症的我来说,看到项目上面有个很小的红色小叉号 ...

  3. 简易qq对话框

    //本程序由QT5 creator编译可运行 //dialog.h 1 #ifndef DIALOG_H #define DIALOG_H #include <QDialog> class ...

  4. MVC控制下输出图片、javascript与json格式

    /// <summary> /// 输出图片 /// </summary> /// <returns></returns> public ActionR ...

  5. 四、优化及调试--网站优化--SEO在网页制作中的应用

    SEO分类:白帽SEO.黑帽SEO 白帽SEO: 内容上的SEO: 网站标题.关键字.描述 网站内容优化 Robot.txt文件 网站地图 增加外链引用 前端SEO: 网站结构布局优化 扁平化结构(一 ...

  6. VCC、VDD、VSS、 VEE 和VPP的区别

    在电子电路中,常可以看到VCC.VDD和VSS三种不同的符号,它们有什么区别呢? 一.解释 VCC:C=circuit 表示电路的意思, 即接入电路的电压: VDD:D=device 表示器件的意思, ...

  7. C#回顾 – 4.IEnumerable 集合

         

  8. Jsonp跨域访问原理和实例

    >>什么是跨域 出于安全方面的考虑,页面中的JavaScript无法访问其他服务器上的数据,当前域名的js只能读取同域下的窗口属性,即同源策略.而跨域就是通过某些手段来绕过同源策略限制,实 ...

  9. bt和wifi的共存

    转自:http://bbs.52rd.com/Thread-291892-1-1.html 蓝牙和802.11b/g/n都可能工作在2.4GISM,可能互相干扰.干扰的典型应用之一是VOIP,用手机的 ...

  10. 无废话Android之smartimageview使用、android多线程下载、显式意图激活另外一个activity,检查网络是否可用定位到网络的位置、隐式意图激活另外一个activity、隐式意图的配置,自定义隐式意图、在不同activity之间数据传递(5)

    1.smartimageview使用 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&q ...