unit ActivScp;

interface

uses Windows, ActiveX, Classes, Graphics, OleCtrls, StdVCL;

// *********************************************************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used:      //
//   Type Libraries     : LIBID_xxxx                                    //
//   CoClasses          : CLASS_xxxx                                    //
//   DISPInterfaces     : DIID_xxxx                                     //
//   Non-DISP interfaces: IID_xxxx                                      //
// *********************************************************************//
const
	IID_IActiveScriptSite: TGUID = '{DB01A1E3-A42B-11CF-8F20-00805F2CD064}';
	IID_IActiveScriptError: TGUID = '{EAE1BA61-A4ED-11CF-8F20-00805F2CD064}';
	IID_IActiveScriptSiteWindow: TGUID = '{D10F6761-83E9-11CF-8F20-00805F2CD064}';
	IID_IActiveScript: TGUID = '{BB1A2AE1-A4F9-11CF-8F20-00805F2CD064}';
	IID_IActiveScriptParse: TGUID = '{BB1A2AE2-A4F9-11CF-8F20-00805F2CD064}';
	IID_IActiveScriptParseProcedure: TGUID = '{AA5B6A80-B834-11D0-932F-00A0C90DCAA9}';
	IID_IActiveScriptSiteInterruptPoll: TGUID = '{539698A0-CDCA-11CF-A5EB-00AA0047A063}';
	IID_IActiveScriptParseProcedureOld: TGUID = '{1CFF0050-6FDD-11D0-9328-00A0C90DCAA9}';
	IID_IBindEventHandler: TGUID = '{63CDBCB0-C1B1-11D0-9336-00A0C90DCAA9}';
	IID_IActiveScriptStats: TGUID = '{B8DA6310-E19B-11D0-933C-00A0C90DCAA9}';

// *********************************************************************//
// Declaration of Enumerations defined in Type Library                  //
// *********************************************************************//
// tagSCRIPTSTATE constants
type
	tagSCRIPTSTATE = TOleEnum;

const
// IActiveScript::AddNamedItem() input flags

	SCRIPTITEM_ISVISIBLE            = $00000002;
	SCRIPTITEM_ISSOURCE             = $00000004;
	SCRIPTITEM_GLOBALMEMBERS        = $00000008;
	SCRIPTITEM_ISPERSISTENT         = $00000040;
	SCRIPTITEM_CODEONLY             = $00000200;
	SCRIPTITEM_NOCODE               = $00000400;

	SCRIPTITEM_ALL_FLAGS            =
		SCRIPTITEM_ISSOURCE or SCRIPTITEM_ISVISIBLE or SCRIPTITEM_ISPERSISTENT or
		SCRIPTITEM_GLOBALMEMBERS or SCRIPTITEM_NOCODE or SCRIPTITEM_CODEONLY;

// IActiveScriptParse::AddScriptlet() and IActiveScriptParse::ParseScriptText() input flags

	SCRIPTTEXT_DELAYEXECUTION       = $00000001;
	SCRIPTTEXT_ISVISIBLE            = $00000002;
	SCRIPTTEXT_ISEXPRESSION         = $00000020;
	SCRIPTTEXT_ISPERSISTENT         = $00000040;
	SCRIPTTEXT_HOSTMANAGESSOURCE    = $00000080;
	SCRIPTTEXT_ALL_FLAGS            =
		SCRIPTTEXT_DELAYEXECUTION or SCRIPTTEXT_ISVISIBLE or SCRIPTTEXT_ISEXPRESSION or
		SCRIPTTEXT_ISPERSISTENT or SCRIPTTEXT_HOSTMANAGESSOURCE;

// IActiveScript::AddTypeLib() input flags

	SCRIPTTYPELIB_ISCONTROL         = $00000010;
	SCRIPTTYPELIB_ISPERSISTENT      = $00000040;
	SCRIPTTYPELIB_ALL_FLAGS         = SCRIPTTYPELIB_ISCONTROL or SCRIPTTYPELIB_ISPERSISTENT;

