View | Details | Raw Unified | Return to bug 68194 | Differences between
and this patch

Collapse All | Expand All

(-)E:/Projects/ebiz2/src32-ivy/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/ole/win32/OleAutomation.java (+63 lines)
Lines 119-124 Link Here
119
 }
119
 }
120
 
120
 
121
/**
121
/**
122
 * Creates an OleAutomation object for the specified progID.
123
 * 
124
 * @param progID ActiveX Component whose additional functionality you need to access
125
 *        
126
 * @exception SWTException <ul>
127
 *     <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
128
 *     <li>ERROR_INTERFACE_NOT_FOUND when unable to create callbacks for OLE Interfaces
129
 *  </ul>
130
 *
131
 * @note This follows the pattern of what is done in 
132
 * COleDispatchDriver::CreateDispatch(REFCLSID clsid, COleException* pError)
133
 */
134
 public OleAutomation(String progID) {
135
     GUID rclsid = getClassID(progID);
136
     int[] ppvObject = new int[1];
137
     int result = COM.CoCreateInstance(rclsid, 0, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER | COM.CLSCTX_LOCAL_SERVER | COM.CLSCTX_REMOTE_SERVER, COM.IIDIUnknown, ppvObject);
138
     if (COM.E_INVALIDARG == result) {
139
         //Last try.  If it doesn't work here, stop going any further
140
         result = COM.CoCreateInstance(rclsid, 0, COM.CLSCTX_INPROC_HANDLER, COM.IIDIUnknown, ppvObject);         
141
         if (result != COM.S_OK)
142
             OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
143
     } else if (result != COM.S_OK)
144
         OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
145
     
146
     IUnknown objIUnknown = new IUnknown(ppvObject[0]);
147
     int[] ppvObject2 = new int[1];
148
     if (objIUnknown.QueryInterface(COM.IIDIDispatch, ppvObject2) != COM.S_OK) {
149
         objIDispatch = null;
150
         OLE.error(OLE.ERROR_INTERFACE_NOT_FOUND);
151
     }
152
     objIDispatch = new IDispatch(ppvObject2[0]);
153
      
154
     int[] ppv = new int[1];
155
     result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, ppv);
156
     if (result == OLE.S_OK) {
157
         objITypeInfo = new ITypeInfo(ppv[0]);
158
         objITypeInfo.AddRef();
159
     }
160
 }
161
  
162
/*
163
 * This has been copied from org.eclipse.swt.ole.win32.OleClientSite
164
 */
165
 protected GUID getClassID(String clientName) {
166
     // create a GUID struct to hold the result
167
     GUID guid = new GUID();
168
    
169
     // create a null terminated array of char
170
     char[] buffer = null;
171
     if (clientName != null) {
172
         int count = clientName.length();
173
         buffer = new char[count + 1];
174
         clientName.getChars(0, count, buffer, 0);
175
     }
176
     if (COM.CLSIDFromProgID(buffer, guid) != COM.S_OK){
177
         int result = COM.CLSIDFromString(buffer, guid);
178
         if (result != COM.S_OK)
179
             OLE.error(OLE.ERROR_INVALID_CLASSID, result);
180
     }
181
     return guid;
182
 }
183
184
/**
122
 * Disposes the automation object.
185
 * Disposes the automation object.
123
 * <p>
186
 * <p>
124
 * This method releases the IDispatch interface on the OLE Document or ActiveX Control.
187
 * This method releases the IDispatch interface on the OLE Document or ActiveX Control.

Return to bug 68194