Skip to content

Commit bc7765c

Browse files
author
xtmouse
committed
Updated readme in light of C++ extensions and samples
1 parent 3d7f805 commit bc7765c

File tree

1 file changed

+51
-40
lines changed

1 file changed

+51
-40
lines changed

Diff for: readme.htm

+51-40
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
<h1>DispHelper</h1>
6363

64-
<p>DispHelper Version 0.80 - June 2004.</p>
64+
<p>DispHelper Version 0.81 - July 2004.</p>
6565

6666
<h2>Introduction</h2>
6767
<p>The aim of the DispHelper library is to allow C/C++ programmers to use COM objects
@@ -132,77 +132,78 @@ <h2>Directory Layout</h2>
132132
<strong>single_file_source: </strong>Contains a compacted single file version of the source
133133
for easy inclusion in your projects.<br />
134134
<strong>samples_c: </strong>Contains several DispHelper samples in C.<br />
135-
<strong>samples_cpp: </strong>Currently empty. Will contain samples optimized for C++.<br />
135+
<strong>samples_cpp: </strong>Contains several DispHelper samples in C++.<br />
136136
<strong>samples_applications: </strong>Currently empty. Will contain small sample applications that
137137
make use of DispHelper.</p>
138138

139139
<h2>Samples</h2>
140-
<p>Several samples are available in the <strong>samples_c</strong> directory. Batch files to compile these
140+
<p>Several samples are available in the <strong>samples_c</strong> and <strong>samples_cpp</strong> directories.
141+
Batch files to compile these
141142
samples are provided for Dev-C++, Visual C++ and LCC-WIN32. Drag the sample file you wish to
142143
compile onto the appropriate batch file. You may have to edit the batch file for your environment.</p>
143-
<p>While each of these samples will compile as either C or C++, many are not C++ friendly. Included in
144-
a future release will be C++ friendly versions of the samples which will make use of smart pointers,
145-
exceptions and the C++ standard libraries.</p>
144+
<p>While each of the samples in samples_c will compile as either C or C++, more C++ friendly versions, which
145+
make use of smart pointers, C++ exceptions and the C++ standard libraries are
146+
available in the samples_cpp directory.</p>
146147

147148
<h2>Sample List</h2>
148149
<table cellspacing="0">
149150
<tr><th>File</th><th>Description</th></tr>
150151

151152
<tr>
152-
<td>word.c</td>
153+
<td>word</td>
153154
<td>Demonstrates outputting formatted text to a Word document and getting user feed
154155
back with the help of the office assistant. Demonstrates using Word as a spell
155156
checker.</td>
156157
</tr>
157158

158159
<tr>
159-
<td>excel.c</td>
160+
<td>excel</td>
160161
<td>Demonstrates outputting formatted data to Excel and using it to create a
161162
chart. Demonstrates using a safe array to efficiently insert data into Excel.</td>
162163
</tr>
163164

164165
<tr>
165-
<td>email.c</td>
166+
<td>email</td>
166167
<td>Demonstrates sending an email with CDO, Outlook and Eudora.</td>
167168
</tr>
168169

169170
<tr>
170-
<td>ado.c</td>
171+
<td>ado</td>
171172
<td>Demonstrates reading and manipulating data from a data source using ActiveX Data Objects.</td>
172173
</tr>
173174

174175
<tr>
175-
<td>corel.c</td>
176+
<td>corel</td>
176177
<td>Demonstrates outputting formatted text to a WordPerfect document.</td>
177178
</tr>
178179

179180
<tr>
180-
<td>speech.c</td>
181+
<td>speech</td>
181182
<td>Demonstrates using Microsoft Agent and SAPI to provide text-to-speech.</td>
182183
</tr>
183184

184185
<tr>
185-
<td>MSHTML.c</td>
186+
<td>MSHTML</td>
186187
<td>Demonstrates ui-less html parsing and manipulation of the html document object
187188
model(DOM) using MSHTML.
188189
Provides functions to parse html from a string, a website or a file.</td>
189190
</tr>
190191

191192
<tr>
192-
<td>regexp.c</td>
193+
<td>regexp</td>
193194
<td>Demonstrates using the VBScript.RegExp object to provide support for regular
194195
expressions. Provides a function to extract hrefs from a web page using a
195196
regular expression.</td>
196197
</tr>
197198

198199
<tr>
199-
<td>xml.c</td>
200+
<td>xml</td>
200201
<td>Demonstrates using MSMXL to download a web page, read an RSS feed and read and
201202
manipulate XML with the XML document object model(DOM).</td>
202203
</tr>
203204

204205
<tr>
205-
<td>wmi.c</td>
206+
<td>wmi</td>
206207
<td>Demonstrates using Windows Management Instrumentation(WMI).
207208

208209
Samples include enumerating installed hot fixes, purging print queues, starting
@@ -211,40 +212,40 @@ <h2>Sample List</h2>
211212
</tr>
212213

213214
<tr>
214-
<td>pocketsoap.c</td>
215+
<td>pocketsoap</td>
215216
<td>Demonstrates using the PocketSoap toolkit to utilise several web services.
216217
Play the 'Who wants to be a millionaire' quiz with the help of a web service.</td>
217218
</tr>
218219

219220
<tr>
220-
<td>soap.c</td>
221+
<td>soap</td>
221222
<td>Demonstrates using the MSSoap toolkit to utilise several web services.
222223
Web services demonstrated include Google search, spell checker and cache viewer.</td>
223224
</tr>
224225

225226
<tr>
226-
<td>iexplore.c</td>
227+
<td>iexplore</td>
227228
<td>Demonstrates controlling Internet Explorer via COM. Demonstrates using an Internet
228229
Explorer window to display or retrieve information from the user.</td>
229230
</tr>
230231

231232
<tr>
232-
<td>scriptctl.c</td>
233+
<td>scriptctl</td>
233234
<td>Demonstrates using the MSScriptControl to run a VBScript or JScript.</td>
234235
</tr>
235236

236237
<tr>
237-
<td>dexplore.c</td>
238+
<td>dexplore</td>
238239
<td>Demonstrates controlling Microsoft's new help system for developers, dexplore.</td>
239240
</tr>
240241

241242
<tr>
242-
<td>dcom_alt_creds.c </td>
243+
<td>dcom_alt_creds</td>
243244
<td>Demonstrates one way of accessing a remote COM object using alternate credentials.</td>
244245
</tr>
245246

246247
<tr>
247-
<td>wia.c</td>
248+
<td>wia</td>
248249
<td>Demonstrates using Windows Image Acquisition(WIA) to manipulate
249250
images. Demonstrates taking a snapshot from a video device.</td>
250251
</tr>
@@ -384,6 +385,9 @@ <h3>Initializing DispHelper</h3>
384385
// Initializes DispHelper only. COM must be initialized seperately
385386
// using CoInitialize(), CoInitializeEx() or OleInitialize().
386387
dhInitialize(FALSE);
388+
389+
// Using the C++ initialization class
390+
CDhInitialize init;
387391
</pre>
388392

389393
<h3>Declaring a DispHelper COM object</h3>
@@ -393,6 +397,9 @@ <h3>Declaring a DispHelper COM object</h3>
393397

394398
// Without the macro
395399
IDispatch * wdDoc = NULL;
400+
401+
// Using the C++ smart pointer
402+
CDispPtr wdDoc;
396403
</pre>
397404

398405
<h3>Toggling Exceptions</h3>
@@ -526,19 +533,9 @@ <h3>Retrieving the last error text</h3>
526533
// Dump the details of the last error to a log file
527534
void LogDhError(void)
528535
{
529-
PDH_EXCEPTION pException = NULL;
530-
dhGetLastException(&amp;pException);
531-
532-
if (pException)
533-
{
534-
WCHAR szMessage[512];
535-
dhFormatException(pException, szMessage, 512, TRUE);
536-
fprintf(g_hLogFile, "%S", szMessage);
537-
}
538-
else
539-
{
540-
fprintf(g_hLogFile, "No error information available.");
541-
}
536+
char szMessage[512];
537+
dhFormatExceptionA(NULL, szMessage, sizeof(szMessage)/sizeof(szMessage[0]), TRUE);
538+
fprintf(g_hLogFile, "%s", szMessage);
542539
}
543540

544541
// Sample usage
@@ -549,16 +546,30 @@ <h3>Retrieving the last error text</h3>
549546
}
550547
</pre>
551548

549+
<h3>Throw a C++ exception on error</h3>
550+
<pre>
551+
// Use the dhCheck macro which will throw a std::string on error
552+
553+
try
554+
{
555+
dhCheck( dhCallMethod(wdApp, L".Selection.TypeText(%s)", "Hello World") );
556+
dhCheck( dhPutValue(wdApp, L".Selection.Font.Bold = %b", TRUE) );
557+
}
558+
catch (string errstr)
559+
{
560+
cerr &lt;&lt; "Fatal error details:" &lt;&lt; endl &lt;&lt; errstr &lt;&lt; endl;
561+
}
562+
</pre>
563+
564+
552565
<h3>Releasing a COM object</h3>
553566
<pre>
554-
// Make use of the SAFE_RELEASE macro
567+
// Make use of the SAFE_RELEASE macro - do not use with smart pointer
555568
SAFE_RELEASE(wdApp);
556569
</pre>
557570

558571
<h2>Future Directions</h2>
559-
<p>In the near future DispHelper will become more C++ friendly, with samples
560-
that use exceptions, smart pointers and the C++ standard libraries.</p>
561-
<p>DispHelper may also expand to allow easy hosting of ActiveX controls, if demand exists.</p>
572+
<p>DispHelper may expand to allow easy hosting of ActiveX controls, if demand exists.</p>
562573

563574
<p style="text-align:center;"><a href="http://sourceforge.net" title="Go to SourceForge.net - The open source development site">
564575
<img src="http://sourceforge.net/sflogo.php?group_id=111558&amp;type=3" width="125" height="37" style="border:none;" alt="Go to SourceForge.net - The open source development site" />

0 commit comments

Comments
 (0)