Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TMainForm.GetJavascriptVariable(variable: string): Variant;
- var
- Window: IHTMLWindow2;
- DispatchIdOfProperty: Integer;
- MyPropertyValue: OleVariant;
- Temp: TExcepInfo;
- Res: Integer;
- Params:TDispParams;
- begin
- // get window interface
- Window:= (Browser.ControlInterface.Document as IHTMLDocument2).parentWindow;
- Assert(Assigned(Window));
- // get dispatch ID of our variable
- if (Window as IDispatchEx).GetDispID(PWideChar(variable), fdexNameCaseSensitive, DispatchIdOfProperty) = S_OK then
- begin
- // no parameters
- ZeroMemory(@Params, SizeOf(Params));
- // get value of our variable
- Res:=(Window as IDispatchEx).InvokeEx(DispatchIdOfProperty, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, @Params, MyPropertyValue, Temp, nil);
- if Res=S_OK then
- begin
- // voila - this should display the value
- result := MyPropertyValue;
- end else
- ShowMessage('Error reading property value');
- end
- else
- ShowMessage('Property not found');
- end;
Add Comment
Please, Sign In to add comment