home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Multimedia Term Paper
/
TERM_PAPER.iso
/
progfile.sfs
/
LAUNCHER.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-07-18
|
3KB
|
114 lines
program Launcher;
uses
WinTypes, WinProcs, IniFiles, SysUtils;
{$R *.RES}
Const
cProductIdFileName = 'ID921171.ID_'; { !!! MUST match PRODUCT_ID_FILENAME in CUSTOM.RUL !!! }
cProgramKeyName = '92117-1'; { !!! MUST match APP_UPC_CODE in CUSTOM.RUL !!! }
cSectionName = 'Sofsource'; { !!! MUST match PROGRAM_FOLDER_NAME in CUSTOM.RUL !!! }
cPermanentSetupLog = 'SOF_LOG_.INI'; { Don't change this value }
const
DosDelimSet : set of Char = ['\', ':', #0];
Var
IniLog : TIniFile;
FileToFind,
RecordedDestination : String;
Function AddBackSlash( Const DirName : String ) : String;
{ Add a default backslash to a directory name }
Begin
If DirName[ Length(DirName) ] in DosDelimSet Then
AddBackSlash := DirName
ELSE
AddBackSlash := DirName + '\';
End; { Function AddBackSlash }
Function JustPathname( Const PathName : String ) : String;
{ Return just the drive:directory portion of a pathname }
Var
I : Word;
Begin
I := Succ( Word( Length(PathName) ) );
Repeat
Dec(I);
Until (PathName[I] in DosDelimSet) or (I = 0);
If I = 0 Then { Had no drive or directory name }
JustPathname[0] := #0
ELSE
If I = 1 Then { Either the root directory of default drive or invalid pathname }
JustPathname := PathName[1]
ELSE
If (PathName[I] = '\') Then
Begin
If PathName[Pred(I)] = ':' Then { Root directory of a drive, leave trailing backslash }
JustPathname := Copy(PathName, 1, I)
ELSE { Subdirectory, remove the trailing backslash }
JustPathname := Copy(PathName, 1, Pred(I));
End
ELSE { Either the default directory of a drive or invalid pathname }
JustPathname := Copy(PathName, 1, I);
End; { Function JustPathName }
Procedure LaunchSetup;
Var
FileToExecute : String;
pFileToExecute : Array[0..254] of Char;
Begin
FileToExecute := AddBackSlash( JustPathName( ParamStr(0)) );
ChDir( FileToExecute );
FileToExecute := AddBackSlash( FileToExecute) + 'SETUP.EXE AUTOPLAY';
StrPCopy( pFileToExecute, FileToExecute );
If WinExec( pFileToExecute, sw_ShowNormal ) < 32 Then
Begin
MessageBeep( mb_IconHand );
MessageBox( 0, 'Unable to launch "SETUP.EXE"', 'Error', 0 );
End;
End; { Procedure LaunchSetup }
begin
IniLog := TIniFile.Create( cPermanentSetupLog );
RecordedDestination := IniLog.ReadString( cSectionName, cProgramKeyName, '' );
IniLog.Free;
If RecordedDestination = '' Then
LaunchSetup
ELSE
Begin
FileToFind := AddBackSlash( RecordedDestination ) + cProductIdFileName;
If NOT FileExists( FileToFind ) Then
LaunchSetup;
End;
end.