User Guide

hszDDEService = DdeCreateStringHandle(idDDE, ACDSee, CP_WINANSI);
hszDDETopic = DdeCreateStringHandle(idDDE, “System”, CP_WINANSI);
hconv = DdeConnect(idDDE, hszDDEService, hszDDETopic, NULL);
if (!hconv && DdeGetLastError(idDDE)==DMLERR_NO_CONV_ESTABLISHED)
{
int rc = (int)ShellExecute(NULL, NULL, pszAppPath,
“/v”, “”, SW_SHOWDEFAULT);
if (rc <= 32) return rc;
// try to connect to server every 50 ms for up to 1 second
// (give server a chance to start up)
for (int i=0 ; i<20 && !hconv ; i++)
{
hconv = DdeConnect(idDDE, hszDDEService, hszDDETopic, NULL);
if (!hconv) err = DdeGetLastError(idDDE);
Sleep(50);
}
}
if (hconv)
{
char* pszCmd;
char szVerb[80] = open”;
if (fAdd != -1) lstrcat(szVerb, fAdd ? “-add” : “-noadd”);
if (fViewAll != -1) lstrcat(szVerb, fViewAll ? “-viewall” : “-noviewall”);
pszCmd = (char*)malloc(lstrlen(szVerb) + lstrlen(pszFiles) + 5);
// wsprintf does not work with >1024 character strings
wsprintf(pszCmd, “[%s(“, szVerb);
lstrcat(pszCmd, pszFiles);
lstrcat(pszCmd, “)]”);
DdeClientTransaction((BYTE*)pszCmd, lstrlen(pszCmd)+1, hconv, 0, 0,
XTYP_EXECUTE, TIMEOUT_ASYNC, NULL);
err = DdeGetLastError(idDDE);
free(pszCmd);
}
DdeFreeStringHandle(idDDE, hszDDEService);
DdeFreeStringHandle(idDDE, hszDDETopic);
DdeUninitialize(idDDE);
}
return err;
}
void main()
{
DDEView(“ACDSee5.exe, “\”c:\\images\\cat.jpg\”, \”c:\\images\\dog.jpg\””, 0, 0);
}
211