// IActiveScriptParseProcedure::ParseProcedureText() input flags

	SCRIPTPROC_HOSTMANAGESSOURCE    = $00000080;
	SCRIPTPROC_IMPLICIT_THIS        = $00000100;
	SCRIPTPROC_IMPLICIT_PARENTS     = $00000200;
	SCRIPTPROC_ALL_FLAGS            =
		SCRIPTPROC_HOSTMANAGESSOURCE or
		SCRIPTPROC_IMPLICIT_THIS or SCRIPTPROC_IMPLICIT_PARENTS;

// IActiveScriptSite::GetItemInfo() input flags

	SCRIPTINFO_IUNKNOWN             = $00000001;
	SCRIPTINFO_ITYPEINFO            = $00000002;
	SCRIPTINFO_ALL_FLAGS            =
		SCRIPTINFO_IUNKNOWN or SCRIPTINFO_ITYPEINFO;

// IActiveScript::Interrupt() Flags 

	SCRIPTINTERRUPT_DEBUG           = $00000001;
	SCRIPTINTERRUPT_RAISEEXCEPTION  = $00000002;
	SCRIPTINTERRUPT_ALL_FLAGS       =
		SCRIPTINTERRUPT_DEBUG or SCRIPTINTERRUPT_RAISEEXCEPTION;

// IActiveScriptStats::GetStat() values

	SCRIPTSTAT_STATEMENT_COUNT       = 1;
	SCRIPTSTAT_INSTRUCTION_COUNT     = 2;
	SCRIPTSTAT_INTSTRUCTION_TIME     = 3;
	SCRIPTSTAT_TOTAL_TIME            = 4;

// script state values

	SCRIPTSTATE_UNINITIALIZED	= 0;
	SCRIPTSTATE_INITIALIZED	= 5;
	SCRIPTSTATE_STARTED	= 1;
	SCRIPTSTATE_CONNECTED	= 2;
	SCRIPTSTATE_DISCONNECTED	= 3;
	SCRIPTSTATE_CLOSED	= 4;


// script thread state values
// tagSCRIPTTHREADSTATE constants
type
	tagSCRIPTTHREADSTATE = TOleEnum;
	SCRIPTTHREADID = DWORD;

const
	SCRIPTTHREADSTATE_NOTINSCRIPT	= 0;
	SCRIPTTHREADSTATE_RUNNING	= 1;

	SCRIPTTHREADID_CURRENT  = SCRIPTTHREADID(-1);
	SCRIPTTHREADID_BASE     = SCRIPTTHREADID(-2);
	SCRIPTTHREADID_ALL      = SCRIPTTHREADID(-3);



type

// *********************************************************************//
// Forward declaration of interfaces defined in Type Library            //
// *********************************************************************//
	IActiveScriptSite = interface;
	IActiveScriptError = interface;
	IActiveScriptSiteWindow = interface;
	IActiveScript = interface;
	IActiveScriptParse = interface;
	IActiveScriptParseProcedure = interface;
	IActiveScriptSiteInterruptPoll = interface;
	IActiveScriptParseProcedureOld = interface;
	IBindEventHandler = interface;
	IActiveScriptStats = interface;

// *********************************************************************//
// Interface: IActiveScriptSite
// Flags:     (0)
// GUID:      {DB01A1E3-A42B-11CF-8F20-00805F2CD064}
// *********************************************************************//
  IActiveScriptSite = interface(IUnknown)
    ['{DB01A1E3-A42B-11CF-8F20-00805F2CD064}']
    function GetLCID(out plcid: UINT): HResult; stdcall;
    function GetItemInfo(pstrName: PWideChar; dwReturnMask: UINT; out ppiunkItem: IUnknown; 
                         out ppti: ITypeInfo): HResult; stdcall;
    function GetDocVersionString(out pbstrVersion: WideString): HResult; stdcall;
    function OnScriptTerminate(var pvarResult: OleVariant; var pexcepinfo: tagEXCEPINFO): HResult; stdcall;
    function OnStateChange(ssScriptState: tagSCRIPTSTATE): HResult; stdcall;
    function OnScriptError(const pscripterror: IActiveScriptError): HResult; stdcall;
		function OnEnterScript: HResult; stdcall;
		function OnLeaveScript: HResult; stdcall;
	end;

