Guest User

Untitled

a guest
Feb 16th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. function TMainForm.GetJavascriptVariable(variable: string): Variant;
  2. var
  3. Window: IHTMLWindow2;
  4. DispatchIdOfProperty: Integer;
  5. MyPropertyValue: OleVariant;
  6. Temp: TExcepInfo;
  7. Res: Integer;
  8. Params:TDispParams;
  9. begin
  10. // get window interface
  11. Window:= (Browser.ControlInterface.Document as IHTMLDocument2).parentWindow;
  12. Assert(Assigned(Window));
  13. // get dispatch ID of our variable
  14. if (Window as IDispatchEx).GetDispID(PWideChar(variable), fdexNameCaseSensitive, DispatchIdOfProperty) = S_OK then
  15. begin
  16. // no parameters
  17. ZeroMemory(@Params, SizeOf(Params));
  18. // get value of our variable
  19. Res:=(Window as IDispatchEx).InvokeEx(DispatchIdOfProperty, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, @Params, MyPropertyValue, Temp, nil);
  20. if Res=S_OK then
  21. begin
  22. // voila - this should display the value
  23. result := MyPropertyValue;
  24. end else
  25. ShowMessage('Error reading property value');
  26. end
  27. else
  28. ShowMessage('Property not found');
  29. end;
Add Comment
Please, Sign In to add comment