难题呀,各位帮帮忙吧。(200分)

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

wenx

Unregistered / Unconfirmed
GUEST, unregistred user!
怎么用程序控制让本地的系统时间走快点,例如本来一分钟的时间实际上只用半分钟。<br>怎么用程序实现?
 
你到底想干嘛呀??<br><br>变速齿轮行吗???行的话,我有本书上的例子给发给你.
 
变速齿轮不行呀,是根据系统时间来累积的,而不是靠循环累积时间。<br>这只是我的猜测,但变速齿轮真的不行。
 
windows 9x<br>procedure Speed(count:word); stdcall;<br>const ExceptionUsed = $03; &nbsp; &nbsp; &nbsp; &nbsp;{ 中断号也可以用其它的中断号}<br>var<br>&nbsp; IDT : array [0..5] of byte; { 保存中断描述符表}<br>&nbsp; lpOldGate : dword; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{存放旧向量}<br>begin<br>&nbsp; &nbsp;asm<br>&nbsp; &nbsp; &nbsp;push ebx<br>&nbsp; &nbsp; &nbsp;sidt IDT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{读入中断描述符表}<br>&nbsp; &nbsp; &nbsp;mov ebx, dword ptr [IDT+2]{IDT表基地址}<br>&nbsp; &nbsp; &nbsp;add ebx, 8*ExceptionUsed &nbsp;{计算中断在中断描述符表中的位置}<br>&nbsp; &nbsp; &nbsp;cli &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {关中断}<br>&nbsp; &nbsp; &nbsp;mov dx, word ptr [ebx+6] &nbsp;{取6,7字节 另外4字节用于门属性和选择子 }<br>&nbsp; &nbsp; &nbsp;shl edx, 16d &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{左移16位}<br>&nbsp; &nbsp; &nbsp;mov dx, word ptr [ebx] &nbsp; &nbsp;{取1,2字节 &nbsp;}<br>&nbsp; &nbsp; &nbsp;mov [lpOldGate], edx &nbsp; &nbsp; &nbsp;{保存旧的中断门}<br>&nbsp; &nbsp; &nbsp;mov eax, offset @@Ring0Code &nbsp; {修改向量,指向Ring0级代码段}<br>&nbsp; &nbsp; &nbsp;mov word ptr [ebx], ax &nbsp; &nbsp; &nbsp; &nbsp;{低16位,保存到1,2字}<br>&nbsp; &nbsp; &nbsp;shr eax, 16d<br>&nbsp; &nbsp; &nbsp;mov word ptr [ebx+6], ax &nbsp; &nbsp; &nbsp;{高16位,保存到6,7位}<br>&nbsp; &nbsp; &nbsp;int ExceptionUsed &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {发生中断}<br>&nbsp; &nbsp; &nbsp;mov ebx, dword ptr [IDT+2] &nbsp; &nbsp;{重新定位到中断描述符表中}<br>&nbsp; &nbsp; &nbsp;add ebx, 8*ExceptionUsed<br>&nbsp; &nbsp; &nbsp;mov edx, [lpOldGate]<br>&nbsp; &nbsp; &nbsp;mov word ptr [ebx], dx<br>&nbsp; &nbsp; &nbsp;shr edx, 16d<br>&nbsp; &nbsp; &nbsp;mov word ptr [ebx+6], dx &nbsp; &nbsp; &nbsp;{恢复被改了的向量}<br>&nbsp; &nbsp; &nbsp;pop ebx<br>&nbsp; &nbsp; &nbsp;jmp @@exit1<br>&nbsp; &nbsp; @@Ring0Code: &nbsp; &nbsp;{Ring0级代码段}<br>&nbsp; &nbsp; &nbsp;{0011 0100}<br>&nbsp; &nbsp; &nbsp; mov al,$34 &nbsp; &nbsp;{写入8253控制寄存器,设置写0号定时器}<br>&nbsp; &nbsp; &nbsp; out $43,al<br>&nbsp; &nbsp; &nbsp; mov ax,Count<br>&nbsp; &nbsp; &nbsp; out $40,al &nbsp; &nbsp;{写定时值低位}<br>&nbsp; &nbsp; &nbsp; mov al,ah<br>&nbsp; &nbsp; &nbsp; out $40,al &nbsp; &nbsp;{写定时值高位}<br>&nbsp; &nbsp; &nbsp; iretd &nbsp; &nbsp; &nbsp; &nbsp; {中断返回}<br>&nbsp; &nbsp;@@exit1:<br>&nbsp; &nbsp;end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp;Speed($6000); //慢<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp;Speed($1742); <br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp;Speed($500); //快<br>end;<br>
 
