PDA

View Full Version : Feedback wanted - DispHelper



anonytmouse
12-23-2003, 09:06 PM
DispHelper aims to allow Windows C/C++ programmers to use COM objects in a simple, script like manner.

If anyone wants to try it out or give feedback feel free. Suggestions, criticisms, bugs, crushing silence, you know the sort of thing.

Download DispHelper Version 0.75(BETA) - 90KB (http://www.ifrance.com/tmouse/disphelper075.zip)

The following samples are provided. All samples can be compiled as C or C++.

word.c
Demonstrates outputting formatted text to a Word document and getting user feed back with the help of the office assistant. Demonstrates using Word as a spell checker.

excel.c
Demonstrates outputting formatted data to Excel and using it to create a chart. Demonstrates using a safe array to efficiently insert data into Excel.

email.c
Demonstrates sending an email with CDO, Outlook and Eudora.

ado.c
Demonstrates reading and manipulating data from a data source using ActiveX Data Objects.

corel.c
Demonstrates outputting formatted text to a WordPerfect document.

speech.c
Demonstrates using Microsoft Agent and SAPI to provide text-to-speech.

MSHTML.c
Demonstrates ui-less html parsing and manipulation of the html document object model(DOM) using MSHTML. Provides functions to parse html from a string, a website or a file.

regexp.c
Demonstrates using the VBScript.RegExp object to provide support for regular expressions. Provides a function to extract hrefs from a web page using a regular expression.

xml.c
Demonstrates using MSMXL to download a web page, read an RSS feed and read and manipulate XML with the XML document object model(DOM).

wmi.c
Demonstrates using Windows Management Instrumentation(WMI). Samples include enumerating installed hot fixes, purging print queues, starting a program, monitoring starting and terminating processes, and monitoring file creation. All of these samples can target the local or a remote computer.

pocketsoap.c
Demonstrates using the PocketSoap toolkit to utilise several web services. Play the 'Who wants to be a millionaire' quiz with the help of a web service.

soap.c
Demonstrates using the MSSoap toolkit to utilise several web services. Web services demonstrated include Google search, spell checker and cache viewer.

iexplore.c
Demonstrates controlling Internet Explorer via COM. Demonstrates using an Internet Explorer window to display or retrieve information from the user.

scriptctl.c
Demonstrates using the MSScriptControl to run a VBScript or JScript.

dexplore.c
Demonstrates controlling Microsoft's new help system for developers, dexplore.

dcom_alt_creds.c
Demonstrates one way of accessing a remote COM object using alternate credentials.

wia.c
Demonstrates using Windows Image Acquisition(WIA) to manipulate images. Demonstrates taking a snapshot from a video device.

anonytmouse
12-23-2003, 09:14 PM
Sorry about the extra post, didn't want to make the
previous post unreadable with 'wide' code.

Here's a couple of samples(error checking ommitted):




/* ***********************************************
* RSSRead:
* Demonstrates reading an rss feed using MSXML.
*
============================================*/
void RSSRead(LPCTSTR szURL) {

DISPATCH_OBJ(xmlDoc);
struct RSS {
LPWSTR szTitle, szLink, szDescription;
} RSSItem;

/* Load the rss document from the URL */
dhCreateObject(L"MSXML.DOMDocument", NULL, &xmlDoc) );
dhPutValue(xmlDoc, L".Async = %b", FALSE) );
dhCallMethod(xmlDoc, L".Load(%T)", szURL) );

FOR_EACH1(xmlNode, xmlDoc, L".documentElement.getElementsByTagName(%S)", L"item") {

ZeroMemory(&RSSItem, sizeof(RSSItem));

dhGetValue(L"%S", &RSSItem.szTitle, xmlNode, L".selectSingleNode(%S).text", L"title");
dhGetValue(L"%S", &RSSItem.szLink, xmlNode, L".selectSingleNode(%S).text", L"link");
dhGetValue(L"%S", &RSSItem.szDescription, xmlNode, L".selectSingleNode(%S).text", L"description");

wprintf(L"Title: %s\nLink: %s\nDescription: %.140s\n\n",
RSSItem.szTitle, RSSItem.szLink, RSSItem.szDescription);

dhFreeString(RSSItem.szTitle);
dhFreeString(RSSItem.szLink);
dhFreeString(RSSItem.szDescription);

} NEXT(xmlNode);

SAFE_RELEASE(xmlDoc);
}



/* ********************************************
* MonitorProcessActivity:
* Monitors process startup and termination on local or remote computer.
*
* =========================================== */
void MonitorProcessActivity(LPCWSTR szComputer) {

DISPATCH_OBJ(wmiSvc);
DISPATCH_OBJ(wmiEventSrc);

dhGetObject(getWmiStr(szComputer), NULL, &wmiSvc) );

dhGetValue(L"%o", &wmiEventSrc, wmiSvc, L".ExecNotificationQuery(%S)",
L"SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE (__Class = '__InstanceCreationEvent' OR __Class = '__InstanceDeletionEvent') AND TargetInstance ISA 'Win32_Process'") );

while (TRUE) {
DISPATCH_OBJ(wmiLatestEvent);
LPWSTR szProcessName = NULL;
LPWSTR szClassName = NULL;

dhGetValue(L"%o", &wmiLatestEvent, wmiEventSrc, L".NextEvent") );

dhGetValue(L"%S", &szProcessName, wmiLatestEvent, L".TargetInstance.Name");
dhGetValue(L"%S", &szClassName, wmiLatestEvent, L".SystemProperties_(%S)", L"__Class");

if (szClassName && 0 == wcscmp(L"__InstanceDeletionEvent", szClassName))
wprintf(L"TERMINATED: \t%s\n", szProcessName);
else
wprintf(L"STARTED: \t%s\n", szProcessName);

dhFreeString(szProcessName);
dhFreeString(szClassName);
SAFE_RELEASE(wmiLatestEvent);
}

SAFE_RELEASE(wmiEventSrc);
SAFE_RELEASE(wmiSvc);
}

anonytmouse
12-30-2003, 08:15 PM
That bad? I wasn't serious about the crushing silence!

I can understand if no one can be bothered having a look but can anyone comment on whether this is a worthwhile project or should I give it a ceremonial burial at sea.

The 'how do I put a chart in Excel' or 'how do I send an email' sort of questions seem to come up fairly regularly so I thought this might be of some use. However, I may have been deluding myself.

No one thinks any of the samples listed could be at all useful?

Thanks.

Salem
12-31-2003, 09:30 AM
1. It would be better on the windows board
2. Everyone is on holiday
I am not a windows programmer, so I can't comment on it in any depth