示例#1
0
static
KpInt32_t getOEMInfo (initializedGlobals_p iGblP)
{
	KpModuleId appId;
	KpInt32_t ret;
	KpUInt32_t theSize;
	char resBuf[128], regPath[256];
	char tmpBuf [256], iniName[20];

	if (iGblP == NULL) {
		return (-1);
	}

	/* get the ini file name */
	KpFileStripPath (kcp_ini, iniName);

	/* locate the application id for the app that loaded the */
	/* Color Processor  but use the one provided by the app  */
	/* if there is one. */
	if (iGblP->appModuleId == NULL)
		appId = GetModuleHandle (NULL);
	else
		appId = iGblP->appModuleId;
	if (appId == NULL) {
		return (-1);
	}

	/* get the oem company name from the resource of the app */
	ret = KpGetCString (appId, 0, KPCPOEMNAME, resBuf, sizeof(resBuf));
	if (ret != KCMS_SUCCESS) {
		return (-1);
	}

	/* create the registry sub keys */
	strcpy (regPath, "OEM\\");
	strcat (regPath, resBuf);
	strcat (regPath, KcpFileDirSep);
	strcat (regPath, iniName);
	strcat (regPath, KcpFileDirSep);
	strcat (regPath, "KEPS Precision");

	/* get the drive letter */
	theSize = sizeof(iGblP->KCPDataDir);
	ret = KpReadRegistryString (KPLOCAL_MACHINE, regPath, "DRIVE",
								iGblP->KCPDataDir, &theSize);
	if (ret != KCMS_SUCCESS) {
		return (-1);
	}

	/* make sure that the retrun data string is not null */
	if (iGblP->KCPDataDir == NULL) {
		return (-1);
	}

	/* make sure there is no back slash, will be added below */
	iGblP->KCPDataDir[2] = '\0';

	/* create the registry sub keys */
	strcpy (regPath, "OEM\\");
	strcat (regPath, resBuf);
	strcat (regPath, KcpFileDirSep);
	strcat (regPath, iniName);
	strcat (regPath, KcpFileDirSep);
	strcat (regPath, "KCP");

	/* get the CP data path */
	theSize = sizeof(tmpBuf);
	ret = KpReadRegistryString (KPLOCAL_MACHINE, regPath, "CP_DIR",
								tmpBuf, &theSize);
	if (ret != KCMS_SUCCESS) {
		return (-1);
	}

	if (tmpBuf[0] != KcpFileDirSep[0]) {
		addDirSep (iGblP->KCPDataDir);
	}

	strcat (iGblP->KCPDataDir, tmpBuf);
	addDirSep (iGblP->KCPDataDir);

#if defined(KCP_ACCEL)
	/* get the hardware accelerator */
	theSize = sizeof(kcp_cte_name);
	KpReadRegistryString (KPLOCAL_MACHINE, regPath, "CTE32_NAME",
								kcp_cte_name, &theSize);
	if (ret != KCMS_SUCCESS) {
		kcp_cte_name[0] = '\0';
	}
#endif

	return (0);
}
示例#2
0
/*--------------------------------------------------------------------
 * DESCRIPTION	(private)
 *	Get the default profile data base path for windows.  The path
 *	is returned in the buffer pointed to by pDataBasePath.  The 
 *	size of the buffer in bytes is specified by size.
 *
 * AUTHOR
 * 	M. Biamonte
 *
 * DATE CREATED
 *	November 16, 1995
 *------------------------------------------------------------------*/
SpStatus_t KSPAPI GetWinDefaultDB (KpTChar_p pDataBasePath, KpInt32_t size)
{

	KpInt32_t			retVal;
	KpChar_t			*p;
	HANDLE				hFindFile;
	WIN32_FIND_DATA		findData;
	char 				defProfileDB [DEFPROFILEDBSIZE];
	DWORD				dwSize = DEFPROFILEDBSIZE;
	KpChar_t			FAR ColorDir[256];
	HMODULE				hLib;
	BOOL				result = FALSE;

	*pDataBasePath = '\0';

	hLib = LoadLibrary("mscms.dll");
	if (hLib != NULL)
	{
		result = GetFunctionAddress(hLib, GETCOLORDIRNAME, (FARPROC FAR *)&GetColorDirFunc);
		if (result == TRUE) 
		{
			result = GetColorDirFunc(NULL, defProfileDB, &dwSize);
		}
		FreeLibrary(hLib);
	}
	if(result == FALSE)
	{
		/* Create the {Windows System Directory}\Color
		   directory to use as the default */
		retVal = GetSystemDirectory (defProfileDB, sizeof (defProfileDB));
		if (0 == retVal) {
			return SpStatFileNotFound;
		}

		/* Check for room to add  \\Color */
		LoadString(SpHInst, SpColorStr, (LPSTR)ColorDir, 255);
		if (retVal >= (KpInt32_t) (size - strlen (ColorDir) + 1)) {
			return SpStatBufferTooSmall;
		} 
		strcat (defProfileDB, KcpFileDirSep);
		strcat (defProfileDB, ColorDir);
	}

	/* Read default DB from registry.  If one is not present, set registry to
	   default of windows\system\color.  Note - this doesn't use the
	   KpReadStringPreferenceEx call so that the ini file stuff is skipped.  */

	retVal = KpReadRegistryString ( KPLOCAL_MACHINE, 
			(KpChar_p) sectICCProfiles,
			(KpChar_p) keyDefPath, 
			pDataBasePath, 
			(KpUInt32_p)&size);

	if (KCMS_SUCCESS != retVal) {
		if (KCMS_MORE_DATA == retVal) {
			return SpStatBufferTooSmall;
		}
		else {
			/* write registry entry */
			retVal = KpWriteRegistryString (KPLOCAL_MACHINE, (KpChar_p) sectICCProfiles,
							(KpChar_p) keyDefPath, defProfileDB);
			if (KCMS_SUCCESS != retVal)
				return SpStatFileNotFound;
			strncpy (pDataBasePath, defProfileDB, size);
		}
	}

	/* if trailing file separator - remove it */
	p = strrchr (pDataBasePath, '\\');
	if (p != NULL) {
		if (*(p+1) == '\0') {
			*p = '\0';
		}
	}

	/*	Check if path exists	*/
	hFindFile = FindFirstFile (pDataBasePath, &findData);

	if (INVALID_HANDLE_VALUE == hFindFile) {
		FindClose(hFindFile);
		return (SpStatFileNotFound);
	}
	FindClose(hFindFile);
	if (0 == (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {		
		return (SpStatFileNotFound);
	}

	return SpStatSuccess;

}