winnt/2000 单元<br>unit UnitPortTalk;<br><br>interface<br><br>uses<br>&nbsp; Windows, SysUtils, Dialogs,WinSvc;<br><br>const<br>&nbsp; PORTTALK_TYPE = 40000; { 32768-65535是保留给用户使用的}<br>&nbsp; METHOD_BUFFERED = 0;<br>&nbsp; FILE_ANY_ACCESS = 0;<br>&nbsp; IOCTL_IOPM_RESTRICT_ALL_ACCESS &nbsp;= PORTTALK_TYPE shl 16 +<br>&nbsp; &nbsp; $900 shl 2 +<br>&nbsp; &nbsp; METHOD_BUFFERED +<br>&nbsp; &nbsp; FILE_ANY_ACCESS shl 14;<br><br>&nbsp; IOCTL_IOPM_ALLOW_EXCUSIVE_ACCESS = PORTTALK_TYPE shl 16 +<br>&nbsp; &nbsp; $901 shl 2 +<br>&nbsp; &nbsp; METHOD_BUFFERED +<br>&nbsp; &nbsp; FILE_ANY_ACCESS shl 14;<br><br><br>&nbsp; IOCTL_SET_IOPM = PORTTALK_TYPE shl 16 +<br>&nbsp; &nbsp; $902 shl 2 +<br>&nbsp; &nbsp; METHOD_BUFFERED +<br>&nbsp; &nbsp; FILE_ANY_ACCESS shl 14;<br><br>&nbsp; IOCTL_ENABLE_IOPM_ON_PROCESSID = PORTTALK_TYPE shl 16 +<br>&nbsp; &nbsp; $903 shl 2 +<br>&nbsp; &nbsp; METHOD_BUFFERED +<br>&nbsp; &nbsp; FILE_ANY_ACCESS shl 14;<br><br>&nbsp; IOCTL_READ_PORT_UCHAR = PORTTALK_TYPE shl 16 +<br>&nbsp; &nbsp; $904 shl 2 +<br>&nbsp; &nbsp; METHOD_BUFFERED +<br>&nbsp; &nbsp; FILE_ANY_ACCESS shl 14;<br><br>&nbsp; IOCTL_WRITE_PORT_UCHAR = PORTTALK_TYPE shl 16 +<br>&nbsp; &nbsp; $905 shl 2 +<br>&nbsp; &nbsp; METHOD_BUFFERED +<br>&nbsp; &nbsp; FILE_ANY_ACCESS shl 14;<br><br>&nbsp; function OpenPortTalk:boolean;<br>&nbsp; procedure ClosePortTalk;<br>&nbsp; procedure outportb(PortAddress:word;byte1:byte);<br>&nbsp; function inportb(PortAddress:word):byte;<br><br>&nbsp; function StartPortTalkDriver:boolean;<br>&nbsp; procedure InstallPortTalkDriver;<br>&nbsp; <br>var<br>&nbsp; PortTalk_Handle:THANDLE; &nbsp; &nbsp; &nbsp; &nbsp;{PortTalk句柄}<br><br>implementation<br><br><br>procedure outportb(PortAddress:word;byte1:byte);<br>var<br>&nbsp; &nbsp; error:boolean;<br>&nbsp; &nbsp; BytesReturned:DWORD;<br>&nbsp; &nbsp; Buffer:array[0..2]of byte;<br>&nbsp; &nbsp; pBuffer:pword;<br>begin<br>&nbsp; &nbsp; pBuffer := pword(@Buffer[0]);<br>&nbsp; &nbsp; pBuffer^ := PortAddress;<br>&nbsp; &nbsp; Buffer[2] := byte1;<br><br>&nbsp; &nbsp; error := DeviceIoControl(PortTalk_Handle,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cardinal(IOCTL_WRITE_PORT_UCHAR),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Buffer,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BytesReturned,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil);<br><br>&nbsp; &nbsp; if (not error) then showmessagefmt('从PortTalk输出端口数据时出错:%d',[GetLastError]);<br>end;<br><br>function inportb(PortAddress:word):byte;<br>var<br>&nbsp; &nbsp; error:boolean;<br>&nbsp; &nbsp; BytesReturned:DWORD;<br>&nbsp; &nbsp; Buffer:array[0..2]of byte;<br>&nbsp; &nbsp; pBuffer:pword;<br>begin<br>&nbsp; &nbsp; pBuffer := pword(@Buffer[0]);<br>&nbsp; &nbsp; pBuffer^ := PortAddress;<br><br>&nbsp; &nbsp; error := DeviceIoControl(PortTalk_Handle,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cardinal(IOCTL_READ_PORT_UCHAR),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Buffer,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Buffer,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BytesReturned,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil);<br><br>&nbsp; &nbsp; if (not error) then showmessagefmt('从PortTalk输入端口数据时出错:%d',[GetLastError]);<br>&nbsp; &nbsp; result:=Buffer[0];<br>end;<br><br>function OpenPortTalk:boolean;<br>begin<br>&nbsp; &nbsp; {打开PortTalk,如果不能打开,则安装它}<br>&nbsp; &nbsp; PortTalk_Handle := CreateFile('//./PortTalk',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GENERIC_READ,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nil,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OPEN_EXISTING,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FILE_ATTRIBUTE_NORMAL,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0);<br><br>&nbsp; &nbsp; if(PortTalk_Handle = INVALID_HANDLE_VALUE) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {启动驱动程序}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StartPortTalkDriver;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {再次打开PortTalk}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PortTalk_Handle := CreateFile('//./PortTalk',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GENERIC_READ,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nil,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OPEN_EXISTING,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FILE_ATTRIBUTE_NORMAL,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0);<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(PortTalk_Handle = INVALID_HANDLE_VALUE) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage('PortTalk: 不能存取PortTalk,请确保驱动程序已安装。');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; result:=true;<br>end;<br><br>procedure ClosePortTalk;<br>begin<br>&nbsp; &nbsp; CloseHandle(PortTalk_Handle);<br>end;<br><br>function StartPortTalkDriver:boolean;<br>type<br>&nbsp; TNewStartService=function (hService: SC_HANDLE; dwNumServiceArgs: DWORD;<br>&nbsp; &nbsp; lpServiceArgVectors: PPChar): BOOL; stdcall;<br>var<br>&nbsp; &nbsp; SchSCManager:SC_HANDLE;<br>&nbsp; &nbsp; schService:SC_HANDLE;<br>&nbsp; &nbsp; ret:BOOL;<br>&nbsp; &nbsp; err:DWORD;<br>begin<br><br>&nbsp; &nbsp; {打开Service Control Manager}<br>&nbsp; &nbsp; SchSCManager := OpenSCManager (nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { 机器 (nil = 本机) }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ 数据库 (nil = 默认 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SC_MANAGER_ALL_ACCESS); &nbsp; &nbsp; { 访问权 }<br><br>&nbsp; &nbsp; if (SchSCManager = 0) then<br>&nbsp; &nbsp; &nbsp; if (GetLastError = ERROR_ACCESS_DENIED) then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ 没有权限打开SCM管理,必须是poor用户}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;showmessage('PortTalk: 没有权限访问Service Control Manager,'#$D#$A+<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'不能安装和启动PortTalk,请使用超级用户来安装。');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br>&nbsp; &nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; repeat begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{打开PortTalk服务数据库}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;schService := OpenService(SchSCManager, &nbsp; &nbsp; &nbsp; {服务数据库句柄}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'PortTalk', &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{要启动的服务名}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SERVICE_ALL_ACCESS); {存取的权限}<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (schService = 0) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case (GetLastError) of<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ERROR_ACCESS_DENIED:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage('PortTalk: 没有权限访问PortTalk服务数据库');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ERROR_INVALID_NAME:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage('PortTalk: 指定的服务名无效');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ERROR_SERVICE_DOES_NOT_EXIST:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage('PortTalk: PortTalk驱动程序不存在');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InstallPortTalkDriver;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp;end until (schService &lt;&gt; 0);<br><br>&nbsp; &nbsp; {启动PortTalk驱动程序,如果发生错误,一般是由于PortTalk.SYS不存在。}<br>&nbsp; &nbsp; <br>&nbsp; &nbsp; ret := TNewStartService(@StartService) (schService, &nbsp;{服务标识}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {参数个数}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil); &nbsp; &nbsp; &nbsp; &nbsp; {参数}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; if (ret) then //showmessage('PortTalk: PortTalk安装成功!')<br>&nbsp; &nbsp; else begin<br>&nbsp; &nbsp; &nbsp; &nbsp; err := GetLastError;<br>&nbsp; &nbsp; &nbsp; &nbsp; if (err = ERROR_SERVICE_ALREADY_RUNNING) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage('PortTalk: PortTalk已经安装')<br>&nbsp; &nbsp; &nbsp; &nbsp; else begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage('PortTalk: 启动PortTalk时发生未知错误。'+#$D#$A+<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'PortTalk.SYS没有放入/System32/Drivers目录吗?');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; {关闭Service Control Manager}<br>&nbsp; &nbsp; CloseServiceHandle (schService);<br>&nbsp; &nbsp; result:=TRUE;<br>end;<br><br>procedure InstallPortTalkDriver;<br>var<br>&nbsp; &nbsp; SchSCManager:SC_HANDLE;<br>&nbsp; &nbsp; schService:SC_HANDLE;<br>&nbsp; &nbsp; err:DWORD;<br>&nbsp; &nbsp; DriverFileName:array[0..79]of CHAR;<br>begin<br>&nbsp; &nbsp; if (GetSystemDirectory(DriverFileName, 55)=0) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;showmessage('PortTalk: 取System目录出错');<br>&nbsp; &nbsp; &nbsp; &nbsp;exit;<br>&nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; {加入驱动程序文件名}<br>&nbsp; &nbsp; lstrcat(DriverFileName,'/Drivers/PortTalk.sys');<br>&nbsp; &nbsp; showmessagefmt('PortTalk: 拷贝驱动程序到%s',[DriverFileName]);<br><br>&nbsp; &nbsp; {拷贝驱动程序到System32/drivers目录,如果出错,一般是因为文件不存在。}<br><br>&nbsp; &nbsp; if (not CopyFile('PortTalk.sys', DriverFileName, FALSE)) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;showmessagefmt('PortTalk: 拷贝驱动程序到以下位置出错:%s'+#$D#$A+<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '请手工拷贝到system32/driver目录',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [DriverFileName]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br>&nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; {打开Service Control Manager}<br>&nbsp; &nbsp; SchSCManager := OpenSCManager (nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { 机器 (nil = 本机) }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ 数据库 (nil = 默认 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SC_MANAGER_ALL_ACCESS); { 访问权 }<br><br>&nbsp; &nbsp; schService := CreateService (SchSCManager, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { SCManager数据库 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'PortTalk', &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ 服务个数 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'PortTalk', &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ 显示名 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SERVICE_ALL_ACCESS, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ 权限 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SERVICE_KERNEL_DRIVER, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { 服务类别 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SERVICE_DEMAND_START, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ 启动类别 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SERVICE_ERROR_NORMAL, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ 出错控件类别 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'System32/Drivers/PortTalk.sys', &nbsp; { 服务二进制文件 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { 加入的组 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { 标识 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { 隶属 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { 本地帐户 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ 密码 }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<br><br>&nbsp; &nbsp; if (schService = 0) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;err := GetLastError;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (err = ERROR_SERVICE_EXISTS) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;showmessage('PortTalk: 驱动程序不存在。')<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else &nbsp;showmessage('PortTalk:建立服务时发生未知的错误。');<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; else showmessage('PortTalk: 成功安装!');<br><br>&nbsp; &nbsp; { 关闭Service Control Manager }<br>&nbsp; &nbsp; CloseServiceHandle (schService);<br>end;<br>end.<br><br>调用<br>uses UnitPortTalk;<br><br>{$R *.DFM}<br><br>procedure Speed(count:word);<br>begin<br>&nbsp; if not OpenPortTalk then exit;<br>&nbsp; outportb($43,$34); {写入8253控制寄存器,设置写0号定时器}<br>&nbsp; outportb($40,lo(count)); &nbsp;{写定时值低位}<br>&nbsp; outportb($40,hi(count)); &nbsp;{写定时值高位}<br>&nbsp; ClosePortTalk;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp;Speed($6000); //慢<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp;Speed($2ea5); &nbsp; <br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp;Speed($500); //快<br>end;<br>
 
楼上的就是变速齿轮吧
 
<br>你到底想做什么???<br><br>楼上的方法不行吗?
 
我已经说过了,变速齿轮不行的,上面的代码就是变速齿轮的delphi版本,我有,不管用的。
 
我想让本地时间跑快点,这样靠累积时间的游戏就好办了。
 
没道理啊,积累时间难道不用取系统时间吗?<br>上面的变速齿轮应该可以的
 
如果是用服务器的时间,<br>你只好攻击服务器了。
 
后退
顶部