I'm creating a small NPAPI Plugin to be used in a Chrome extension. The main goal of the extension is to be able to open PuTTY (with arguments) from a web page.
I have it working...with the exception of the path to PuTTY. I have the path hard coded to a location on my C drive. I'd like to include the executable and have it run from the installation directory. How do I do that? Here is my Invoke Method:
bool ScriptablePluginObject::Invoke(NPObject* obj, NPIdentifier methodName,
const NPVariant* args, uint32_t argCount,
NPVariant* result) {
ScriptablePluginObject *thisObj = (ScriptablePluginObject*)obj;
char* name = npnfuncs->utf8fromidentifier(methodName);
bool ret_val = false;
if (!name) {
return ret_val;
}
if (!strcmp(name, kOpenPutty)) {
ret_val = true;
std::string strCMD = std::string("C:\\putty.exe ") + args[0].value.stringValue.UTF8Characters;
system(strCMD.c_str());
const char* outString = "success";
char* npOutString = (char *)npnfuncs->memalloc(strlen(outString) + 1);
if (!npOutString)
return false;
strcpy(npOutString, outString);
STRINGZ_TO_NPVARIANT(npOutString, *result);
} else {
// Exception handling.
npnfuncs->setexception(obj, "Unknown method");
}
npnfuncs->memfree(name);
return ret_val;
}
Any help would be appreciated!