1 11 package org.eclipse.swt.internal.ole.win32; 12 13 import org.eclipse.swt.internal.win32.*; 14 15 public class IDispatch extends IUnknown 16 { 17 public IDispatch(int address) { 18 super(address); 19 } 20 public int GetIDsOfNames(GUID riid, String [] rgszNames, int cNames, int lcid, int[] rgDispId) { 21 22 char[] buffer; 23 int size = rgszNames.length; 24 25 int hHeap = OS.GetProcessHeap(); 27 int ppNames = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, size * OS.PTR_SIZEOF); 28 int [] memTracker = new int [size]; 29 30 try { 31 33 for (int i=0; i<size; i++){ 34 int nameSize = rgszNames[i].length(); 36 buffer = new char[nameSize +1]; 37 rgszNames[i].getChars(0, nameSize, buffer, 0); 38 int pName = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length * 2); 40 OS.MoveMemory(pName, buffer, buffer.length * 2); 41 COM.MoveMemory(ppNames + OS.PTR_SIZEOF * i, new int []{pName}, OS.PTR_SIZEOF); 43 memTracker[i] = pName; 45 } 46 47 return COM.VtblCall(5, address, new GUID(), ppNames, cNames, lcid, rgDispId); 48 49 } finally { 50 for (int i=0; i<memTracker.length; i++){ 52 OS.HeapFree(hHeap, 0, memTracker[i]); 53 } 54 OS.HeapFree(hHeap, 0, ppNames); 55 } 56 } 57 public int GetTypeInfo(int iTInfo, int lcid, int [] ppTInfo ){ 58 return COM.VtblCall(4, address, iTInfo, lcid, ppTInfo); 59 } 60 public int GetTypeInfoCount(int[] pctinfo ){ 61 return COM.VtblCall(3, address, pctinfo); 62 } 63 public int Invoke(int dispIdMember, GUID riid, int lcid, int dwFlags, DISPPARAMS pDispParams, int pVarResult, EXCEPINFO pExcepInfo, int[] pArgErr) { 64 return COM.VtblCall(6, address, dispIdMember, riid, lcid, dwFlags, pDispParams, pVarResult, pExcepInfo, pArgErr); 65 } 66 } 67 | Popular Tags |