########
# DEFiNE
########
!define APP64 VidCoder64
!define 64    VidCoder64\VidCoder.exe
;===
!define EXE64 `$EXEDIR\App\${64}`
;===
!define SET64 `Kernel32::SetEnvironmentVariable(t "VIDCODER", t "VidCoder64")`
########
# CUSTOM
########
${SegmentFile}
${Segment.OnInit}
	Push $0
	${IsWOW64} $0
	StrCmp $0 0 ThirtyTwoBit
	IfFileExists `${EXE64}` 0 EightySixBit
	SetRegView 64
	System::Call `${SET64}`
	${WriteSettings} 64 Architecture
		Goto END
	EightySixBit:
	System::Call `${SET32}`
	${WriteSettings} 64 Architecture
		Goto END
	ThirtyTwoBit:
	System::Call `${SET32}`
	${WriteSettings} 32 Architecture
	END:
	Pop $0
!macroend
;===
!macro ProExecInit
	Push $0
	ReadEnvStr $0 ${APP}
	StrCmp $0 ${APP} 0 +3
	StrCpy $ProgramExecutable ${32}
	Goto +2
	StrCpy $ProgramExecutable ${64}
	Pop $0
!macroend
;===
!define MsgBox "!insertmacro MsgBox"
!macro MsgBox
	StrCpy $0 `Windows XP +`
	MessageBox MB_ICONSTOP|MB_TOPMOST `$(MINREQ)`
	Call Unload
	Quit
!macroend
!macro OS
	Push $0
	${If} ${IsNT}
		${IfNot} ${AtLeastWinXP}
			${MsgBox}
		${EndIf}
	${Else}
		${MsgBox}
	${EndIf}
	Pop $0
!macroend
${SegmentPrePrimary}
	SetRegView 64
		SetRegView LastUsed
!macroend

${SegmentPostPrimary}
	SetRegView 64
	DeleteRegKey /IFEMPTY HKLM `SOFTWARE\Microsoft\Tracing\VidCoder_RASAPI32`
        DeleteRegKey /IFEMPTY HKLM `SOFTWARE\Microsoft\Tracing\VidCoder_RASMANCS`
        DeleteRegKey /IFEMPTY HKLM `SOFTWARE\Microsoft\Tracing\EnableConsoleTracing`
        DeleteRegKey /IFEMPTY HKLM `SOFTWARE\Microsoft\Tracing`
	Pop $0
		SetRegView LastUsed
!macroend