Q
qj_chen
Unregistered / Unconfirmed
GUEST, unregistred user!
以下是一段执行外部程序--改变“控制面板”中的日期格式--的源代码(从大富翁<br>上搬来的)。如果改变了日期格式,一按“确定”就死机。请教专家,原因何在?我的要求<br>是等待进程结束,而不是改变日期的方法!!!<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls, WinProcs, ShellAPI;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> <br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var <br> cmdStrchar; <br> StartupInfo: TStartupInfo;<br> ProcessInfo: TProcessInformation;<br>begin<br> cmdstr:=pchar('RunDLL32.exe Shell32.DLL,Control_RunDLL Intl.cpl,,4');<br> {建立进程并等待其结束}<br> fillchar(StartupInfo,sizeof(StartupInfo),0);<br> CreateProcess(nil,cmdstr,nil,nil,false,0,nil,nil,StartupInfo,ProcessInfo);<br> With ProcessInfo do<br> begin<br> CloseHandle(hThread);<br> WaitForSingleObject(hProcess, INFINITE);<br> CloseHandle(hProcess);<br> end;<br>end;<br><br>end.<br>