2011-04-19 3 views
0

그래서 지금까지 내가 가지고있는 것입니다. 어둠 속에서 다트를 던지기 전에. 누군가에게 조언이 있는지 알고 싶었습니다. 분명히 pShellLink에서 메서드를 직접 호출 할 수는 없습니다. 그래서 나는 그들을 선언 할 방법이 필요합니다. 그러나 나는 그 방법을 알 수 없습니다. Javascript ctype에는 아직 많은 예제가 없습니다.javascript js-ctypes를 사용하여 셸 링크 만들기

Components.utils.import("resource://gre/modules/ctypes.jsm"); 
var libshell32 = ctypes.open("shell32.dll"); 

const CLSID_ShellLink = '00021401-0000-0000-C000-000000000046'; 
const IID_IShellLink = '000214EE-0000-0000-C000-000000000046'; 
const IID_IPersistFile = '0000010b-0000-0000-C000-000000000046'; 
const CLSCTX_INPROC_SERVER = 0x1; 

var CoInitialize = libshell32.declare("CoInitialize", ctypes.winapi_abi, ctypes.int32_t, 
              ctypes.jschar.ptr); // LPVOID 

var CoCreateInstance = libshell32.declare("CoCreateInstance", ctypes.winapi_abi, ctypes.int32_t, 
              ctypes.int32_t,  // REFCLSID 
              ctypes.jschar.ptr, // LPUNKNOWN 
              ctypes.jschar.ptr, // DWORD 
              ctypes.int32_t,  // REFIID 
              ctypes.voidptr_t); // LPVOID 

var pPersistFile; // ?? 
var pShellLink; // ?? 
var hRes; // ?? 

hRes = CoInitialize(null); 
hRes = CoCreateInstance(CLSID_ShellLink,null,CLSCTX_INPROC_SERVER,IID_IShellLink,pShellLink); 
if (SUCCEEDED(hRes)) 
{ 
    hRes = pShellLink->lpVtbl->SetPath(pShellLink, "c:\somefile"); 
    hRes = pShellLink->lpVtbl->SetArguments(pShellLink, "-somearg"); 
    hRes = pShellLink->lpVtbl->SetDescription(pShellLink, "SomeDescription"); 
    hRes = pShellLink->lpVtbl->SetShowCmd(pShellLink, '1'); 
    hRes = pShellLink->lpVtbl->SetWorkingDirectory(pShellLink, "c:\somedir"); 
    hRes = pShellLink->lpVtbl->SetIconLocation(pShellLink, "c:\pathtoicon", '1'); 

    /* Use the IPersistFile object to save the shell link */ 
    hRes = pShellLink->lpVtbl->QueryInterface(pShellLink,  /* existing IShellLink object */ 
              &IID_IPersistFile, /* pre-defined interface of the IPersistFile object */ 
              &pPersistFile); /* returns a pointer to the IPersistFile object */ 
    if (SUCCEEDED(hRes)) 
    { 
    hRes = pPersistFile->lpVtbl->Save(pPersistFile, "c:\pathtoInk", TRUE); 
    pPersistFile->lpVtbl->Release(pPersistFile); 
    } 
    pShellLink->lpVtbl->Release(pShellLink); 
} 

답변

관련 문제