請問如何將這一批次檔改寫成Delphi程式 |
尚未結案
|
fanny
一般會員 發表:10 回覆:26 積分:7 註冊:2002-07-19 發送簡訊給我 |
|
cmj
高階會員 發表:15 回覆:242 積分:226 註冊:2002-06-12 發送簡訊給我 |
參考下列函數 1.The GetSystemDirectory function retrieves the path of the Windows system directory UINT GetSystemDirectory( LPTSTR lpBuffer, // address of buffer for system directory UINT uSize ); // size of directory buffer 2.The WinExec function runs the specified application. UINT WinExec( LPCSTR lpCmdLine, // address of command line UINT uCmdShow); // window style for new application 3.The CreateProcess function creates a new process and its primary thread. The new process executes the specified executable file. BOOL CreateProcess( LPCTSTR lpApplicationName, // pointer to name of executable module LPTSTR lpCommandLine, // pointer to command line string LPSECURITY_ATTRIBUTES lpProcessAttributes, // pointer to process security attributes LPSECURITY_ATTRIBUTES lpThreadAttributes, // pointer to thread security attributes BOOL bInheritHandles, // handle inheritance flag DWORD dwCreationFlags, // creation flags LPVOID lpEnvironment, // pointer to new environment block LPCTSTR lpCurrentDirectory, // pointer to current directory name LPSTARTUPINFO lpStartupInfo, // pointer to STARTUPINFO LPPROCESS_INFORMATION lpProcessInformation // pointer to PROCESS_INFORMATION ); 1取windows之system目錄 2,3執行一支exe檔 更詳細資料可以參考windows api Help說明,也可以下載本站 Window API 函式說明檔(繁體,chm格式) , Cooky Kid |
wnhoo
高階會員 發表:75 回覆:443 積分:198 註冊:2003-04-22 發送簡訊給我 |
1.写批处理文件
var f:textfile;
begin
assignfile(f,'c:\delme.bat');
rewrite(f);
writeln(f,'@echo off');
writeln(f,'%windir%\SYSTEM\eSLogonc.exe close');
writeln(f,'%windir%\SYSTEM\esoehk.exe -u');
writeln(f,'CertSync.exe close');
writeln(f,'RmvReg.exe RmvReg.ini');
writeln(f,'del c:\delme.bat');
closefile(f);
winexec(pchar('c:\delme.bat'),SW_HIDE);
end; 2.直接执行
var
a,b,c,d,e,f:pchar;
begin
a:=pchar('COMMAND.COM /C @echo off ' ) ;
b:=pchar('COMMAND.COM /C %windir%\SYSTEM\eSLogonc.exe close');
c:=pchar('COMMAND.COM /C %windir%\SYSTEM\esoehk.exe -u ') ;
d:=pchar('COMMAND.COM /C CertSync.exe close' );
e:=pchar('COMMAND.COM /C RmvReg.exe RmvReg.ini');
f:=pchar('COMMAND.COM /C exit' );
WinExec(a, sw_hide);
WinExec(b, sw_hide);
WinExec(c, sw_hide);
WinExec(d, sw_hide);
WinExec(e, sw_hide);
WinExec(f, sw_hide);
end; 以上程序我均测试通过!!!
希望能对你有所帮助! 风花雪月 e梦情缘
------
风花雪月 e梦情缘 |
fanny
一般會員 發表:10 回覆:26 積分:7 註冊:2002-07-19 發送簡訊給我 |
引言: 1.写批处理文件 var f:textfile; begin assignfile(f,'c:\delme.bat'); rewrite(f); writeln(f,'@echo off'); writeln(f,'%windir%\SYSTEM\eSLogonc.exe close'); writeln(f,'%windir%\SYSTEM\esoehk.exe -u'); writeln(f,'CertSync.exe close'); writeln(f,'RmvReg.exe RmvReg.ini'); writeln(f,'del c:\delme.bat'); closefile(f); winexec(pchar('c:\delme.bat'),SW_HIDE); end; 2.直接执行 var a,b,c,d,e,f:pchar; begin a:=pchar('COMMAND.COM /C @echo off ' ) ; b:=pchar('COMMAND.COM /C %windir%\SYSTEM\eSLogonc.exe close'); c:=pchar('COMMAND.COM /C %windir%\SYSTEM\esoehk.exe -u ') ; d:=pchar('COMMAND.COM /C CertSync.exe close' ); e:=pchar('COMMAND.COM /C RmvReg.exe RmvReg.ini'); f:=pchar('COMMAND.COM /C exit' ); WinExec(a, sw_hide); WinExec(b, sw_hide); WinExec(c, sw_hide); WinExec(d, sw_hide); WinExec(e, sw_hide); WinExec(f, sw_hide); end; 以上程序我均测试通过!!! 希望能对你有所帮助! 风花雪月 e梦情缘Thanks~~ 可是我eSLogonc.exe還是沒有close WinExec(pchar('COMMAND.COM /C ' path 'CertSync.exe close'),sw_hide); Why~~ |
wnhoo
高階會員 發表:75 回覆:443 積分:198 註冊:2003-04-22 發送簡訊給我 |
//程序结束
application.Terminate; 如果你用的是批处理语句,请最好创建临时批处理文件。
在完成后删除,并关闭自己application.Terminate; var f:textfile;
begin
assignfile(f,'c:\delme.bat');
rewrite(f);
writeln(f,'@echo off');
writeln(f,'%windir%\SYSTEM\eSLogonc.exe close');
writeln(f,'%windir%\SYSTEM\esoehk.exe -u');
writeln(f,'CertSync.exe close');
writeln(f,'RmvReg.exe RmvReg.ini');
writeln(f,'del c:\delme.bat');
closefile(f);
winexec(pchar('c:\delme.bat'),SW_HIDE);
//close me
application.Terminate; end; command 参数供参考
Starts a new instance of the MS-DOS command interpreter. COMMAND [[drive:]path] [device] [/E:nnnnn] [/P] [/C string] [/MSG] [drive:]path Specifies the directory containing COMMAND.COM file. device Specifies the device to use for command input and output. /E:nnnnn Sets the initial environment size to nnnnn bytes. /P Makes the new command interpreter permanent (can't exit). /C string Carries out the command specified by string, and then stops. /MSG Specifies that all error messages be stored in memory. You need to specify /P with this switch. 风花雪月 e梦情缘
發表人 - wnhoo 於 2003/05/06 15:28:59
------
风花雪月 e梦情缘 |
wnhoo
高階會員 發表:75 回覆:443 積分:198 註冊:2003-04-22 發送簡訊給我 |
修改如下:(去掉 CLOSE参数)
var
a,b,c,d,e,f:pchar;
begin
a:=pchar('COMMAND.COM /C @echo off ' ) ;
b:=pchar('COMMAND.COM /C %windir%\SYSTEM\eSLogonc.exe');
c:=pchar('COMMAND.COM /C %windir%\SYSTEM\esoehk.exe -u ') ;
d:=pchar('COMMAND.COM /C CertSync.exe' );
e:=pchar('COMMAND.COM /C RmvReg.exe RmvReg.ini');
f:=pchar('COMMAND.COM /C exit' );
WinExec(a, sw_hide);
WinExec(b, sw_hide);
WinExec(c, sw_hide);
WinExec(d, sw_hide);
WinExec(e, sw_hide);
WinExec(f, sw_hide);
//close me
//application.Terminate;
end; 你可以试验一下 风花雪月 e梦情缘
------
风花雪月 e梦情缘 |
fanny
一般會員 發表:10 回覆:26 積分:7 註冊:2002-07-19 發送簡訊給我 |
|
wnhoo
高階會員 發表:75 回覆:443 積分:198 註冊:2003-04-22 發送簡訊給我 |
|
fanny
一般會員 發表:10 回覆:26 積分:7 註冊:2002-07-19 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |