#include #include "RegEdit.h" #ifndef DBCS #define AnsiNext(x) ((x)+1) #endif #define NUMACTIONS (ID_LASTACTIONRADIO-ID_FIRSTACTIONRADIO+1) #define EDITSPERACTION (ID_LASTEDIT-ID_FIRSTACTIONEDIT+1) #define OFFSET_COMMAND 0 #define OFFSET_FIRSTDDE 1 #define OFFSET_DDEEXEC 1 #define OFFSET_DDEIFEXEC 2 #define OFFSET_DDEAPP 3 #define OFFSET_DDETOPIC 4 #define BLOCKLEN 100 char szNull[] = ""; static char szShell[] = "shell"; static char szCommand[] = "command"; static char szDDEExec[] = "ddeexec"; static char szDDEIfExec[] = "ddeexec\\ifexec"; static char szDDEApplication[] = "ddeexec\\application"; static char szDDETopic[] = "ddeexec\\topic"; static char *ppCommands[] = { szCommand, szDDEExec, szDDEIfExec, szDDEApplication, szDDETopic } ; static char szOpen[] = "open"; static char szPrint[] = "print"; static char *ppActionIds[] = { szOpen, szPrint } ; static char szSystem[] = "System"; char cUsesDDE[NUMACTIONS]; HANDLE *pLocalVals = NULL; WORD NEAR PASCAL CreateId(HANDLE hId) { HKEY hKeyNew; PSTR pId, pTemp; WORD wErrMsg = IDS_INVALIDID; pId = LocalLock(hId); if(!*pId || *pId=='.') goto Error1; for(pTemp=pId; *pTemp; ++pTemp) /* this excludes '\\' and all other chars except 33-127 */ if(*pTemp=='\\' || *pTemp<=' ') goto Error1; wErrMsg = IDS_EXISTS; if(RegOpenKey(HKEY_CLASSES_ROOT, pId, &hKeyNew) == ERROR_SUCCESS) goto Error2; if(wErrMsg=GetErrMsg((WORD)RegCreateKey(HKEY_CLASSES_ROOT, pId, &hKeyNew))) goto Error1; wErrMsg = NULL; Error2: RegCloseKey(hKeyNew); Error1: LocalUnlock(hId); return(wErrMsg); } WORD NEAR PASCAL MyGetClassName(HANDLE hId, HANDLE *hName) { WORD wErrMsg; wErrMsg = GetErrMsg((WORD)MyQueryValue(HKEY_CLASSES_ROOT, LocalLock(hId), hName)); LocalUnlock(hId); return(wErrMsg); } WORD NEAR PASCAL DeleteClassId(HANDLE hId) { WORD wErrMsg; wErrMsg = GetErrMsg((WORD)RegDeleteKey(HKEY_CLASSES_ROOT, LocalLock(hId))); LocalUnlock(hId); return(wErrMsg); } WORD NEAR PASCAL MergeData(HWND hWndName, HANDLE hId) { HANDLE hName; HANDLE *phTemp; WORD wErrMsg = IDS_OUTOFMEMORY; HKEY hKeyId, hKeyShell, hKeyAction; int i, j; if(!(hName=GetEditString(hWndName))) goto Error2; if(wErrMsg=GetErrMsg((WORD)RegOpenKey(HKEY_CLASSES_ROOT, LocalLock(hId), &hKeyId))) goto Error3; if(wErrMsg=GetErrMsg((WORD)RegCreateKey(hKeyId, szShell, &hKeyShell))) goto Error4; if(wErrMsg=GetErrMsg((WORD)RegSetValue(hKeyId, szNull, (DWORD)REG_SZ, LocalLock(hName), 0L))) goto Error5; for(i=0, phTemp=pLocalVals; i=OFFSET_FIRSTDDE) { if(*phTemp) cUsesDDE[i] = 1; else if(j == OFFSET_DDETOPIC) { *phTemp = StringToLocalHandle(szSystem, LMEM_MOVEABLE); } else if(j == OFFSET_DDEAPP) { HANDLE hTemp; if(hTemp = *(phTemp-(OFFSET_DDEAPP+OFFSET_COMMAND))) *phTemp = StringToLocalHandle(GetAppName(hTemp), LMEM_MOVEABLE); } } } RegCloseKey(hSubKey); } wErrMsg = NULL; Error5: RegCloseKey(hKeyShell); Error4: RegCloseKey(hKeyId); Error3: LocalUnlock(hId); Error1: return(wErrMsg); }