Hello
I am trying to create a function inside a NPAPI plugin that will execute a command received as an argument using CreateProcess...
I managed somehow to convert from const char to LPCWSTR, the plugin loads in the browser but when I try to call the function in breaks and it displays Plugin cannot be loaded... ( javascript error )
Bellow is the code, the plugin is built using FireBreath
Code:
// Method run
FB::variant HarrisonRunCmdPluginAPI::runCommand(const char command)
{
STARTUPINFO startupInfo = {0};
startupInfo.cb = sizeof(startupInfo);
PROCESS_INFORMATION processInformation;
LPCWSTR cmd = (LPCWSTR)command;
// Try to start the process
BOOL result = ::CreateProcess(
cmd,
NULL,
NULL,
NULL,
FALSE,
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&startupInfo,
&processInformation
);
if(result == 0)
return("Could not create process");
else
return true;
}
if I hardcode an exe file like "c:\\windows\\notepad.exe" it works with no problem...
I am not sure, almost all the code in the project is generated by firebreath... i just wrote this function form an example function...
But somewhere the compiler is seeing that function, else it would not have given the error.
and FB is the firebreath class from witch ( I think )
HarrisonRunCmdPluginAPI ( my class ) inherits some methods needed for functionality...
Do not describe what you think it is.
Do a search for the function declaration that the error is referring to, and post it (or them if the function is indeed overloaded). The error says there are 5 overloads to that function, and we don't know what any of them are.
for example if I replace all the code in the function with:
Code:
return command;
When I call the obj from js I get the argument back with no trouble at all...
C++ isn't a language to experiment with by throwing stuff on the wall and seeing what sticks. All you'll do is create buggy, faulty programs, if you can get the code to compile.
Hi
I know this is old thread but i want take my chance.
i try your method but everytime i test it i get "Could not create process" message even i try use cmd as hardcord like this:
Hi
I know this is old thread but i want take my chance.
i try your method but everytime i test it i get "Could not create process" message even i try use cmd as hardcord like this:
...
but the result is always 0.
May you help me?
MSDN may help you... but only if you will read it and read it very carefully.
For example the CreateProcess article mentions:
Return value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Bookmarks