Processing custom command-line arguments

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Processing custom command-line arguments

Postby Pirs01 » Mon Sep 03, 2018 9:48 am

Hello,

I'm looking to pass some custom command-line arguments (arbitrary, non-chrome-switches) to my CEF App and then access them in the Renderer process on Win OS.

My plan was to use
Code: Select all
CefCommandLine::GetGlobalCommandLine();

however it seams that CefCommandLine only cares for the predefined chrome switches and ignores other arguments. I pass the argument (confirmed with Process Explorer) but then debugging Browser process and looking into CefCommandLine instance contents I find no information about my argument. I can only see the predefined chrome switches there.

What's the correct approach here?

Thank you and regards,
Pirs01

EDIT:

Looks like my mistake. I guess I was looking at it too early right after creating Browser. Now tried having a look when in CefDisplayHandler::OnTitleChange and it seams to be in order.
Pirs01
Newbie
 
Posts: 2
Joined: Mon Sep 03, 2018 9:27 am

Re: Processing custom command-line arguments

Postby Pirs01 » Tue Sep 04, 2018 6:04 am

My fault confirmed.

I can see my command-line arguments just fine when using CefCommandLine::GetGlobalCommandLine in browser process.
Then I pass my arguments along to the Renderer process with something like:
Code: Select all
CefBrowserProcessHandler::OnBeforeChildProcessLaunch(CefRefPtr<CefCommandLine> command_line) {
    CefRefPtr<CefCommandLine> glob_command_line =
        CefCommandLine::GetGlobalCommandLine();
    CefString argVal = glob_command_line->GetSwitchValue("myCmdArg");
    command_line->AppendSwitchWithValue("myCmdArg", argVal);

It works. Thanks, all your moral support is appreciated :lol:
Pirs01
Newbie
 
Posts: 2
Joined: Mon Sep 03, 2018 9:27 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 71 guests