L
li_zhifu
Unregistered / Unconfirmed
GUEST, unregistred user!
我有一多媒体软件需RealPlayer支持,现我已经完成了判断目标机器上是否安装了
RealPlayer的代码,但在执行并等待一步是却出了问题:
逻辑关系是这样的
是否安装了RealPlayer-------->Yes
| |
|No |
| |
V |
安装RealPlayer |
| |
V |
Wait Until Complete |
| |
------------------------
|
V
执行应用程序
|
V
Exit
在等待这一步,就执行不下去了,Autorun.exe 和 rp8-dc8o-cn-setup.exe就处于无限期
等待之中。代码如下
program AutoRun;
uses
Forms,
SysUtils,
Windows,
Registry,
Dialogs;
{$R *.res}
var sPathChar;
function WinExecAndWait32(FileName:String;
Visibility: Integer): Integer;
var
i:LPDWord;
zAppName:array[0..512] of char;
zCurDir:array[0..255] of char;
WorkDir:String;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
begin
StrPCopy(zAppName,FileName);
GetDir(0,WorkDir);
StrPCopy(zCurDir,WorkDir);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;
if not CreateProcess(nil,
zAppName, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
false, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block }
nil, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) then
Result := -1 { pointer to PROCESS_INF }
else
begin
WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
end;
end;
begin
Application.Initialize;
with TRegistry.Createdo
begin
RootKey:=HKEY_CLASSES_ROOT;
while Not OpenKey('CLSID/{CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA}',False)do
begin
ShowMessage('本多媒体光盘软件需RealPlayer G2支持,'#13'按“OK”安装RealPlayer G2');
GetMem(sPath,255);
GetSystemDirectory(sPath,255);
CopyFile(PChar(ExtractFilePath(Application.ExeName)+'diver/swflash.ocx'),PChar(ExtractFilePath(sPath)+'swflash.ocx'),False);
WinExecAndWait32(PChar('Regsvr32.exe /s '+ExtractFilePath(sPath)+'swflash.ocx'),0);
WinExecAndWait32(PChar(ExtractFilePath(Application.ExeName)+'diver/rp8-dc8o-cn-setup.exe'),SW_SHOWNORMAL);
FreeMem(sPath);
end;
CloseKey;
Free;
end;
WinExec(PChar(ExtractFilePath(Application.ExeName)+'Main.exe'),SW_NORMAL);
end.
RealPlayer的代码,但在执行并等待一步是却出了问题:
逻辑关系是这样的
是否安装了RealPlayer-------->Yes
| |
|No |
| |
V |
安装RealPlayer |
| |
V |
Wait Until Complete |
| |
------------------------
|
V
执行应用程序
|
V
Exit
在等待这一步,就执行不下去了,Autorun.exe 和 rp8-dc8o-cn-setup.exe就处于无限期
等待之中。代码如下
program AutoRun;
uses
Forms,
SysUtils,
Windows,
Registry,
Dialogs;
{$R *.res}
var sPathChar;
function WinExecAndWait32(FileName:String;
Visibility: Integer): Integer;
var
i:LPDWord;
zAppName:array[0..512] of char;
zCurDir:array[0..255] of char;
WorkDir:String;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
begin
StrPCopy(zAppName,FileName);
GetDir(0,WorkDir);
StrPCopy(zCurDir,WorkDir);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;
if not CreateProcess(nil,
zAppName, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
false, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block }
nil, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) then
Result := -1 { pointer to PROCESS_INF }
else
begin
WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
end;
end;
begin
Application.Initialize;
with TRegistry.Createdo
begin
RootKey:=HKEY_CLASSES_ROOT;
while Not OpenKey('CLSID/{CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA}',False)do
begin
ShowMessage('本多媒体光盘软件需RealPlayer G2支持,'#13'按“OK”安装RealPlayer G2');
GetMem(sPath,255);
GetSystemDirectory(sPath,255);
CopyFile(PChar(ExtractFilePath(Application.ExeName)+'diver/swflash.ocx'),PChar(ExtractFilePath(sPath)+'swflash.ocx'),False);
WinExecAndWait32(PChar('Regsvr32.exe /s '+ExtractFilePath(sPath)+'swflash.ocx'),0);
WinExecAndWait32(PChar(ExtractFilePath(Application.ExeName)+'diver/rp8-dc8o-cn-setup.exe'),SW_SHOWNORMAL);
FreeMem(sPath);
end;
CloseKey;
Free;
end;
WinExec(PChar(ExtractFilePath(Application.ExeName)+'Main.exe'),SW_NORMAL);
end.