0
Chrome 확장 프로그램에서 사용할 소형 NPAPI 플러그인을 만들고 있습니다. 확장의 주요 목적은 웹 페이지에서 PuTTY (인수 포함)를 열 수있게하는 것입니다.NPAPI Chrome 확장 프로그램 : 포함 된 실행 파일을 실행하는 방법은 무엇입니까?
나는 PuTTY의 경로를 제외하고는 ... 작동하고 있습니다. C 드라이브의 위치에 하드 코딩 된 경로가 있습니다. 실행 파일을 포함시키고 설치 디렉토리에서 실행하게하고 싶습니다. 어떻게해야합니까? 여기 내 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;
}
아무 도움이됩니다. 당신의 DllMain에서