Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome extension NPAPI Chrome扩展:如何执行包含的可执行文件?_Google Chrome Extension_Npapi - Fatal编程技术网

Google chrome extension NPAPI Chrome扩展:如何执行包含的可执行文件?

Google chrome extension NPAPI Chrome扩展:如何执行包含的可执行文件?,google-chrome-extension,npapi,Google Chrome Extension,Npapi,我正在创建一个用于Chrome扩展的小NPAPI插件。 扩展的主要目标是能够从web页面打开PuTTY(带参数) 我有它的工作…除了路径油灰。我将路径硬编码到我的C驱动器上的某个位置。我想包括可执行文件,并让它从安装目录运行。我该怎么做?以下是我的调用方法: bool ScriptablePluginObject::Invoke(NPObject* obj, NPIdentifier methodName, const NPVariant* args, uin

我正在创建一个用于Chrome扩展的小NPAPI插件。 扩展的主要目标是能够从web页面打开PuTTY(带参数)

我有它的工作…除了路径油灰。我将路径硬编码到我的C驱动器上的某个位置。我想包括可执行文件,并让它从安装目录运行。我该怎么做?以下是我的调用方法:

 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;
 }
任何帮助都将不胜感激

在您的DllMain中:

TCHAR* strDLLPath1(new TCHAR[_MAX_PATH]);
::GetModuleFileName(hInstance, strDLLPath1, _MAX_PATH);
strdlpath1现在将包含插件DLL的路径和文件名;从那里,您应该能够找到它旁边安装的任何其他设备的路径