启动windows的服务--《用delphi开发共享软件》-15.2桌面提示器
在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桌面提示器的更多相关文章
- 字体和壁纸合并后再更改壁纸--《用delphi开发共享软件》-15.2桌面提示器
procedure TFrmPlay.mnDeskPicClick(Sender: TObject); Var s:String; i:Integer; begin //s:=Path+'SetPic ...
- 《用delphi开发共享软件》-15.2桌面提示器
打开一个配置文件: 打开一个配置文件 操作TStringGrid Procedure EmptyGrid(Var sg:TStringGrid); Var i:Integer; begin do sg ...
- windows 10 无法启动 windows update 服务 错误 0x80070005 拒绝访问
windows 10 无法启动 windows update 服务 错误 0x80070005 拒绝访问: 解决方法: 首先重命名系统盘 windows目录下的代号为“SoftwareDistribu ...
- win7防火墙打不开(无法启动windows firewall服务)
点击windows 7控制面板中防火墙的“推荐配置”没有反应:打开“服务”,无法启动windows firewall,并报错. 可能很多的win7用户都碰到过这样的一种情况,那就是win7的防火墙打 ...
- 设置随机启动--《用delphi开发共享软件》-15.1任务管理器
在设置窗体中 chkAutoStart: TCheckBox; 在设置窗体中 chkAutoStart: TCheckBox; procedure TFrmSetup.FormCreate(Sende ...
- 软件打开时间、窗体透明度、背景色---《用delphi开发共享软件》-15.1任务管理器
1.计算软件启动了多长时间:用定时器,每分钟触发一次: procedure TFrmMain.tmCheckLegalTimer(Sender: TObject);Var Minutes:LongIn ...
- 实现窗体随着鼠标移动(控件)--《用delphi开发共享软件》-15.1任务管理器
private //窗体移动: OldPos,NewPos:TPoint; bMove:Boolean; procedure TForm1.FormMouseDown(Sender: TObject; ...
- Windows Installer 服务启动错误 14007 的解决办法
问题: 在 本地计算机 无法启动 Windows Installer 服务. 错误代码 14007: 在活动的激活上下文中没有找到任何查找密钥. 这个问题似乎涉及到 Windows Installer ...
- Windows Time服务无法启动 错误5拒绝访问
接着上次写的文章 XP和Win7设置系统自动同步系统时间方法 本文就把故障出现的过程和解决方法一共写下来,希望大家可以看到本文在解决此项服务的思路.大家以后出现类似的问题和问题可以一样使用此类方法解决 ...
随机推荐
- HDU 5831 Rikka with Parenthesis II (贪心) -2016杭电多校联合第8场
题目:传送门. 题意:T组数据,每组给定一个长度n,随后给定一个长度为n的字符串,字符串只包含'('或')',随后交换其中两个位置,必须交换一次也只能交换一次,问能否构成一个合法的括号匹配,就是()( ...
- addsubview跟insertsubview的区别
子视图是以栈的方式存放的. 每次addsubview时都是在最后面添加. 每次在addsubview前和addsubview后可以看看[self.view.subViews count]: 你看看你的 ...
- osg 纹理访问器
#include<osgViewer/Viewer> #include<osg/Node>#include<osg/Geode>#include<osg/Gr ...
- 访问javaweb服务器sessionid存放问题
sessionid存放在cookies里面,key是JSESSIONID
- DB2 上copy表结构及数据
现已有一行数据,要复制为多行,每行只有两个字段值不同,db2 没有sql server的top关键字,本只想复制几次,然后update逐条数据,发现不行. 然后想到不如临时创建一张表B,插入此行数据, ...
- NYOJ题目916胖子小的百宝袋
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAsQAAAL6CAIAAAC+R9cJAAAgAElEQVR4nOydO5LcvM6GzyYmn4U47o
- Android5.0如何正确启用isLoggable(二) 理分析
转自:http://www.it165.net/pro/html/201506/43374.html 概要 在上文<Android 5.0 如何正确启用isLoggable(一)__使用详解&g ...
- Pyqt 打包资源文件
用打包工具将做好的Pyqt程序打包成exe后发现引用的资源图片都显示不了? 是否遇到了和我一样的问题呢.google之后找到了方法,一种方法是在程序中引用外部资源,另外一种方法是将资源文件转换为py文 ...
- 【翻译四】java-并发之线程暂停
Pausing Execution with Sleep Thread.sleep causes the current thread to suspend execution for a speci ...
- 6-04使用SQL语句更新数据
修改数据语法: UPDATTE 表名 SET 列名 =更新值 WHERE 更新条件 1:省略WHERE条件的更新: 更新性别: UPDATE UserInfo SET Gender=1 三行受影响. ...