//=========================================================================== // Register a new class. // Parameters -------------------------------------------------------------- // HWND hwnd : window handle // Return value ------------------------------------------------------------ // VOID //=========================================================================== static VOID addItem(HWND hwnd) { PWPSCLASSLIST pClassList; ULONG cbClassList = 0; CHAR className[64]; CHAR moduleName[CCHMAXPATH]; CHAR buf[1024]; DlgItemText(hwnd, EF_CLASSNAME, sizeof(className), className); DlgItemText(hwnd, EF_MODULENAME, sizeof(moduleName), moduleName); sprintf(buf, SZ_CONFIRMADD, className, moduleName); if (NULL != (pClassList = getWPSClassData(hwnd))) { cbClassList = pClassList->cbData; free(pClassList); } /* endif */ if (userConfirmAction(hwnd, buf)) { if (!WinRegisterObjectClass(className, moduleName)) { buf[0] = 0; if (cbClassList && (NULL != (pClassList = getWPSClassData(hwnd)))) { if (cbClassList != pClassList->cbData) sprintf(buf, SZERR_ADD2, className, moduleName); free(pClassList); } /* endif */ if (!buf[0]) sprintf(buf, SZERR_ADD, className, moduleName); notifyError(hwnd, buf); } else { sprintf(buf, SZ_FORMATSTR, className, moduleName); dLbxItemIns(hwnd, LBOX_CLASS, LIT_SORTASCENDING, buf); } /* endif */ } /* endif */ }
BOOL WPS_WPClass (PWPS_WPCLASS CustomPtr) { CHAR DLLName[MAXFILELENGTH]; ULONG CRC32; PMINSTFILE CurFilePtr; if (FILE_IncludesPath(CustomPtr->WPDllName)) { strcpy (DLLName, CustomPtr->WPDllName); } else { // If DLL-Name doesnt contain path already, we search for the file in // filelist and add the corresponding path. strlwr (CustomPtr->WPDllName); FILE_SetDefaultExtension (CustomPtr->WPDllName, MINSTMAX_PATHLENGTH, ".dll"); CRC32 = CRC32_GetFromPSZ(CustomPtr->WPDllName); if ((CurFilePtr = MINSTALL_SearchFileCRC32(CRC32))!=0) { if (!STRING_CombinePSZ (DLLName, MAXFILELENGTH, CurFilePtr->DestinPtr->FQName, CustomPtr->WPDllName)) return FALSE; // buffer-overflow } else { strcpy (DLLName, CustomPtr->WPDllName); } } // Register the class at any time... if (!WinRegisterObjectClass (CustomPtr->WPClassNameNew, DLLName)) return FALSE; if (strlen(CustomPtr->WPReplaceClass)>0) { // If Replace-Class set, replace this class with the new one... if (!WinReplaceObjectClass (CustomPtr->WPReplaceClass, CustomPtr->WPClassNameNew, TRUE)) return FALSE; } return TRUE; }
BOOL install(char *dll, char *newclass, char *oldclass) { if (WinRegisterObjectClass(newclass,dll) && WinReplaceObjectClass(oldclass,newclass,TRUE)) { printf("%s successfully registered and %s successfully subclassed.\n",newclass,oldclass); return TRUE; } else { printf("%s NOT successfully subclassed.\n",oldclass); return FALSE; } }
extern BOOL ShrInstall(PSZ pszDLL) { CHAR szText[256]; USHORT usResponse; APIRET rc; HMODULE hmod; PSZ psz; sprintf(szText, "Register Address Book DLL '%s'?", pszDLL); usResponse = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szText, vszMessageTitle, 0, MB_YESNO | MB_MOVEABLE | MB_ICONQUESTION); if (usResponse != MBID_YES) return FALSE; rc = DosLoadModule(NULL, 0, pszDLL, &hmod); if (rc == ERROR_FILE_NOT_FOUND) { sprintf(szText, "Address Book DLL '%s' not found.", pszDLL); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szText, vszMessageTitle, 0, MB_ENTER | MB_MOVEABLE | MB_ERROR); return FALSE; } else if (rc == ERROR_PATH_NOT_FOUND) { psz = strrchr(pszDLL, '\\'); *psz = '\0'; sprintf(szText, "Path '%s' is not valid.", pszDLL); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szText, vszMessageTitle, 0, MB_ENTER | MB_MOVEABLE | MB_ERROR); return FALSE; } else if (rc == ERROR_BAD_EXE_FORMAT) { sprintf(szText, "Address Book DLL '%s' is corrupted. " "Verify you downloaded it correctly and try again.", pszDLL); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szText, vszMessageTitle, 0, MB_ENTER | MB_MOVEABLE | MB_ERROR); return FALSE; } else if (rc != 0) { sprintf(szText, "DosLoadModule failed with a return code of %u. " "Type HELP SYS%u at an OS/2 command prompt for " "a list of possible causes of the error.", rc, rc); WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szText, vszMessageTitle, 0, MB_ENTER | MB_MOVEABLE | MB_ERROR); return FALSE; } if (!WinRegisterObjectClass("ShrPerson", pszDLL)) { WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Unable to register Person class.", vszMessageTitle, 0, MB_ENTER | MB_MOVEABLE | MB_ERROR); return FALSE; } if (!WinRegisterObjectClass("ShrFolder", pszDLL)) { WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Unable to register ShrFolder class.", vszMessageTitle, 0, MB_ENTER | MB_MOVEABLE | MB_ERROR); return FALSE; } if (!WinRegisterObjectClass("ShrAddressBook", pszDLL)) { WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Unable to register Address Book class.", vszMessageTitle, 0, MB_ENTER | MB_MOVEABLE | MB_ERROR); return FALSE; } if (!WinCreateObject("ShrAddressBook", "Address Book", " ", "<WP_DESKTOP>", CO_REPLACEIFEXISTS)) { WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Unable to create Address Book.", vszMessageTitle, 0, MB_ENTER | MB_MOVEABLE | MB_ERROR); return FALSE; } else { WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Address Book created.", vszMessageTitle, 0, MB_ENTER | MB_MOVEABLE); } return TRUE; }