// *********************************************************************//
// Interface: IActiveScriptError
// Flags:     (0)
// GUID:      {EAE1BA61-A4ED-11CF-8F20-00805F2CD064}
// *********************************************************************//
	IActiveScriptError = interface(IUnknown)
		['{EAE1BA61-A4ED-11CF-8F20-00805F2CD064}']
		function GetExceptionInfo(out pexcepinfo: tagEXCEPINFO): HResult; stdcall;
		function GetSourcePosition(out pdwSourceContext: UINT; out pulLineNumber: UINT;
															 out plCharacterPosition: Integer): HResult; stdcall;
		function GetSourceLineText(out pbstrSourceLine: WideString): HResult; stdcall;
	end;

// *********************************************************************//
// Interface: IActiveScriptSiteWindow
// Flags:     (0)
// GUID:      {D10F6761-83E9-11CF-8F20-00805F2CD064}
// *********************************************************************//
	IActiveScriptSiteWindow = interface(IUnknown)
		['{D10F6761-83E9-11CF-8F20-00805F2CD064}']
		function GetWindow(out phwnd: HWND): HResult; stdcall;
		function EnableModeless(fEnable: Integer): HResult; stdcall;
	end;

// *********************************************************************//
// Interface: IActiveScript
// Flags:     (0)
// GUID:      {BB1A2AE1-A4F9-11CF-8F20-00805F2CD064}
// *********************************************************************//
	IActiveScript = interface(IUnknown)
		['{BB1A2AE1-A4F9-11CF-8F20-00805F2CD064}']
		function SetScriptSite(const pass: IActiveScriptSite): HResult; stdcall;
		function GetScriptSite(var riid: TGUID; out ppvObject: Pointer): HResult; stdcall;
		function SetScriptState(ss: tagSCRIPTSTATE): HResult; stdcall;
		function GetScriptState(out pssState: tagSCRIPTSTATE): HResult; stdcall;
		function Close: HResult; stdcall;
		function AddNamedItem(pstrName: PWideChar; dwFlags: UINT): HResult; stdcall;
		function AddTypeLib(var rguidTypeLib: TGUID; dwMajor: UINT; dwMinor: UINT; dwFlags: UINT): HResult; stdcall;
		function GetScriptDispatch(pstrItemName: PWideChar; out ppdisp: IDispatch): HResult; stdcall;
		function GetCurrentScriptThreadID(out pstidThread: UINT): HResult; stdcall;
		function GetScriptThreadID(dwWin32ThreadId: UINT; out pstidThread: UINT): HResult; stdcall;
		function GetScriptThreadState(stidThread: UINT; out pstsState: tagSCRIPTTHREADSTATE): HResult; stdcall;
		function InterruptScriptThread(stidThread: UINT; var pexcepinfo: tagEXCEPINFO; dwFlags: UINT): HResult; stdcall;
		function Clone(out ppscript: IActiveScript): HResult; stdcall;
	end;

