/* This should be during startup in WinMain */ BOOL dde_initialise() { lpDdeProc = MakeProcInstance((FARPROC)GSviewDdeCallback, phInstance); if (DdeInitialize(&idInst, (PFNCALLBACK)lpDdeProc, CBF_FAIL_POKES, 0L)) { return FALSE; } hszService = DdeCreateStringHandleA(idInst, (LPSTR)szServiceName, 0); hszTopic = DdeCreateStringHandleA(idInst, (LPSTR)szTopicName, 0); return TRUE; }
/***************************************************************** * DdeCreateStringHandle (DDEML.21) */ HSZ WINAPI DdeCreateStringHandle16(DWORD idInst, LPCSTR str, INT16 codepage) { if (codepage) { return DdeCreateStringHandleA(idInst, str, codepage); } else { TRACE("Default codepage supplied\n"); return DdeCreateStringHandleA(idInst, str, CP_WINANSI); } }
HSZ gcDDEManager::atomFromString(const char* string) { HSZ hsz = DdeCreateStringHandleA(m_hDDEIdInst, string, CP_WINANSI); m_vAtomList.insert(hsz); return hsz; }
DDEstring::DDEstring(const char *name) : hSz(NULL) { /* Was aeeror with invalid converting to (CHAR*) */ hSz = DdeCreateStringHandleA(*DDEbase::base, (CHAR*)name, CP_WINANSI); }
SleepyApi::Impl::Impl() : m_conv(NULL) { assert(m_instance==NULL); m_instance=this; m_appId=0; if (DdeInitializeA(&m_appId,OnDdeCallback,APPCMD_CLIENTONLY,0)!=DMLERR_NO_ERROR) { m_appId=0; } else { m_service=DdeCreateStringHandleA(m_appId,"VerySleepyProfilerServer",CP_WINANSI); m_topic=DdeCreateStringHandleA(m_appId,"Control.1",CP_WINANSI); m_paused=DdeCreateStringHandleA(m_appId,"paused",CP_WINANSI); TryConnect(); } }
/* Assume dde_initialise has already been called */ BOOL dde_execute(char *str) { HSZ hszServName; HSZ hszTopicName; HCONV hConv; DWORD dwResult = DDE_FNOTPROCESSED; /* Make connection to server */ hszServName = DdeCreateStringHandleA(idInst, (LPSTR)szServiceName, CP_WINANSI); hszTopicName = DdeCreateStringHandleA(idInst, (LPSTR)szTopicName, CP_WINANSI); hConv = DdeConnect(idInst, hszServName, hszTopicName, (PCONVCONTEXT)NULL); if (hConv == NULL) { DdeFreeStringHandle(idInst, hszServName); DdeFreeStringHandle(idInst, hszTopicName); if (debug) gs_addmess("DdeConnect failed\r\n"); return FALSE; } /* send command */ DdeClientTransaction((LPBYTE)str, strlen(str)+1, hConv, NULL, CF_TEXT, XTYP_EXECUTE, 10000, &dwResult); /* Disconnect from server */ DdeDisconnect(hConv); DdeFreeStringHandle(idInst, hszServName); DdeFreeStringHandle(idInst, hszTopicName); if (debug) { gs_addmess("Sent XTYP_EXECUTE: "); gs_addmess(str); gs_addmess("\r\n"); } return (dwResult == DDE_FACK); }
int gsview_progman(char *groupname, char *gsviewpath, int gsver, char *gspath, char *gsargs) { DWORD idInst = 0L; FARPROC lpDdeProc; HSZ hszServName; HSZ hszSysTopic; HSZ hszGroupsItem; HCONV hConv; HDDEDATA hdata = NULL; char setup[MAXSTR+MAXSTR]; DWORD dwResult; char groupfile[MAXSTR]; int i; char *s, *d; FILE *ddefile; char gspathbuf[MAXSTR]; char gsviewpathbuf[MAXSTR]; char gsdocbuf[MAXSTR]; strncpy(gspathbuf, gspath, sizeof(gspathbuf)/sizeof(TCHAR)); strncpy(gsdocbuf, gsargs, sizeof(gsdocbuf)/sizeof(TCHAR)); d = strchr(gsdocbuf, ';'); if (d) *d = '\0'; if (gsver >= 593) { d = strrchr(gsdocbuf, '\\'); if (d) { d++; strcpy(d, "doc\\"); } } else { strcat(gsdocbuf, "\\"); } strncpy(gsviewpathbuf, gsviewpath, sizeof(gsviewpathbuf)); if (!is_win32s) { /* The DDE interface isn't reliable with long names */ /* Convert everything to short names */ GetShortPathNameA(gspath, gspathbuf, sizeof(gspathbuf)); GetShortPathNameA(gsviewpath, gsviewpathbuf, sizeof(gsviewpathbuf)); } /* Open ProgMan DDE undo file if it doesn't exist */ strcpy(setup, gsviewpathbuf); strcat(setup, GSVIEW_ZIP); d = strrchr(setup, '.'); strcpy(d, "dde.log"); ddefile = fopen(setup, "r"); if (ddefile != (FILE *)NULL) { /* We found a previous ProgMan DDE undo file. */ /* Don't touch it since we want to keep the original record */ /* of the ProgMan state before GSview was installed */ fclose(ddefile); ddefile = (FILE *)NULL; } else { ddefile = fopen(setup, "w"); /* If we fail to open the file for writing, the destination is probably * read only. Don't worry, just don't write to the log file. */ } /* derive group filename from group name */ for (i=0, s=groupname, d=groupfile; i<8 && *s; s++) { if (isalpha((int)(*s)) || isdigit((int)(*s))) { *d++ = *s; i++; } } *d = '\0'; if (strlen(groupfile)==0) strcpy(groupfile, "gstools"); lpDdeProc = MakeProcInstance((FARPROC)DdeCallback, phInstance); if (DdeInitialize(&idInst, (PFNCALLBACK)lpDdeProc, CBF_FAIL_POKES, 0L)) { return 1; } hszServName = DdeCreateStringHandleA(idInst, "PROGMAN", CP_WINANSI); hszSysTopic = DdeCreateStringHandleA(idInst, "PROGMAN", CP_WINANSI); hConv = DdeConnect(idInst, hszServName, hszSysTopic, (PCONVCONTEXT)NULL); if (hConv == NULL) { DdeFreeStringHandle(idInst, hszServName); DdeFreeStringHandle(idInst, hszSysTopic); return 1; } if (ddefile) { /* Find out if group existed */ hszGroupsItem = DdeCreateStringHandleA(idInst, groupname, CP_WINANSI); hdata = DdeClientTransaction((LPBYTE)NULL, 0, hConv,\ hszGroupsItem, CF_TEXT, XTYP_REQUEST, 5000, &dwResult); DdeFreeStringHandle(idInst, hszGroupsItem); } #define DDEEXECUTE(str)\ DdeClientTransaction((LPBYTE)str, strlen(str)+1, hConv,\ NULL, CF_TEXT, XTYP_EXECUTE, 5000, &dwResult) sprintf(setup, "[CreateGroup(\042%s\042,%s.grp)][ShowGroup(\042%s\042,1)]", groupname, groupfile, groupname); /* display, active */ DDEEXECUTE(setup); if (ddefile) /* display, no active */ fprintf(ddefile, "[ShowGroup(\042%s\042,8)]\n",groupname); sprintf(setup, "[ReplaceItem(\042%s\042)]", GSVIEW_NAME); DDEEXECUTE(setup); #ifdef _WIN64 #define GSVIEW_ICON "gsview64.ico" #else #define GSVIEW_ICON "gsview32.ico" #endif if (!is_win4) sprintf(setup, "[AddItem(\042%s%s\042,\042%s\042, \042%s%s\042)]", gsviewpathbuf, GSVIEW_EXENAME, GSVIEW_NAME, gsviewpathbuf, GSVIEW_ICON); else sprintf(setup, "[AddItem(\042%s%s\042,\042%s\042)]", gsviewpathbuf, GSVIEW_EXENAME, GSVIEW_NAME); DDEEXECUTE(setup); if (ddefile) fprintf(ddefile, "[DeleteItem(\042%s\042)]\n", GSVIEW_NAME); /* Win3.1 documentation says you must put quotes around names */ /* with embedded spaces. */ /* In Win95, it appears you must put quotes around the EXE name */ /* and options separately */ sprintf(setup, "[ReplaceItem(\042GSview README\042)]"); DDEEXECUTE(setup); #ifdef NOTUSED_IN_GSVIEW28 if (!is_win4) sprintf(setup, "[AddItem(\042notepad.exe %sREADME.TXT\042,\042GSview README\042)]", gsviewpathbuf); else sprintf(setup, "[AddItem(\042notepad.exe\042 \042%sREADME.TXT\042,\042GSview README\042,\042notepad.exe\042,1)]", gsviewpathbuf); #endif sprintf(setup, "[AddItem(\042%sReadme.htm\042,\042GSview README\042)]", gsviewpathbuf); DDEEXECUTE(setup); if (ddefile) fprintf(ddefile, "[DeleteItem(\042%s\042)]\n", "GSview README"); sprintf(setup, "[ReplaceItem(\042Ghostscript\042)]"); DDEEXECUTE(setup); if (!is_win4) sprintf(setup, "[AddItem(\042%s%s -I%s\042,\042Ghostscript\042, \042%sgstext.ico\042)]", gspathbuf, GS_EXENAME, gsargs, gspathbuf); else sprintf(setup, "[AddItem(\042%s%s\042 \042-I%s\042,\042Ghostscript\042)]", gspathbuf, GS_EXENAME, gsargs); DDEEXECUTE(setup); if (ddefile) fprintf(ddefile, "[DeleteItem(\042%s\042)]\n", "Ghostscript"); sprintf(setup, "[ReplaceItem(\042Ghostscript README\042)]"); DDEEXECUTE(setup); if (gsver >= 540) { sprintf(setup, "[AddItem(\042%sReadme.htm\042,\042Ghostscript README\042)]", gsdocbuf); } else { if (!is_win4) sprintf(setup, "[AddItem(\042notepad.exe %sREADME.\042,\042Ghostscript README\042)]", gsdocbuf); else sprintf(setup, "[AddItem(\042notepad.exe\042 \042%sREADME.\042,\042Ghostscript README\042, \042notepad.exe\042,1)]", gsdocbuf); } DDEEXECUTE(setup); if (ddefile) fprintf(ddefile, "[DeleteItem(\042%s\042)]\n", "Ghostscript README"); #undef DDEXECUTE /* Now remember the way things were */ if (ddefile) { if (hdata) { DWORD dlen; BYTE FAR *lpData = DdeAccessData(hdata, &dlen); LPSTR p, q; /* skip first line */ q = (LPSTR)lpData; while (*q && (*q != '\r') && (*q != '\n')) q++; while (*q && ((*q == '\r') || (*q == '\n'))) q++; p = q; /* for each group item */ while (*p) { /* skip to end of line */ while (*q && (*q != '\r') && (*q != '\n')) q++; strncpy(setup, p, (int)(q-p)+1); add_group_item(ddefile, setup); /* skip to start of next group name */ while (*q && ((*q == '\r') || (*q == '\n'))) q++; p = q; } if (ddefile) /* display, no active */ fprintf(ddefile, "[ShowGroup(\042%s\042,8)]\n",groupname); DdeUnaccessData(hdata); DdeFreeDataHandle(hdata); } else { /* group didn't exist before, so delete it */ fprintf(ddefile, "[DeleteGroup(\042%s\042)]\n", groupname); } fclose(ddefile); } DdeDisconnect(hConv); DdeFreeStringHandle(idInst, hszServName); DdeFreeStringHandle(idInst, hszSysTopic); DdeUninitialize(idInst); return 0; }
DDEstring::DDEstring(const char *name) : hSz(NULL) { hSz = DdeCreateStringHandleA(*DDEbase::base, name, CP_WINANSI); }
/* MAKE_EXPORT DdeCreateStringHandleW_new=DdeCreateStringHandleW */ HSZ WINAPI DdeCreateStringHandleW_new(DWORD idInst, LPWSTR pszW, int iCodePage) { ALLOC_WtoA(psz); return DdeCreateStringHandleA(idInst, pszA, iCodePage); }