Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Get value from main process (native JS function)

Post Reply
User avatar
xpert13
Posts: 39
Joined: Wed May 31, 2017 5:26 pm

Get value from main process (native JS function)

Post by xpert13 »

Hello.

I need to create a JS native function than will get return value from main process. I tried to use the example but I didn't understand how can I get value from main process and return it:

Code: Select all

function TMyV8Handler.Execute(const name      : ustring;
                              const obj       : ICefv8Value;
                              const arguments : TCefv8ValueArray;
                              var   retval    : ICefv8Value;
                              var   exception : ustring): Boolean;
begin
  if (name = 'myfunc') then
    begin
      retval := TCefv8ValueRef.NewString('My Value!'); // <---- What I need to write here?
      Result := True;
    end
   else
    Result := False;
end;
Please help. I don't understand how to send message to the main process and wait for an answer.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Get value from main process (native JS function)

Post by salvadordf »

If I understand you correctly, the easiest way to send information from the main process to JavaScript is to execute some custom JS code which embeds that information in the JS code, for example, as a parameter of a JS function.

Another way to do that is using process messages to the render process with an ICefProcessMessage that has your custom information in "ICefProcessMessage.ArgumentList".
Post Reply