// *********************************************************************//
// Interface: IActiveScriptParse
// Flags:     (0)
// GUID:      {BB1A2AE2-A4F9-11CF-8F20-00805F2CD064}
// *********************************************************************//
	IActiveScriptParse = interface(IUnknown)
		['{BB1A2AE2-A4F9-11CF-8F20-00805F2CD064}']
		function InitNew: HResult; stdcall;
		function AddScriptlet(pstrDefaultName: PWideChar; pstrCode: PWideChar; pstrItemName: PWideChar;
													pstrSubItemName: PWideChar; pstrEventName: PWideChar;
													pstrDelimiter: PWideChar; dwSourceContextCookie: UINT;
													ulStartingLineNumber: UINT; dwFlags: UINT; out pBstrName: WideString;
													out pexcepinfo: tagEXCEPINFO): HResult; stdcall;
		function ParseScriptText(pstrCode: PWideChar; pstrItemName: PWideChar;
														 const punkContext: IUnknown; pstrDelimiter: PWideChar;
														 dwSourceContextCookie: UINT; ulStartingLineNumber: UINT;
														 dwFlags: UINT; out pvarResult: OleVariant; out pexcepinfo: tagEXCEPINFO): HResult; stdcall;
	end;

// *********************************************************************//
// Interface: IActiveScriptParseProcedure
// Flags:     (0)
// GUID:      {AA5B6A80-B834-11D0-932F-00A0C90DCAA9}
// *********************************************************************//
	IActiveScriptParseProcedure = interface(IUnknown)
		['{AA5B6A80-B834-11D0-932F-00A0C90DCAA9}']
		function ParseProcedureText(pstrCode: PWideChar; pstrFormalParams: PWideChar;
																pstrProcedureName: PWideChar; pstrItemName: PWideChar;
																const punkContext: IUnknown; pstrDelimiter: PWideChar;
																dwSourceContextCookie: UINT; ulStartingLineNumber: UINT;
																dwFlags: UINT; out ppdisp: IDispatch): HResult; stdcall;
	end;

// *********************************************************************//
// Interface: IActiveScriptSiteInterruptPoll
// Flags:     (0)
// GUID:      {539698A0-CDCA-11CF-A5EB-00AA0047A063}
// *********************************************************************//
	IActiveScriptSiteInterruptPoll = interface(IUnknown)
		['{539698A0-CDCA-11CF-A5EB-00AA0047A063}']
		function QueryContinue: HResult; stdcall;
	end;

// *********************************************************************//
// Interface: IActiveScriptParseProcedureOld
// Flags:     (0)
// GUID:      {1CFF0050-6FDD-11D0-9328-00A0C90DCAA9}
// *********************************************************************//
	IActiveScriptParseProcedureOld = interface(IUnknown)
		['{1CFF0050-6FDD-11D0-9328-00A0C90DCAA9}']
		function ParseProcedureText(pstrCode: PWideChar; pstrFormalParams: PWideChar;
																pstrItemName: PWideChar; const punkContext: IUnknown;
																pstrDelimiter: PWideChar; dwSourceContextCookie: UINT;
																ulStartingLineNumber: UINT; dwFlags: UINT; out ppdisp: IDispatch): HResult; stdcall;
	end;

// *********************************************************************//
// Interface: IBindEventHandler
// Flags:     (0)
// GUID:      {63CDBCB0-C1B1-11D0-9336-00A0C90DCAA9}
// *********************************************************************//
	IBindEventHandler = interface(IUnknown)
		['{63CDBCB0-C1B1-11D0-9336-00A0C90DCAA9}']
		function BindHandler(pstrEvent: PWideChar; const pdisp: IDispatch): HResult; stdcall;
	end;

// *********************************************************************//
// Interface: IActiveScriptStats
// Flags:     (0)
// GUID:      {B8DA6310-E19B-11D0-933C-00A0C90DCAA9}
// *********************************************************************//
	IActiveScriptStats = interface(IUnknown)
		['{B8DA6310-E19B-11D0-933C-00A0C90DCAA9}']
		function GetStat(stid: UINT; out pluHi: UINT; out pluLo: UINT): HResult; stdcall;
		function GetStatEx(var guid: TGUID; out pluHi: UINT; out pluLo: UINT): HResult; stdcall;
		function ResetStats: HResult; stdcall;
	end;

implementation

end.
