示例#1
0
void noise_get_heavy(void (*func) (void *, int))
{
    HANDLE srch;
    WIN32_FIND_DATA finddata;
    DWORD pid;
    char winpath[MAX_PATH + 3];

    GetWindowsDirectory(winpath, sizeof(winpath));
    strcat(winpath, "\\*");
    srch = FindFirstFile(winpath, &finddata);
    if (srch != INVALID_HANDLE_VALUE) {
	do {
	    func(&finddata, sizeof(finddata));
	} while (FindNextFile(srch, &finddata));
	FindClose(srch);
    }

    pid = GetCurrentProcessId();
    func(&pid, sizeof(pid));

    read_random_seed(func);
    /* Update the seed immediately, in case another instance uses it. */
    random_save_seed();
}
//////////////////
// Set "hand" cursor to cue user that this is a link. If app has not set
// g_hCursorLink, then try to get the cursor from winhlp32.exe,
// resource 106, which is a pointing finger. This is a bit of a kludge,
// but it works.
//
BOOL CStaticLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
	if (g_hCursorLink == NULL) {
		static BOOL bTriedOnce = FALSE;
		if (!bTriedOnce) {
         CString windir;
         GetWindowsDirectory(windir.GetBuffer(MAX_PATH), MAX_PATH);
         windir.ReleaseBuffer();
         windir += _T("\\winhlp32.exe");
         HMODULE hModule = LoadLibrary(windir);
			if (hModule) {
				g_hCursorLink =
					CopyCursor(::LoadCursor(hModule, MAKEINTRESOURCE(106)));
			}
			FreeLibrary(hModule);
			bTriedOnce = TRUE;
		}
	}
	if (g_hCursorLink) {
		::SetCursor(g_hCursorLink);
		return TRUE;
	}
	return FALSE;
}
示例#3
0
文件: noise.c 项目: rdebath/sgt
void noise_get_heavy(void (*func) (void *, int)) {
    HANDLE srch;
    HANDLE seedf;
    WIN32_FIND_DATA finddata;
    char winpath[MAX_PATH+3];

    GetWindowsDirectory(winpath, sizeof(winpath));
    strcat(winpath, "\\*");
    srch = FindFirstFile(winpath, &finddata);
    if (srch != INVALID_HANDLE_VALUE) {
	do {
	    func(&finddata, sizeof(finddata));
	} while (FindNextFile(srch, &finddata));
	FindClose(srch);
    }

    if (!seedpath[0])
	get_seedpath();

    seedf = CreateFile(seedpath, GENERIC_READ,
		       FILE_SHARE_READ | FILE_SHARE_WRITE,
		       NULL, OPEN_EXISTING, 0, NULL);

    if (seedf != INVALID_HANDLE_VALUE) {
	while (1) {
	    char buf[1024];
	    DWORD len;

	    if (ReadFile(seedf, buf, sizeof(buf), &len, NULL) && len)
		func(buf, len);
	    else
		break;
	}
	CloseHandle(seedf);
    }
}
/***************************************************************************

   Function:   FixFilePath

   Purpose:    Adds the correct path string to a file name according 
               to given file location 

   Input:      Original file name
               File location (Windows dir, System dir, Current dir or none)

   Output:     TRUE only if successful

   Remarks:    Trashes original file name

****************************************************************************/
BOOL CDLLVersion::FixFilePath (char * szFileName, int FileLoc)
{
    char    szPathStr [_MAX_PATH];      // Holds path prefix
   
    switch (FileLoc) 
    {
        case WIN_DIR:
            // Get the name of the windows directory
            if (GetWindowsDirectory (szPathStr, _MAX_PATH) ==  0)  
                return FALSE;   // Cannot get windows directory
            break;

        case SYS_DIR:
            // Get the name of the windows SYSTEM directory
            if (GetSystemDirectory (szPathStr, _MAX_PATH) ==  0)  
                return FALSE;   // Cannot get system directory
            break;

        case CUR_DIR:
            // Get the name of the current directory
            if (GetCurrentDirectory (_MAX_PATH, szPathStr) ==  0)  
                return FALSE;   // Cannot get current directory
            break;

        case NO_DIR:
            lstrcpy (szPathStr,"");
            break;

        default:
            return FALSE;
    }
    lstrcat (szPathStr, _T("\\"));
    lstrcat (szPathStr, szFileName);
    lstrcpy (szFileName, szPathStr);
    return TRUE;
}            
示例#5
0
int dha_uninstall(void)
{
	SC_HANDLE hSCManager = NULL;
	SC_HANDLE hService = NULL;
	char szPath[MAX_PATH];
	int result = 0;

	hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
	hService = OpenService(hSCManager, DRV_NAME, SERVICE_ALL_ACCESS);

	dha_stop();

	result = DeleteService(hService);
	if(!result) print_last_error("Error while deleting service");

	CloseServiceHandle(hService);
	CloseServiceHandle(hSCManager);

	GetWindowsDirectory(szPath, MAX_PATH);
	strcpy(szPath + strlen(szPath), "\\system32\\drivers\\" DRV_FILENAME);
	DeleteFile(szPath);

	return 0;
}
示例#6
0
///////////////////////////////////////////////////////////////////////////////
// SetDefaultCursor
void CXHyperLink::SetDefaultCursor()
{
	if (m_hLinkCursor == NULL)				// No cursor handle - try to load one
	{
		// First try to load the Win98 / Windows 2000 hand cursor

		TRACE(_T("loading from IDC_HAND\n"));
		m_hLinkCursor = AfxGetApp()->LoadStandardCursor(IDC_HAND);

		if (m_hLinkCursor == NULL)			// Still no cursor handle - 
											// load the WinHelp hand cursor
		{
			// The following appeared in Paul DiLascia's Jan 1998 MSJ articles.
			// It loads a "hand" cursor from the winhlp32.exe module.

			TRACE(_T("loading from winhlp32\n"));

			// Get the windows directory
			CString strWndDir;
			GetWindowsDirectory(strWndDir.GetBuffer(MAX_PATH), MAX_PATH);
			strWndDir.ReleaseBuffer();

			strWndDir += _T("\\winhlp32.exe");

			// This retrieves cursor #106 from winhlp32.exe, which is a hand pointer
			HMODULE hModule = LoadLibrary(strWndDir);
			if (hModule) 
			{
				HCURSOR hHandCursor = ::LoadCursor(hModule, MAKEINTRESOURCE(106));
				if (hHandCursor)
					m_hLinkCursor = CopyCursor(hHandCursor);
				FreeLibrary(hModule);
			}
		}
	}
}
示例#7
0
static void
get_home(void)
{
    int len;
    char tmpstr[MAX_PATH+1];
    char* homedrive;
    char* homepath;

    homedrive = get_env("HOMEDRIVE");
    homepath = get_env("HOMEPATH");
    if (!homedrive || !homepath) {
	if (len = GetWindowsDirectory(tmpstr,MAX_PATH)) {
	    home = emalloc(len+1);
	    strcpy(home,tmpstr);
	} else
	    error("HOMEDRIVE or HOMEPATH is not set and GetWindowsDir failed");
    } else {
	home = emalloc(strlen(homedrive)+strlen(homepath)+1);
	strcpy(home, homedrive);
	strcat(home, homepath);
    }
    free_env_val(homedrive);
    free_env_val(homepath);
}
示例#8
0
int php_init_config(char *php_ini_path_override)
{
	char *env_location, *php_ini_search_path;
	int safe_mode_state;
	char *open_basedir;
	int free_ini_search_path=0;
	zend_file_handle fh;
	PLS_FETCH();

	if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) pvalue_config_destructor, 1)==FAILURE) {
		return FAILURE;
	}

	zend_llist_init(&extension_lists.engine, sizeof(zval), (llist_dtor_func_t) free_estring, 1);
	zend_llist_init(&extension_lists.functions, sizeof(zval), (llist_dtor_func_t)  ZVAL_DESTRUCTOR, 1);
	
	safe_mode_state = PG(safe_mode);
	open_basedir = PG(open_basedir);

	env_location = getenv("PHPRC");
	if (!env_location) {
		env_location="";
	}
	if (php_ini_path_override) {
		php_ini_search_path = php_ini_path_override;
		free_ini_search_path = 0;
	} else {
		char *default_location;
		int free_default_location;

#ifdef PHP_WIN32
		default_location = (char *) emalloc(512);
	
		if (!GetWindowsDirectory(default_location,255)) {
			default_location[0]=0;
		}
		free_default_location=1;
#else
		default_location = PHP_CONFIG_FILE_PATH;
		free_default_location=0;
#endif
		php_ini_search_path = (char *) emalloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1);
		free_ini_search_path = 1;
		if(env_location && env_location[0]) {
			sprintf(php_ini_search_path, ".%c%s%c%s", ZEND_PATHS_SEPARATOR, env_location, ZEND_PATHS_SEPARATOR, default_location);
		} else {
			sprintf(php_ini_search_path, ".%c%s", ZEND_PATHS_SEPARATOR, default_location);
		}
		if (free_default_location) {
			efree(default_location);
		}
	}

	PG(safe_mode) = 0;
	PG(open_basedir) = NULL;
	
	fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path);
	if (free_ini_search_path) {
		efree(php_ini_search_path);
	}
	PG(safe_mode) = safe_mode_state;
	PG(open_basedir) = open_basedir;

	if (!fh.handle.fp) {
		return SUCCESS;  /* having no configuration file is ok */
	}
	fh.type = ZEND_HANDLE_FP;
	fh.filename = php_ini_opened_path;

	zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
	
	if (php_ini_opened_path) {
		zval tmp;
		
		tmp.value.str.len = strlen(php_ini_opened_path);
		tmp.value.str.val = zend_strndup(php_ini_opened_path, tmp.value.str.len);
		tmp.type = IS_STRING;
		zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"),(void *) &tmp,sizeof(zval), NULL);
		persist_alloc(php_ini_opened_path);
	}
	
	return SUCCESS;
}
示例#9
0
LPCWSTR GetComspecFromEnvVar(wchar_t* pszComspec, DWORD cchMax, ComSpecBits Bits/* = csb_SameOS*/)
{
	if (!pszComspec || (cchMax < MAX_PATH))
	{
		_ASSERTE(pszComspec && (cchMax >= MAX_PATH));
		return NULL;
	}

	*pszComspec = 0;
	BOOL bWin64 = IsWindows64();

	if (!((Bits == csb_x32) || (Bits == csb_x64)))
	{
		if (GetEnvironmentVariable(L"ComSpec", pszComspec, cchMax))
		{
			// Не должен быть (даже случайно) ConEmuC.exe
			const wchar_t* pszName = PointToName(pszComspec);
			if (!pszName || !lstrcmpi(pszName, L"ConEmuC.exe") || !lstrcmpi(pszName, L"ConEmuC64.exe")
				|| !FileExists(pszComspec)) // ну и существовать должен
			{
				pszComspec[0] = 0;
			}
		}
	}

	// Если не удалось определить через переменную окружения - пробуем обычный "cmd.exe" из System32
	if (pszComspec[0] == 0)
	{
		int n = GetWindowsDirectory(pszComspec, cchMax - 20);
		if (n > 0 && (((DWORD)n) < (cchMax - 20)))
		{
			// Добавить \System32\cmd.exe

			// Warning! 'c:\Windows\SysNative\cmd.exe' не прокатит, т.к. доступен
			// только для 32битных приложений. А нам нужно в общем виде.
			// Если из 32битного нужно запустить 64битный cmd.exe - нужно выключать редиректор.

			if (!bWin64 || (Bits != csb_x32))
			{
				_wcscat_c(pszComspec, cchMax, (pszComspec[n-1] == L'\\') ? L"System32\\cmd.exe" : L"\\System32\\cmd.exe");
			}
			else
			{
				_wcscat_c(pszComspec, cchMax, (pszComspec[n-1] == L'\\') ? L"SysWOW64\\cmd.exe" : L"\\SysWOW64\\cmd.exe");
			}
		}
	}

	if (pszComspec[0] && !FileExists(pszComspec))
	{
		_ASSERTE("Comspec not found! File not exists!");
		pszComspec[0] = 0;
	}

	// Last chance
	if (pszComspec[0] == 0)
	{
		_ASSERTE(pszComspec[0] != 0); // Уже должен был быть определен
		//lstrcpyn(pszComspec, L"cmd.exe", cchMax);
		wchar_t *psFilePart;
		DWORD n = SearchPathW(NULL, L"cmd.exe", NULL, cchMax, pszComspec, &psFilePart);
		if (!n || (n >= cchMax))
			_wcscpy_c(pszComspec, cchMax, L"cmd.exe");
	}

	return pszComspec;
}
示例#10
0
CThirdPage::CThirdPage()
    : CPropertyPage(CThirdPage::IDD),
      m_manufacturerSelected( NULL ),
      m_modelSelected( NULL ),
      m_genericPostscript( NULL ),
      m_genericPCL( NULL ),
      m_initialized(false),
      m_printerImage( NULL )
{
    static const int	bufferSize	= 32768;
    TCHAR				windowsDirectory[bufferSize];
    CString				header;
    WIN32_FIND_DATA		findFileData;
    HANDLE				findHandle;
    CString				prnFiles;
    CString				ntPrint;
    OSStatus			err;
    BOOL				ok;

    m_psp.dwFlags &= ~(PSP_HASHELP);
    m_psp.dwFlags |= PSP_DEFAULT|PSP_USEHEADERTITLE|PSP_USEHEADERSUBTITLE;

    m_psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_INSTALL_TITLE);
    m_psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_INSTALL_SUBTITLE);

    //
    // load printers from ntprint.inf
    //
    ok = GetWindowsDirectory( windowsDirectory, bufferSize );
    err = translate_errno( ok, errno_compat(), kUnknownErr );
    require_noerr( err, exit );

    //
    // <rdar://problem/4826126>
    //
    // If there are no *prn.inf files, we'll assume that the information
    // is in ntprint.inf
    //
    prnFiles.Format( L"%s\\%s", windowsDirectory, kVistaPrintFiles );
    findHandle = FindFirstFile( prnFiles, &findFileData );

    if ( findHandle != INVALID_HANDLE_VALUE )
    {
        CString absolute;

        absolute.Format( L"%s\\inf\\%s", windowsDirectory, findFileData.cFileName );
        err = LoadPrintDriverDefsFromFile( m_manufacturers, absolute, false );
        require_noerr( err, exit );

        while ( FindNextFile( findHandle, &findFileData ) )
        {
            absolute.Format( L"%s\\inf\\%s", windowsDirectory, findFileData.cFileName );
            err = LoadPrintDriverDefsFromFile( m_manufacturers, absolute, false );
            require_noerr( err, exit );
        }

        FindClose( findHandle );
    }
    else
    {
        ntPrint.Format(L"%s\\%s", windowsDirectory, kNTPrintFile);
        err = LoadPrintDriverDefsFromFile( m_manufacturers, ntPrint, false );
        require_noerr(err, exit);
    }

    //
    // load printer drivers that have been installed on this machine
    //
    err = LoadPrintDriverDefs( m_manufacturers );
    require_noerr(err, exit);

    //
    // load our own special generic printer defs
    //
    err = LoadGenericPrintDriverDefs( m_manufacturers );
    require_noerr( err, exit );

exit:

    return;
}
示例#11
0
//取得系統環境
void PH_GetSysFolerInfo()
{
	GetSystemDirectory(SystemDirectory,MAX_PATHa);
	GetWindowsDirectory(WindowDirectory,MAX_PATHa);
	printf("系統目錄    : %s\nWIN目錄     : %s\n",SystemDirectory,WindowDirectory);
}
示例#12
0
static Common::String getDefaultConfigFileName() {
	char configFile[MAXPATHLEN];
#if defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
	OSVERSIONINFO win32OsVersion;
	ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO));
	win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&win32OsVersion);
	// Check for non-9X version of Windows.
	if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) {
		// Use the Application Data directory of the user profile.
		if (win32OsVersion.dwMajorVersion >= 5) {
			if (!GetEnvironmentVariable("APPDATA", configFile, sizeof(configFile)))
				error("Unable to access application data directory");
		} else {
			if (!GetEnvironmentVariable("USERPROFILE", configFile, sizeof(configFile)))
				error("Unable to access user profile directory");

			strcat(configFile, "\\Application Data");
			CreateDirectory(configFile, NULL);
		}

		strcat(configFile, "\\ScummVM");
		CreateDirectory(configFile, NULL);
		strcat(configFile, "\\" DEFAULT_CONFIG_FILE);

		FILE *tmp = NULL;
		if ((tmp = fopen(configFile, "r")) == NULL) {
			// Check windows directory
			char oldConfigFile[MAXPATHLEN];
			GetWindowsDirectory(oldConfigFile, MAXPATHLEN);
			strcat(oldConfigFile, "\\" DEFAULT_CONFIG_FILE);
			if ((tmp = fopen(oldConfigFile, "r"))) {
				strcpy(configFile, oldConfigFile);

				fclose(tmp);
			}
		} else {
			fclose(tmp);
		}
	} else {
		// Check windows directory
		GetWindowsDirectory(configFile, MAXPATHLEN);
		strcat(configFile, "\\" DEFAULT_CONFIG_FILE);
	}
#elif defined(UNIX)
	// On UNIX type systems, by default we store the config file inside
	// to the HOME directory of the user.
	//
	// GP2X is Linux based but Home dir can be read only so do not use
	// it and put the config in the executable dir.
	//
	// On the iPhone, the home dir of the user when you launch the app
	// from the Springboard, is /. Which we don't want.
#if defined(ANDROID)
	const char *home = "/sdcard";
#else
	const char *home = getenv("HOME");
#endif
	if (home != NULL && strlen(home) < MAXPATHLEN)
		snprintf(configFile, MAXPATHLEN, "%s/%s", home, DEFAULT_CONFIG_FILE);
	else
		strcpy(configFile, DEFAULT_CONFIG_FILE);
#else
	strcpy(configFile, DEFAULT_CONFIG_FILE);
#endif

	return configFile;
}
示例#13
0
文件: init.c 项目: cypherfox/gpkcs11
/* {{{ CI_FindConfFile */
CK_DEFINE_FUNCTION(CK_RV, CI_FindConfFile)(
)
{
  CK_RV rv = CKR_OK;              /* function return value */
  CK_ULONG level;
  
  CI_LogEntry("CI_FindConfFile", "starting...", rv, 1);

  /*******************************************************************
   *         Find Config-File                                        *
   *******************************************************************/
  /* check environment variable GPKCS11_CONF */
  CK_I_config_fname = getenv("GPKCS11_CONF");
  if(CK_I_config_fname == NULL_PTR)
    {
      /* Architecture dependent seach for filename. */
#if defined (CK_Win32)
      /* {{{ filename for Win32 */

{
	FILE *f;

	/* first search the current directory for config-file */

	// " '.'  + seperator +  CK_I_WINDOWS_RC_FNAME + \0" 
	CK_I_config_fname = TC_malloc(sizeof(CK_CHAR) * (1 + 1 
				     + strlen(CK_I_WINDOWS_RC_FNAME) + 1));
	if( CK_I_config_fname == NULL_PTR )
		{
			rv = CKR_HOST_MEMORY;
			CI_LogEntry("CI_FindConfFile", "Allocating Buffer Space", 
			rv, 0); 
			return rv;
		}
	
	*CK_I_config_fname = 0;
	strcat(CK_I_config_fname,".\\");
	strcat(CK_I_config_fname,CK_I_WINDOWS_RC_FNAME);

	CI_VarLogEntry("CI_FindConfFile", "trying %s", rv, 1,CK_I_config_fname);

	if( (f = fopen(CK_I_config_fname, "r")) == NULL)
	{
	  if(errno != ENOENT)	
	  {
			rv = CKR_GENERAL_ERROR;
			CI_VarLogEntry("CI_FindConfFile", 
							   "opening file '%s': %s", 
									rv, 0, CK_I_config_fname, strerror(errno)); 
			return rv;
	  }
	  else
	  {
			TC_free(CK_I_config_fname);
			CK_I_config_fname = NULL_PTR; /* nicht gefunden */
	  }
	}
	else
	{
	  fclose(f);
	}
	
	/* if no config-file was found in the current directory, search the user profile */
	if ( CK_I_config_fname == NULL )
	{
		CK_CHAR_PTR application_data_dir = NULL_PTR;
		
		application_data_dir = getenv ("APPDATA");
		if( application_data_dir == NULL_PTR )
		{
			CI_LogEntry("CI_FindConfFile", "'APPDATA' environment varibale not set", 
			CKR_GENERAL_ERROR, 0);
		}else
		{
			if( strlen (application_data_dir) == 0 )
			{
				CI_VarLogEntry("CI_FindConfFile", 
				 "'APPDATA' environment varibale set, but has zero length", 
				 CKR_GENERAL_ERROR, 0, 0); 
			}else
			{
				/* directory + Seperator + 'gpkcs11' + Seperator + CK_I_conf_filename + Seperator + \0 */
				CK_I_config_fname = TC_malloc(sizeof(CK_CHAR) * ( strlen (application_data_dir) 
										 + 1 + strlen ("gpkcs11") + 1 + strlen(CK_I_WINDOWS_RC_FNAME) + 1));
				if( CK_I_config_fname == NULL_PTR )
				{
					rv = CKR_HOST_MEMORY;
					CI_LogEntry("CI_FindConfFile", "Allocating Buffer Space", 
					rv, 0); 
					return rv;
				}
				
				strcpy(CK_I_config_fname,application_data_dir);
				strcat(CK_I_config_fname,"\\");
				strcat(CK_I_config_fname,"gpkcs11");
				strcat(CK_I_config_fname,"\\");
				strcat(CK_I_config_fname,CK_I_WINDOWS_RC_FNAME);
			}
		}
	
		CI_VarLogEntry("CI_FindConfFile", "trying %s", rv, 1,CK_I_config_fname);
		if( (f = fopen(CK_I_config_fname, "r")) == NULL)
		{
			if(errno != ENOENT)	
			{
				rv = CKR_GENERAL_ERROR;
				CI_VarLogEntry("CI_FindConfFile", 
								   "opening file '%s': %s", 
									rv, 0, CK_I_config_fname, strerror(errno)); 
				return rv;
			}else
			{
				TC_free(CK_I_config_fname);
				CK_I_config_fname = NULL_PTR; /* nicht gefunden */
			}
		}
		else
		{
		 fclose(f);
		}
	}


	/* if no config-file was found in the user profile, search the system-directory */
	if ( CK_I_config_fname == NULL )
      {
	CK_CHAR_PTR system_dir = NULL_PTR;
	UINT retlen;
	
	system_dir = TC_malloc(sizeof(CK_CHAR) * MAX_PATH);
	if( system_dir == NULL_PTR )
	  {
	    rv = CKR_HOST_MEMORY;
	    CI_LogEntry("CI_FindConfFile", "Allocating Buffer Space", 
			rv, 0); 
	    return rv;
	  }

	retlen =GetWindowsDirectory(system_dir, MAX_PATH);
	if(retlen == 0 )
	  {
	    rv = CKR_GENERAL_ERROR;
	    CI_VarLogEntry("CI_FindConfFile", 
			   "Retrieving Windows System Directory GetLastError(): %i", 
			   rv, 0, GetLastError()); 
	    return rv;
	  }
	
	if(retlen > MAX_PATH)
	  {
	    /* realloc would move the block first */
	    TC_free(system_dir); 
	    system_dir = TC_malloc(sizeof(CK_CHAR) * retlen);
	    if( system_dir == NULL_PTR )
	      {
		rv = CKR_HOST_MEMORY;
		CI_LogEntry("CI_FindConfFile", "Allocating Buffer Space", 
			    rv, 0); 
		return rv;
	      }

	    GetSystemDirectory(system_dir , retlen);

	    if(retlen == 0 )
	      {
		rv = CKR_GENERAL_ERROR;
		CI_VarLogEntry("CI_FindConfFile", 
			       "Retrieving Windows System Directory GetLastError(): %i", 
			       rv, 0, GetLastError()); 
		TC_free(system_dir); 		
		return rv;
	      }
	  }
	
	/* directory + CK_I_conf_filename + Seperator + \0 */
	CK_I_config_fname = TC_malloc(sizeof(CK_CHAR) * (strlen(system_dir) 
					     + strlen(CK_I_WINDOWS_RC_FNAME) + 1 + 1));
	if( CK_I_config_fname == NULL_PTR )
	  {
	    rv = CKR_HOST_MEMORY;
	    CI_LogEntry("CI_FindConfFile", "Allocating Buffer Space", 
			rv, 0); 
	    TC_free(system_dir); 
	    return rv;
	  }
	
	strcpy(CK_I_config_fname,system_dir);
	strcat(CK_I_config_fname,"\\");
	strcat(CK_I_config_fname,CK_I_WINDOWS_RC_FNAME);
	
	TC_free(system_dir);
      }
}

      /* }}} */
#else
      /* {{{ filename for Solaris and Linux*/

      {
	int fdes;
	CK_CHAR_PTR home_dir = NULL_PTR;
	
	/* look for /etc/gpkcs11rc or $HOME/.gpkcs11.rc */
	CK_I_config_fname = TC_malloc(sizeof(CK_CHAR) * ( strlen("/etc/") + 
					   strlen(CK_I_UNIX_RC_FNAME) + 1 ));
	if( CK_I_config_fname == NULL_PTR )
	  {
	    rv = CKR_HOST_MEMORY;
	    CI_LogEntry("CI_FindConfFile", "Allocating Buffer Space", 
			rv, 0); 
	    return rv;
	  }
	
	strcpy(CK_I_config_fname, "/etc/");
	strcat(CK_I_config_fname, CK_I_UNIX_RC_FNAME);
	
	CI_VarLogEntry("CI_FindConfFile", "trying %s", rv, 1,CK_I_config_fname);
	if( (fdes = open(CK_I_config_fname, O_RDWR)) == -1)
	  {
	    if(errno != ENOENT)  /* Datei existiert nur einfach nicht? */
	      {
		rv = CKR_GENERAL_ERROR;
		CI_VarLogEntry("CI_FindConfFile", 
			       "opening file '%s': %s", 
			       rv, 0, CK_I_config_fname, strerror(errno)); 
		return rv;
	      }
	    else
	      {
		TC_free(CK_I_config_fname);
		CK_I_config_fname = NULL_PTR; /* nicht gefunden */
	      }
	  }
	else
	  close(fdes);
	
	/* an entry in the home directory will override the selection */
	if((home_dir = getenv("HOME")) != NULL_PTR)
	  {
	    /* wir brauchen neuen speicher: home_dir + /. + . + CK_I_UNIX_RC_FNAME + \0 */
	    CK_CHAR_PTR tmp_name = TC_malloc(sizeof(CK_CHAR) * 
					     (strlen(home_dir)
					      + strlen(CK_I_UNIX_RC_FNAME)
					      + strlen("/.") + 1 + 1)); 
	    if( tmp_name == NULL_PTR )
	      {
		rv = CKR_HOST_MEMORY;
		CI_LogEntry("CI_FindConfFile", "Allocating Buffer Space", 
			    rv, 0); 
		return rv;
	      }
	    
	    strcpy(tmp_name, home_dir);
	    strcat(tmp_name, "/.");
	    strcat(tmp_name, CK_I_UNIX_RC_FNAME);
	    
	    CI_VarLogEntry("CI_FindConfFile", "trying %s", rv, 1,tmp_name);
	    if(( (fdes = open(tmp_name, O_RDWR)) == -1) &&
	       (errno != ENOENT))  /* Datei existiert nur einfach nicht? */
	      {
		rv = CKR_GENERAL_ERROR;
		CI_VarLogEntry("CI_FindConfFile", 
			       "opening file '%s': %s", 
			       rv, 0, tmp_name, strerror(errno)); 
		return rv;
	      }
	    
	    if(fdes != -1)
	      {
		if(CK_I_config_fname != NULL_PTR) 
		  TC_free(CK_I_config_fname);
		CK_I_config_fname = tmp_name;
		tmp_name = NULL_PTR;
		CI_VarLogEntry("CI_FindConfFile", "using '%s'", rv, 1,CK_I_config_fname);
		close(fdes);
	      }
	    else
	      {
		CI_VarLogEntry("CI_FindConfFile", "could not open '%s'", rv, 1,tmp_name);
		if(tmp_name != NULL_PTR) TC_free(tmp_name);
	      }
	  }
	
	/* wenn die Datei nicht gefunden ist auf das lokale Verzeichniss hoffen */
	if(CK_I_config_fname == NULL_PTR)
	  {
	    CK_CHAR_PTR curr_dir = getcwd(NULL_PTR, 256/* will be ignored! */);
	    /* alloc speicher: pwd + / + gpkcs11.rc + \0 */
	    CK_I_config_fname = TC_malloc(sizeof(CK_CHAR) * (strlen(CK_I_UNIX_RC_FNAME)
						 + strlen(curr_dir) +1 + 1));
	    if( CK_I_config_fname == NULL_PTR )
	      {
		rv = CKR_HOST_MEMORY;
		CI_LogEntry("CI_FindConfFile", "Allocating Buffer Space", 
			    rv, 0); 
	      }
	    
	    strcpy(CK_I_config_fname, curr_dir);
	    TC_free(curr_dir);
	    strcat(CK_I_config_fname, "/");
	    strcat(CK_I_config_fname, CK_I_UNIX_RC_FNAME);
	    
	    CI_VarLogEntry("CI_FindConfFile", "settling for %s", rv, 1,CK_I_config_fname);
	  }
      }

      /* }}} */
#endif
    }

  /*******************************************************************
   *         Get Logging File                                        *
   *******************************************************************/
  {
    CK_CHAR_PTR buf;
    
    CI_LogEntry("CI_FindConfFile", "trying Profile read", rv, 1);
    rv=CI_GetConfigString(NULL_PTR,"LoggingFile",&buf);
    if(rv == CKR_OK)
      {
	CI_SetLoggingFile(buf);
	TC_free(buf);

      }
    else
      {
	/* if there is not special logging-file we can skip this step */
	/* and use the default                                        */
      }
		rv = CKR_OK;
  } 
  
  /*******************************************************************
   *         Get Loging Level                                        *
   *******************************************************************/
  {
    CK_CHAR_PTR buf;
    
    CI_LogEntry("CI_FindConfFile", "trying Profile read", rv, 1);
    rv=CI_GetConfigString(NULL_PTR,"LoggingLevel",&buf);
    if(rv != CKR_OK)
      return rv;
  
    level = strtoul(buf,NULL,10);
    CI_SetLogingLevel(level);
	TC_free(buf);
	rv = CKR_OK;

  }  
 
  /*******************************************************************
   *         Get Mem-Logging File                                    *
   *******************************************************************/
  {
    CK_CHAR_PTR buf;
    
    CI_LogEntry("CI_FindConfFile", "trying Profile read", rv, 1);
    rv=CI_GetConfigString(NULL_PTR,"MemLoggingFile",&buf);
    if(rv == CKR_OK)
      {
	TC_SetMemLoggingFile(buf);
	TC_free(buf);

      }
    else
     {
       /* if there is not special mem-logging-file we can skip this step */
       /* and use the default                                            */
     }
  }  
  
  /*******************************************************************
   *         Get Extra Library Path                                  *
   *******************************************************************/
  {
    CK_CHAR_PTR path_string = NULL_PTR; /* holder for constructed path */
    CK_C_CHAR_PTR orig_path = NULL_PTR;   /* holder for original path */
    CK_CHAR_PTR xtra_path = NULL_PTR; /* path read from the config file */
#if defined(CK_GENERIC)
    CK_C_CHAR_PTR path_var_name ="LD_LIBRARY_PATH";
    CK_C_CHAR_PTR path_sep = ":";
#else /* Windows */
    CK_C_CHAR_PTR path_var_name ="PATH";
    CK_C_CHAR_PTR path_sep = ";";
#endif
    
    /* Set extra dll path (Has to be set before we load the first token) */
    CI_VarLogEntry("CI_FindConfFile", "starting xtra path read: fname: %s", rv, 1,CK_I_config_fname);

    rv=CI_GetConfigString(NULL_PTR,"ExtraLibraryPath",&xtra_path);
    if(rv != CKR_OK)
      {
	/* if there is not extra path we can skip this step */
	return CKR_OK;
      }
    
    CI_VarLogEntry("CI_FindConfFile", "done xtra lib path read. PATH: %s", 
		   rv, 1,xtra_path);
    
    orig_path = getenv(path_var_name);
    
    if(orig_path == NULL_PTR)
      {
	/* no original path. only put the new path there */
	path_string = xtra_path;
      }
    else
      {
	/* combine the old and the new */
	
	/* (orig +':' +config+ '\0') */
	path_string = TC_malloc(strlen(orig_path) + 1 +
				strlen(xtra_path) + 1);
	if(path_string == NULL_PTR)
	  {
	    rv = CKR_HOST_MEMORY;
	    CI_LogEntry("CI_FindConfFile", "allocating memory for path_string", rv , 0);
	    return rv;
	  }
	sprintf(path_string,"%s%s%s",xtra_path,path_sep,orig_path);
	TC_free(xtra_path); /* has been copied into path_string */
      }
    
    /* This memory we will never get back. putenv is total lunacy */
    {
      CK_CHAR_PTR in_val = TC_malloc(strlen(path_var_name)+1+strlen(path_string)+1);
      sprintf(in_val,"%s=%s",path_var_name,path_string);
      if(putenv(in_val))
	{
	  rv = CKR_GENERAL_ERROR;
	  CI_VarLogEntry("CI_FindConfFile", "putenv(%s) failed", rv, 1,in_val);
	  return rv;
	}
      CI_VarLogEntry("CI_FindConfFile", "putenv(%s)", rv, 1,in_val);
    }		
    TC_free(path_string); /* has been copied into in_val */
  } /* end block for reading extra path */
  
  CI_LogEntry("CI_FindConfFile", "...done", rv, 1);
  return rv;
}
示例#14
0
int PASCAL 
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int cmdShow)
{
DWORD version = GetVersion();
   phInstance = hInstance;
   if ((HIWORD(version) & 0x8000)==0)
      is_winnt = TRUE;
   if (LOBYTE(LOWORD(version)) >= 4)
      is_win4 = TRUE;

   if (lstrlen(lpszCmdLine))
       silent = TRUE;

   LoadString(phInstance, IDS_TITLE, title, sizeof(title)/sizeof(TCHAR)-1);
   LoadString(phInstance, IDS_MONITORNAME, monitorname, 
	sizeof(monitorname)/sizeof(TCHAR)-1);

   /* Check that it really is installed */
   if (EnumMonitors(NULL, 1, (LPBYTE)buffer, sizeof(buffer), 
        &needed, &returned)) {
      MONITOR_INFO_1 *mi;
      mi = (MONITOR_INFO_1 *)buffer;
      for (i=0; i<returned; i++) {
	 if (lstrcmp(mi[i].pName, monitorname) == 0)
	    break;
      }
   }
   else
      return message(IDS_ENUMMONITORS_FAILED);

   if (i == returned)
	return message(IDS_NOT_INSTALLED);

   /* Warn user about what we are about to do */
   if (!silent) {
         TCHAR buf[256];
	 LoadString(phInstance, IDS_INTRO, buf, sizeof(buf)/sizeof(TCHAR)-1);
         if (MessageBox(HWND_DESKTOP, buf, title, MB_YESNO) != IDYES)
	     return 0;
   }

   /* Check if monitor is still in use */
   rc = EnumPorts(NULL, 2, (LPBYTE)buffer, sizeof(buffer), 
      &needed, &returned);
   pi2 = (PORT_INFO_2 *)buffer;
   if (rc) {
      for (i=0; i<returned; i++) {
	 if (lstrcmp(pi2[i].pMonitorName, monitorname) == 0) {
            TCHAR buf[256];
	    LoadString(phInstance, IDS_INUSE, buf, sizeof(buf)/sizeof(TCHAR)-1);
	    wsprintf(sysdir, buf, pi2[i].pPortName);
            MessageBox(HWND_DESKTOP, sysdir, title, MB_OK);
	    return 1;
	 }
      }
   }
   else
      return message(IDS_ENUMPORTS_FAILED);

   /* Try to delete the monitor */
   if (!DeleteMonitor(NULL,  
      NULL /* is_winnt ? MONITORENVNT : MONITORENV95 */, 
      monitorname))
	return message(IDS_DELETEMONITOR_FAILED);

   /* Delete the monitor files */
   if (!GetSystemDirectory(sysdir, sizeof(sysdir)))
	return message(IDS_NOSYSDIR);
   lstrcpy(buffer, sysdir);
   lstrcat(buffer, "\\");
   lstrcat(buffer, is_winnt ? MONITORDLLNT : MONITORDLL95);
   if (!DeleteFile(buffer))
	return message(IDS_ERROR_DELETE_DLL);
   lstrcpy(buffer, sysdir);
   lstrcat(buffer, "\\");
   lstrcat(buffer, MONITORHLP);
   if (!DeleteFile(buffer))
	return message(IDS_ERROR_DELETE_HELP);
   lstrcpy(buffer, sysdir);
   lstrcat(buffer, "\\");
   lstrcat(buffer, REDCONF);
   if (!DeleteFile(buffer))
       return message(IDS_ERROR_DELETE_REDCONF);

   /* delete registry entries for uninstall */
   if ((rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, UNINSTALLKEY, 0, 
	KEY_ALL_ACCESS, &hkey)) == ERROR_SUCCESS) {
	RegDeleteKey(hkey, MONITORKEY);
	RegCloseKey(hkey);
   }

   /* Delete this program, but we can't do it while we are running.
    * Defer deletion until next reboot
    */
   wsprintf(buffer, TEXT("%s\\%s"), sysdir, UNINSTALLPROG);
   if (is_winnt) {
        MoveFileEx(buffer, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
   }
   else {
	char ininame[256];
	GetWindowsDirectory(ininame, sizeof(ininame));
	lstrcat(ininame, "\\wininit.ini");
	/* This method is dodgy, because multiple applications
         * using this method to delete files will overwrite
         * earlier delete instructions.
         */
	WritePrivateProfileString("Rename", "NUL", buffer, ininame);
	SetLastError(0);
   }

#ifdef UNUSED
   /* We should delete this program, but we can't do it
    * while we are running.
    * I think there is a registry key we can create which says
    * "Delete these files on next reboot", but I can't find the 
    * documentation about it.
    * Instead, run a DOS window once to delete the file
    */
    if ((rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
	"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
	0, KEY_ALL_ACCESS, &hkey)) == ERROR_SUCCESS) {
	wsprintf(buffer, "command /c del %s\\%s", sysdir, UNINSTALLPROG);
	RegSetValueEx(hkey, MONITORKEY, 0, REG_SZ,
	    (CONST BYTE *)buffer, lstrlen(buffer)+1);
    }
#endif
   
   
   message(IDS_UNINSTALLED);

   return 0;
}
示例#15
0
文件: freetype.c 项目: forthyen/SDesk
/*****************************************************************************
 * Create: allocates osd-text video thread output method
 *****************************************************************************
 * This function allocates and initializes a Clone vout method.
 *****************************************************************************/
static int Create( vlc_object_t *p_this )
{
    filter_t *p_filter = (filter_t *)p_this;
    filter_sys_t *p_sys;
    char *psz_fontfile = NULL;
    int i, i_error;
    int i_fontsize = 0;
    vlc_value_t val;

    /* Allocate structure */
    p_sys = malloc( sizeof( filter_sys_t ) );
    if( !p_sys )
    {
        msg_Err( p_filter, "out of memory" );
        return VLC_ENOMEM;
    }
    p_sys->p_face = 0;
    p_sys->p_library = 0;

    for( i = 0; i < 256; i++ )
    {
        p_sys->pi_gamma[i] = (uint8_t)( pow( (double)i * 255.0f, 0.5f ) );
    }

    var_Create( p_filter, "freetype-font",
                VLC_VAR_STRING | VLC_VAR_DOINHERIT );
    var_Create( p_filter, "freetype-fontsize",
                VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
    var_Create( p_filter, "freetype-rel-fontsize",
                VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );

    /* Look what method was requested */
    var_Get( p_filter, "freetype-font", &val );
    psz_fontfile = val.psz_string;
    if( !psz_fontfile || !*psz_fontfile )
    {
        if( psz_fontfile ) free( psz_fontfile );
        psz_fontfile = (char *)malloc( PATH_MAX + 1 );
#ifdef WIN32
        GetWindowsDirectory( psz_fontfile, PATH_MAX + 1 );
        strcat( psz_fontfile, "\\fonts\\arial.ttf" );
#elif SYS_DARWIN
        strcpy( psz_fontfile, DEFAULT_FONT );
#else
        msg_Err( p_filter, "user didn't specify a font" );
        goto error;
#endif
    }

    i_error = FT_Init_FreeType( &p_sys->p_library );
    if( i_error )
    {
        msg_Err( p_filter, "couldn't initialize freetype" );
        goto error;
    }

    i_error = FT_New_Face( p_sys->p_library, psz_fontfile ? psz_fontfile : "",
                           0, &p_sys->p_face );
    if( i_error == FT_Err_Unknown_File_Format )
    {
        msg_Err( p_filter, "file %s have unknown format", psz_fontfile );
        goto error;
    }
    else if( i_error )
    {
        msg_Err( p_filter, "failed to load font file %s", psz_fontfile );
        goto error;
    }

    i_error = FT_Select_Charmap( p_sys->p_face, ft_encoding_unicode );
    if( i_error )
    {
        msg_Err( p_filter, "Font has no unicode translation table" );
        goto error;
    }

    p_sys->i_use_kerning = FT_HAS_KERNING( p_sys->p_face );

    var_Get( p_filter, "freetype-fontsize", &val );
    if( val.i_int )
    {
        i_fontsize = val.i_int;
    }
    else
    {
        var_Get( p_filter, "freetype-rel-fontsize", &val );
        i_fontsize = (int)p_filter->fmt_out.video.i_height / val.i_int;
    }
    if( i_fontsize <= 0 )
    {
        msg_Warn( p_filter, "Invalid fontsize, using 12" );
        i_fontsize = 12;
    }
    msg_Dbg( p_filter, "Using fontsize: %i", i_fontsize);

    i_error = FT_Set_Pixel_Sizes( p_sys->p_face, 0, i_fontsize );
    if( i_error )
    {
        msg_Err( p_filter, "couldn't set font size to %d", i_fontsize );
        goto error;
    }

    if( psz_fontfile ) free( psz_fontfile );
    p_filter->pf_render_string = RenderText;
    p_filter->p_sys = p_sys;
    return VLC_SUCCESS;

 error:
    if( p_sys->p_face ) FT_Done_Face( p_sys->p_face );
    if( p_sys->p_library ) FT_Done_FreeType( p_sys->p_library );
    if( psz_fontfile ) free( psz_fontfile );
    free( p_sys );
    return VLC_EGENERIC;
}
示例#16
0
unsigned GetSystemDir( char *buff, unsigned max )
{
    buff[ 0 ] = '\0';
    GetWindowsDirectory( buff, max );
    return( strlen( buff ) );
}
示例#17
0
static GF_Config *create_default_config(char *file_path)
{
	FILE *f;
	GF_Config *cfg;
#if !defined(GPAC_IPHONE) && !defined(GPAC_ANDROID)
	char *cache_dir;
#endif
	char szPath[GF_MAX_PATH];
	char gui_path[GF_MAX_PATH];

	if (! get_default_install_path(file_path, GF_PATH_CFG)) {
		gf_delete_file(szPath);
		return NULL;
	}
	/*Create the config file*/
	sprintf(szPath, "%s%c%s", file_path, GF_PATH_SEPARATOR, CFG_FILE_NAME);
	GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("Trying to create config file: %s\n", szPath ));
	f = fopen(szPath, "wt");
	if (!f) return NULL;
	fclose(f);

#ifndef GPAC_IPHONE
	if (! get_default_install_path(szPath, GF_PATH_MODULES)) {
		gf_delete_file(szPath);
		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] default modules not found\n"));
		return NULL;
	}
#else
	get_default_install_path(szPath, GF_PATH_APP);
#endif

	cfg = gf_cfg_new(file_path, CFG_FILE_NAME);
	if (!cfg) return NULL;

	gf_cfg_set_key(cfg, "General", "ModulesDirectory", szPath);

#if defined(GPAC_IPHONE)
	gf_ios_refresh_cache_directory(cfg, file_path);
#elif defined(GPAC_ANDROID)
	if (get_default_install_path(szPath, GF_PATH_APP)) {
		strcat(szPath, "/cache");
		gf_cfg_set_key(cfg, "General", "CacheDirectory", szPath);
	}
#else
    /*get default temporary directoy */
    cache_dir = gf_get_default_cache_directory();
	
	if (cache_dir) {
		gf_cfg_set_key(cfg, "General", "CacheDirectory", cache_dir);
		gf_free(cache_dir);
	}
#endif

#if defined(GPAC_IPHONE)
    gf_cfg_set_key(cfg, "General", "DeviceType", "iOS");
#elif defined(GPAC_ANDROID)
    gf_cfg_set_key(cfg, "General", "DeviceType", "Android");
#else
    gf_cfg_set_key(cfg, "General", "DeviceType", "Desktop");
#endif
    
	gf_cfg_set_key(cfg, "Compositor", "Raster2D", "GPAC 2D Raster");
	gf_cfg_set_key(cfg, "Audio", "ForceConfig", "yes");
	gf_cfg_set_key(cfg, "Audio", "NumBuffers", "2");
	gf_cfg_set_key(cfg, "Audio", "TotalDuration", "120");
	gf_cfg_set_key(cfg, "Audio", "DisableNotification", "no");

	/*Setup font engine to FreeType by default, and locate TrueType font directory on the system*/
	gf_cfg_set_key(cfg, "FontEngine", "FontReader", "FreeType Font Reader");
	gf_cfg_set_key(cfg, "FontEngine", "RescanFonts", "yes");


#if defined(_WIN32_WCE)
	/*FIXME - is this true on all WinCE systems??*/
	strcpy(szPath, "\\Windows");
#elif defined(WIN32)
	GetWindowsDirectory((char*)szPath, MAX_PATH);
	if (szPath[strlen((char*)szPath)-1] != '\\') strcat((char*)szPath, "\\");
	strcat((char *)szPath, "Fonts");
#elif defined(__APPLE__)

#ifdef GPAC_IPHONE
	strcpy(szPath, "/System/Library/Fonts/Cache,/System/Library/Fonts/AppFonts,/System/Library/Fonts/Core,/System/Library/Fonts/Extra");
#else
	strcpy(szPath, "/Library/Fonts");
#endif

#elif defined(GPAC_ANDROID)
	strcpy(szPath, "/system/fonts/");
#else
	strcpy(szPath, "/usr/share/fonts/truetype/");
#endif
	gf_cfg_set_key(cfg, "FontEngine", "FontDirectory", szPath);

	gf_cfg_set_key(cfg, "Downloader", "CleanCache", "yes");
	gf_cfg_set_key(cfg, "Compositor", "AntiAlias", "All");
	gf_cfg_set_key(cfg, "Compositor", "FrameRate", "30.0");
	/*use power-of-2 emulation in OpenGL if no rectangular texture extension*/
	gf_cfg_set_key(cfg, "Compositor", "EmulatePOW2", "yes");
	gf_cfg_set_key(cfg, "Compositor", "ScalableZoom", "yes");

#if defined(_WIN32_WCE)
	gf_cfg_set_key(cfg, "Video", "DriverName", "GAPI Video Output");
#elif defined(WIN32)
	gf_cfg_set_key(cfg, "Video", "DriverName", "DirectX Video Output");
#elif defined(__DARWIN__) || defined(__APPLE__)
	gf_cfg_set_key(cfg, "Video", "DriverName", "SDL Video Output");
#elif defined(GPAC_ANDROID)
	gf_cfg_set_key(cfg, "Video", "DriverName", "Android Video Output");
gf_cfg_set_key(cfg, "Audio", "DriverName", "Android Audio Output");
#else
	gf_cfg_set_key(cfg, "Video", "DriverName", "X11 Video Output");
	gf_cfg_set_key(cfg, "Audio", "DriverName", "SDL Audio Output");
#endif
#ifdef GPAC_IPHONE
	gf_cfg_set_key(cfg, "Compositor", "DisableGLUScale", "yes");
#endif

	gf_cfg_set_key(cfg, "Video", "SwitchResolution", "no");
	gf_cfg_set_key(cfg, "Video", "HardwareMemory", "Auto");
	gf_cfg_set_key(cfg, "Network", "AutoReconfigUDP", "yes");
	gf_cfg_set_key(cfg, "Network", "UDPTimeout", "10000");
	gf_cfg_set_key(cfg, "Network", "BufferLength", "3000");


	/*locate GUI*/
	if ( get_default_install_path(szPath, GF_PATH_GUI) ) {
		char *sep = strrchr(szPath, GF_PATH_SEPARATOR);
		if (!sep) sep = strrchr(szPath, GF_PATH_SEPARATOR);
		sprintf(gui_path, "%s%cgui.bt", szPath, GF_PATH_SEPARATOR);
		f = gf_fopen(gui_path, "rt");
		if (f) {
			gf_fclose(f);
			gf_cfg_set_key(cfg, "General", "StartupFile", gui_path);
		}

		/*shaders are at the same location*/
		assert(sep);
		sep[0] = 0;
		sprintf(gui_path, "%s%cshaders%cvertex.glsl", szPath, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR);
		gf_cfg_set_key(cfg, "Compositor", "VertexShader", gui_path);
		sprintf(gui_path, "%s%cshaders%cfragment.glsl", szPath, GF_PATH_SEPARATOR, GF_PATH_SEPARATOR);
		gf_cfg_set_key(cfg, "Compositor", "FragmentShader", gui_path);
	}

	/*store and reload*/
	gf_cfg_del(cfg);
	return gf_cfg_new(file_path, CFG_FILE_NAME);
}
示例#18
0
文件: filedlg.c 项目: wesgarner/wine
/* bug 6829 */
static void test_DialogCancel(void)
{
    OPENFILENAMEA ofn;
    BOOL result;
    char szFileName[MAX_PATH] = "";
    char szInitialDir[MAX_PATH];

    GetWindowsDirectory(szInitialDir, MAX_PATH);

    ZeroMemory(&ofn, sizeof(ofn));

    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = NULL;
    ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
    ofn.lpstrFile = szFileName;
    ofn.nMaxFile = MAX_PATH;
    ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLEHOOK;
    ofn.lpstrDefExt = "txt";
    ofn.lpfnHook = OFNHookProc;
    ofn.lpstrInitialDir = szInitialDir;

    PrintDlgA(NULL);
    ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
       "expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());

    result = GetOpenFileNameA(&ofn);
    ok(0 == result, "expected 0, got %d\n", result);
    ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
       CommDlgExtendedError());

    PrintDlgA(NULL);
    ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
       "expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());

    result = GetSaveFileNameA(&ofn);
    ok(0 == result, "expected 0, got %d\n", result);
    ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
       CommDlgExtendedError());

    PrintDlgA(NULL);
    ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
       "expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());

    /* Before passing the ofn to Unicode functions, remove the ANSI strings */
    ofn.lpstrFilter = NULL;
    ofn.lpstrInitialDir = NULL;
    ofn.lpstrDefExt = NULL;

    PrintDlgA(NULL);
    ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
       "expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());

    SetLastError(0xdeadbeef);
    result = GetOpenFileNameW((LPOPENFILENAMEW) &ofn);
    if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
        win_skip("GetOpenFileNameW is not implemented\n");
    else
    {
        ok(0 == result, "expected 0, got %d\n", result);
        ok(0 == CommDlgExtendedError() ||
           broken(CDERR_INITIALIZATION == CommDlgExtendedError()), /* win9x */
           "expected 0, got %d\n", CommDlgExtendedError());
    }

    SetLastError(0xdeadbeef);
    result = GetSaveFileNameW((LPOPENFILENAMEW) &ofn);
    if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
        win_skip("GetSaveFileNameW is not implemented\n");
    else
    {
        ok(0 == result, "expected 0, got %d\n", result);
        ok(0 == CommDlgExtendedError() ||
           broken(CDERR_INITIALIZATION == CommDlgExtendedError()), /* win9x */
           "expected 0, got %d\n", CommDlgExtendedError());
    }
}
示例#19
0
int startup(int argc, char *argv[])
{
    struct op_mask ops; /* Which of the ops do we want to perform? */
    /* First, set the current directory to SystemRoot */
    TCHAR gen_path[MAX_PATH];
    DWORD res;

    res = GetWindowsDirectory(gen_path, sizeof(gen_path));

    if (res==0)
    {
		printf("Couldn't get the windows directory - error %ld\n",
			GetLastError());

		return 100;
    }

    if (res>=sizeof(gen_path))
    {
		printf("Windows path too long (%ld)\n", res);

		return 100;
    }

    if (!SetCurrentDirectory(gen_path))
    {
        wprintf(L"Cannot set the dir to %s (%ld)\n", gen_path, GetLastError());

        return 100;
    }

    if (argc>1)
    {
        switch(argv[1][0])
        {
        case 'r': /* Restart */
            ops=SETUP;
            break;
        case 's': /* Full start */
            ops=SESSION_START;
            break;
        default:
            ops=DEFAULT;
            break;
        }
    } else
        ops=DEFAULT;

    /* Perform the ops by order, stopping if one fails, skipping if necessary */
    /* Shachar: Sorry for the perl syntax */
    res=(ops.ntonly || !ops.preboot || wininit()) &&
        (ops.w9xonly || !ops.preboot || pendingRename()) &&
        (ops.ntonly || !ops.prelogin ||
         ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUNSERVICESONCE], TRUE, FALSE)) &&
        (ops.ntonly || !ops.prelogin || !ops.startup ||
         ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUNSERVICES], FALSE, FALSE)) &&
        (!ops.postlogin ||
         ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUNONCE], TRUE, TRUE)) &&
        (!ops.postlogin || !ops.startup ||
         ProcessRunKeys(HKEY_LOCAL_MACHINE, runkeys_names[RUNKEY_RUN], FALSE, FALSE)) &&
        (!ops.postlogin || !ops.startup ||
         ProcessRunKeys(HKEY_CURRENT_USER, runkeys_names[RUNKEY_RUN], FALSE, FALSE));

    printf("Operation done\n");

    return res?0:101;
}
示例#20
0
BOOL Shortcut_FixStartup (LPCTSTR pszLinkName, BOOL fAutoStart)
{
   TCHAR szShortcut[ MAX_PATH + 10 ] = TEXT("");
   BOOL bSuccess;

   HKEY hk;
   if (RegOpenKey (HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"), &hk) == 0)
      {
      DWORD dwSize = sizeof(szShortcut);
      DWORD dwType = REG_SZ;
      RegQueryValueEx (hk, TEXT("Common Startup"), NULL, &dwType, (LPBYTE)szShortcut, &dwSize);
      if (szShortcut[0] == TEXT('\0'))
         {
         dwSize = sizeof(szShortcut);
         dwType = REG_SZ;
         RegQueryValueEx (hk, TEXT("Startup"), NULL, &dwType, (LPBYTE)szShortcut, &dwSize);
         }
      RegCloseKey (hk);
      }
   if (szShortcut[0] == TEXT('\0'))
      {
      GetWindowsDirectory (szShortcut, MAX_PATH);
      lstrcat (szShortcut, TEXT("\\Start Menu\\Programs\\Startup"));
      }
   lstrcat (szShortcut, TEXT("\\"));
   lstrcat (szShortcut, pszLinkName);

   TCHAR szSource[ MAX_PATH ];
   GetModuleFileName (GetModuleHandle(NULL), szSource, MAX_PATH);

   if (fAutoStart)
   {
       DWORD code, len, type; 
       TCHAR szParams[ 64 ] = TEXT(AFSCREDS_SHORTCUT_OPTIONS);

       code = RegOpenKeyEx(HKEY_CURRENT_USER, AFSREG_USER_OPENAFS_SUBKEY,
                            0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk);
       if (code == ERROR_SUCCESS) {
           len = sizeof(szParams);
           type = REG_SZ;
           code = RegQueryValueEx(hk, "AfscredsShortcutParams", NULL, &type,
                                   (BYTE *) &szParams, &len);
           RegCloseKey (hk);
       }
       if (code != ERROR_SUCCESS) {
           code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_OPENAFS_SUBKEY,
                                0, (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &hk);
           if (code == ERROR_SUCCESS) {
               len = sizeof(szParams);
               type = REG_SZ;
               code = RegQueryValueEx(hk, "AfscredsShortcutParams", NULL, &type,
                                       (BYTE *) &szParams, &len);
               RegCloseKey (hk);
           }
       }
       bSuccess = Shortcut_Create (szShortcut, szSource, "Autostart Authentication Agent", szParams);
   }
   else // (!g.fAutoStart)
   {
      bSuccess = DeleteFile (szShortcut);
   }

   return bSuccess;
}
示例#21
0
TString TWinUtility::GetWindowDir()
{
	TCHAR winDir[MAX_PATH];
	GetWindowsDirectory(winDir,MAX_PATH);
	return TString(winDir);
}
示例#22
0
unsigned GetSystemDir( char *buff, unsigned buff_len )
{
    buff[ 0 ] = '\0';
    GetWindowsDirectory( buff, buff_len );
    return( (unsigned)strlen( buff ) );
}
//----------------------------------------------------------------------------------------
void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirectory)
//----------------------------------------------------------------------------------------
{
    SystemDirectoriesKey dirKey(aSystemSystemDirectory);
    SystemDirectoriesKey mozBinDirKey(Moz_BinDirectory);

    // This flag is used to tell whether or not we need to append something
    // onto the *this.  Search for needToAppend to how it's used.
    // IT's VERY IMPORTANT that needToAppend is initialized to PR_TRUE.
    PRBool needToAppend = PR_TRUE;

    *this = (const char*)nsnull;
    switch (aSystemSystemDirectory)
    {
        
        case OS_DriveDirectory:
#if defined (XP_WIN)
        {
            char path[_MAX_PATH];
            PRInt32 len = GetWindowsDirectory( path, _MAX_PATH );
            if (len)
            {
                if ( path[1] == ':' && path[2] == '\\' )
                    path[3] = 0;
            }
            *this = MakeUpperCase(path);
        }
#elif defined(XP_OS2)
        {
            // printf( "*** Warning warning OS_DriveDirectory called for");
            
            ULONG ulBootDrive = 0;
            char  buffer[] = " :\\OS2\\";
            DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE,
                             &ulBootDrive, sizeof ulBootDrive);
            buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index...
            *this = buffer;
#ifdef DEBUG
            printf( "Got OS_DriveDirectory: %s\n", buffer);
#endif
        }
#else
        *this = "/";
#endif
        break;

            
        case OS_TemporaryDirectory:
#if defined (WINCE)
            {
                *this = "\\TEMP";
            }
#elif defined (XP_WIN)
        {
            char path[_MAX_PATH];
            DWORD len = GetTempPath(_MAX_PATH, path);
            *this = MakeUpperCase(path);
        }
#elif defined(XP_OS2)
          {
             char buffer[CCHMAXPATH] = "";
             char *c = getenv( "TMP");
             if( c) strcpy( buffer, c);
             else
             {
                c = getenv( "TEMP");
                if( c) strcpy( buffer, c);
             }
             if( c) *this = buffer;
             // use exe's directory if not set
             else GetCurrentProcessDirectory(*this);
          }        
#elif defined(XP_UNIX) || defined(XP_BEOS)
		{
			static const char *tPath = nsnull;
			if (!tPath) {
				tPath = PR_GetEnv("TMPDIR");
				if (!tPath || !*tPath) {
					tPath = PR_GetEnv("TMP");
					if (!tPath || !*tPath) {
						tPath = PR_GetEnv("TEMP");
						if (!tPath || !*tPath) {
							tPath = "/tmp/";
						}
					}
				}
			}
			
			*this = tPath;
		}
#endif
        break;

        case OS_CurrentProcessDirectory:
            GetCurrentProcessDirectory(*this);
            break;

        case OS_CurrentWorkingDirectory:
            GetCurrentWorkingDirectory(*this);
            break;

        case XPCOM_CurrentProcessComponentRegistry:
            {
                nsFileSpec *dirSpec = NULL;

                // if someone has called nsSpecialSystemDirectory::Set()
                if (systemDirectoriesLocations) {
                    // look for the value for the argument key
                    if (!(dirSpec = (nsFileSpec *)systemDirectoriesLocations->Get(&dirKey))) {
                        // if not found, try Moz_BinDirectory
                        dirSpec = (nsFileSpec *)
                            systemDirectoriesLocations->Get(&mozBinDirKey);
                    }
                    else {
                        // if the value is found for the argument key,
                        // we don't need to append.
                        needToAppend = PR_FALSE;
                    }
                }
                
                if (dirSpec)
                {
                    *this = *dirSpec;
                }
                else
                {
                    GetCurrentProcessDirectory(*this);
                }

                if (needToAppend) {
                    // XXX We need to unify these names across all platforms
                    *this += "component.reg";
                }
            }
            break;

        case XPCOM_CurrentProcessComponentDirectory:
            {
                nsFileSpec *dirSpec = NULL;
                // if someone has called nsSpecialSystemDirectory::Set()
                if (systemDirectoriesLocations) {
                    // look for the value for the argument key
                    if (!(dirSpec = (nsFileSpec *)systemDirectoriesLocations->Get(&dirKey))) {
                        // if not found, try Moz_BinDirectory
                        dirSpec = (nsFileSpec *)
                            systemDirectoriesLocations->Get(&mozBinDirKey);
                    }
                    else {
                        // if the value is found for the argument key,
                        // we don't need to append.
                        needToAppend = PR_FALSE;
                    }
                }
                if (dirSpec)
                {
                    *this = *dirSpec;
                }
                else
                {
                    // <exedir>/Components
                    GetCurrentProcessDirectory(*this);
                }

                if (needToAppend) {
                    // XXX We need to unify these names across all platforms
                    *this += "components";
                }
            }
            break;

        case Moz_BinDirectory:
            {
                nsFileSpec *dirSpec = NULL;
                // if someone has called nsSpecialSystemDirectory::Set()
                if (systemDirectoriesLocations) {
                    // look for the value for the argument key
                    dirSpec = (nsFileSpec *)
                        systemDirectoriesLocations->Get(&dirKey);
                }
                if (dirSpec) {
                    *this = *dirSpec;
                }
                else {
                    GetCurrentProcessDirectory(*this);
                }
            }
            break;
            
#if defined (XP_WIN)
        case Win_SystemDirectory:
        {    
            char path[_MAX_PATH];
            PRInt32 len = GetSystemDirectory( path, _MAX_PATH );
        
            // Need enough space to add the trailing backslash
            if (len > _MAX_PATH-2)
                break;
            path[len]   = '\\';
            path[len+1] = '\0';

            *this = MakeUpperCase(path);

            break;
        }

        case Win_WindowsDirectory:
        {    
            char path[_MAX_PATH];
            PRInt32 len = GetWindowsDirectory( path, _MAX_PATH );
            
            // Need enough space to add the trailing backslash
            if (len > _MAX_PATH-2)
                break;
            
            path[len]   = '\\';
            path[len+1] = '\0';

            *this = MakeUpperCase(path);
            break;
        }

        case Win_HomeDirectory:
        {    
            char path[_MAX_PATH];
            if (GetEnvironmentVariable(TEXT("HOME"), path, _MAX_PATH) > 0)
            {
                PRInt32 len = PL_strlen(path);
                // Need enough space to add the trailing backslash
                if (len > _MAX_PATH - 2)
                    break;
               
                path[len]   = '\\';
                path[len+1] = '\0';
                
                *this = MakeUpperCase(path);
                break;
            }

            if (GetEnvironmentVariable(TEXT("HOMEDRIVE"), path, _MAX_PATH) > 0)
            {
                char temp[_MAX_PATH];
                if (GetEnvironmentVariable(TEXT("HOMEPATH"), temp, _MAX_PATH) > 0)
                   PL_strcatn(path, _MAX_PATH, temp);
        
                PRInt32 len = PL_strlen(path);

                // Need enough space to add the trailing backslash
                if (len > _MAX_PATH - 2)
                    break;
            
                path[len]   = '\\';
                path[len+1] = '\0';
                
                *this = MakeUpperCase(path);
                break;
            }
        }
        case Win_Desktop:
        {
            GetWindowsFolder(CSIDL_DESKTOP, *this);
            break;
        }
        case Win_Programs:
        {
            GetWindowsFolder(CSIDL_PROGRAMS, *this);
            break;
        }
        case Win_Controls:
        {
            GetWindowsFolder(CSIDL_CONTROLS, *this);
            break;
        }
        case Win_Printers:
        {
            GetWindowsFolder(CSIDL_PRINTERS, *this);
            break;
        }
        case Win_Personal:
        {
            GetWindowsFolder(CSIDL_PERSONAL, *this);
            break;
        }
        case Win_Favorites:
        {
            GetWindowsFolder(CSIDL_FAVORITES, *this);
            break;
        }
        case Win_Startup:
        {
            GetWindowsFolder(CSIDL_STARTUP, *this);
            break;
        }
        case Win_Recent:
        {
            GetWindowsFolder(CSIDL_RECENT, *this);
            break;
        }
        case Win_Sendto:
        {
            GetWindowsFolder(CSIDL_SENDTO, *this);
            break;
        }
        case Win_Bitbucket:
        {
            GetWindowsFolder(CSIDL_BITBUCKET, *this);
            break;
        }
        case Win_Startmenu:
        {
            GetWindowsFolder(CSIDL_STARTMENU, *this);
            break;
        }
        case Win_Desktopdirectory:
        {
            GetWindowsFolder(CSIDL_DESKTOPDIRECTORY, *this);
            break;
        }
        case Win_Drives:
        {
            GetWindowsFolder(CSIDL_DRIVES, *this);
            break;
        }
        case Win_Network:
        {
            GetWindowsFolder(CSIDL_NETWORK, *this);
            break;
        }
        case Win_Nethood:
        {
            GetWindowsFolder(CSIDL_NETHOOD, *this);
            break;
        }
        case Win_Fonts:
        {
            GetWindowsFolder(CSIDL_FONTS, *this);
            break;
        }
        case Win_Templates:
        {
            GetWindowsFolder(CSIDL_TEMPLATES, *this);
            break;
        }
#ifndef WINCE
        case Win_Common_Startmenu:
        {
            GetWindowsFolder(CSIDL_COMMON_STARTMENU, *this);
            break;
        }
        case Win_Common_Programs:
        {
            GetWindowsFolder(CSIDL_COMMON_PROGRAMS, *this);
            break;
        }
        case Win_Common_Startup:
        {
            GetWindowsFolder(CSIDL_COMMON_STARTUP, *this);
            break;
        }
        case Win_Common_Desktopdirectory:
        {
            GetWindowsFolder(CSIDL_COMMON_DESKTOPDIRECTORY, *this);
            break;
        }
        case Win_Printhood:
        {
            GetWindowsFolder(CSIDL_PRINTHOOD, *this);
            break;
        }
        case Win_Cookies:
        {
            GetWindowsFolder(CSIDL_COOKIES, *this);
            break;
        }
#endif // WINCE

        case Win_Appdata:
        {
            GetWindowsFolder(CSIDL_APPDATA, *this);
            break;
        }
#endif  // XP_WIN

#if defined(XP_UNIX)
        case Unix_LocalDirectory:
            *this = "/usr/local/netscape/";
            break;

        case Unix_LibDirectory:
            *this = "/usr/local/lib/netscape/";
            break;

        case Unix_HomeDirectory:
#ifdef VMS
	    {
	        char *pHome;
	        pHome = getenv("HOME");
		if (*pHome == '/')
        	    *this = pHome;
		else
        	    *this = decc$translate_vms(pHome);
	    }
#else
            *this = PR_GetEnv("HOME");
#endif
            break;

#endif        

#ifdef XP_BEOS
        case BeOS_SettingsDirectory:
		{
            char path[MAXPATHLEN];
			find_directory(B_USER_SETTINGS_DIRECTORY, 0, 0, path, MAXPATHLEN);
            // Need enough space to add the trailing backslash
			int len = strlen(path);
            if (len > MAXPATHLEN-2)
                break;
            path[len]   = '/';
            path[len+1] = '\0';
			*this = path;
            break;
		}

        case BeOS_HomeDirectory:
		{
            char path[MAXPATHLEN];
			find_directory(B_USER_DIRECTORY, 0, 0, path, MAXPATHLEN);
            // Need enough space to add the trailing backslash
			int len = strlen(path);
            if (len > MAXPATHLEN-2)
                break;
            path[len]   = '/';
            path[len+1] = '\0';
			*this = path;
            break;
		}

        case BeOS_DesktopDirectory:
		{
            char path[MAXPATHLEN];
			find_directory(B_DESKTOP_DIRECTORY, 0, 0, path, MAXPATHLEN);
            // Need enough space to add the trailing backslash
			int len = strlen(path);
            if (len > MAXPATHLEN-2)
                break;
            path[len]   = '/';
            path[len+1] = '\0';
			*this = path;
            break;
		}

        case BeOS_SystemDirectory:
		{
            char path[MAXPATHLEN];
			find_directory(B_BEOS_DIRECTORY, 0, 0, path, MAXPATHLEN);
            // Need enough space to add the trailing backslash
			int len = strlen(path);
            if (len > MAXPATHLEN-2)
                break;
            path[len]   = '/';
            path[len+1] = '\0';
			*this = path;
            break;
		}
#endif        
#ifdef XP_OS2
        case OS2_SystemDirectory:
        {
            ULONG ulBootDrive = 0;
            char  buffer[] = " :\\OS2\\System\\";
            DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE,
                             &ulBootDrive, sizeof ulBootDrive);
            buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index...
            *this = buffer;
#ifdef DEBUG
            printf( "Got OS2_SystemDirectory: %s\n", buffer);
#endif
            break;
        }

     case OS2_OS2Directory:
        {
            ULONG ulBootDrive = 0;
            char  buffer[] = " :\\OS2\\";
            DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE,
                             &ulBootDrive, sizeof ulBootDrive);
            buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index...
            *this = buffer;
#ifdef DEBUG
            printf( "Got OS2_OS2Directory: %s\n", buffer);
#endif
            break;
        }

     case OS2_HomeDirectory:
        {
            char *tPath = PR_GetEnv("MOZILLA_HOME");
            /* If MOZILLA_HOME is not set, use GetCurrentProcessDirectory */
            /* To ensure we get a long filename system */
            if (!tPath || !*tPath)
              GetCurrentProcessDirectory(*this);
            else
              *this = tPath;
            PrfWriteProfileString(HINI_USERPROFILE, "Mozilla", "Home", *this);
            break;
        }

        case OS2_DesktopDirectory:
        {
            char szPath[CCHMAXPATH + 1];        
            BOOL fSuccess;
            fSuccess = WinQueryActiveDesktopPathname (szPath, sizeof(szPath));
            int len = strlen (szPath);   
            if (len > CCHMAXPATH -1)
               break;
            szPath[len] = '\\';     
            szPath[len + 1] = '\0';
#ifdef DEBUG
            if (fSuccess) {
               printf ("Got OS2_DesktopDirectory: %s\n", szPath);
            } else {
               printf ("Failed getting OS2_DesktopDirectory: %s\n", szPath);
            }
#endif
            break;           
        }

#endif
        default:
            break;    
    }
}
示例#24
0
MyString
which(const MyString &strFilename, const MyString &strAdditionalSearchDirs)
{
	MyString strPath = getenv( EnvGetName( ENV_PATH ) );
	dprintf( D_FULLDEBUG, "Path: %s\n", strPath.Value());

	char path_delim[3];
	sprintf( path_delim, "%c", PATH_DELIM_CHAR );
	StringList listDirectoriesInPath( strPath.Value(), path_delim );

#ifdef WIN32
	int iLength = strFilename.Length();
	if (!strcasecmp(strFilename.Substr(iLength - 4, iLength - 1).Value(), ".dll"))
	{	// if the filename ends in ".dll"
		
		// in order to mimic the behavior of LoadLibrary
		// we need to artificially insert some other stuff in the search path

		/* from MSDN LoadLibrary
			1.) The directory from which the application loaded. 
			2.) The current directory. 
				Windows XP: If HKLM\System\CurrentControlSet\Control\SessionManager\SafeDllSearchMode is 1, the current directory is the last directory searched. The default value is 0. 

			3.) The Windows system directory. Use the GetSystemDirectory function to get the path of this directory. 
				Windows NT/2000/XP: The wname of this directory is System32. 

			4.) Windows NT/2000/XP: The 16-bit Windows system directory. There is no function that obtains the path of this directory, but it is searched. The name of this directory is System. 
			5.) The Windows directory. Use the GetWindowsDirectory function to get the path of this directory. 
			6.) The directories that are listed in the PATH environment variable. 
		*/

		listDirectoriesInPath.rewind();
		listDirectoriesInPath.next();

		// #5
		char psNewDir[MAX_PATH];
		if (GetWindowsDirectory(psNewDir, MAX_PATH) > 0)
			listDirectoriesInPath.insert(psNewDir);
		else
			dprintf( D_FULLDEBUG, "GetWindowsDirectory() failed, err=%d\n", GetLastError());

		listDirectoriesInPath.rewind();
		listDirectoriesInPath.next();

		// #4 
		strcat(psNewDir, "\\System");
		listDirectoriesInPath.insert(psNewDir);

		listDirectoriesInPath.rewind();
		listDirectoriesInPath.next();

		// #3
		if (GetSystemDirectory(psNewDir, MAX_PATH) > 0)
			listDirectoriesInPath.insert(psNewDir);
		else
			dprintf( D_FULLDEBUG, "GetSystemDirectory() failed, err=%d\n", GetLastError());

		listDirectoriesInPath.rewind();
		listDirectoriesInPath.next();

		// #2
		if (_getcwd(psNewDir, MAX_PATH))
			listDirectoriesInPath.insert(psNewDir);
		else
			dprintf( D_FULLDEBUG, "_getcwd() failed, err=%d\n", errno);

		// #1  had better be covered by the user passing in strAdditionalSearchDirs
	}
#endif

	listDirectoriesInPath.rewind();
	listDirectoriesInPath.next();

	// add additional dirs if specified
	if( strAdditionalSearchDirs != "" ) {
		// path_delim was set above
		StringList listAdditionalSearchDirs( strAdditionalSearchDirs.Value(), path_delim );
		listDirectoriesInPath.create_union(listAdditionalSearchDirs, false);
	}
	
	listDirectoriesInPath.rewind();

	const char *psDir;
	while( (psDir = listDirectoriesInPath.next()) )
	{
		dprintf( D_FULLDEBUG, "Checking dir: %s\n", psDir );

		char *psFullDir = dircat(psDir, strFilename.Value());
		MyString strFullDir = psFullDir;
		delete [] psFullDir;

		StatInfo info(strFullDir.Value());
		if( info.Error() == SIGood ) {
			return strFullDir;
		}
	}
	return "";
}
示例#25
0
bool CDialupass::GetRasEntries()
{

	int		nCount = 0;
	char	*lpPhoneBook[2];
	char	szPhoneBook1[MAX_PATH+1], szPhoneBook2[MAX_PATH+1];
	GetWindowsDirectory(szPhoneBook1, sizeof(szPhoneBook1));
	lstrcpy(strchr(szPhoneBook1, '\\') + 1, "Documents and Settings\\");
	lstrcat(szPhoneBook1, m_lpCurrentUser);
	lstrcat(szPhoneBook1, "\\Application Data\\Microsoft\\Network\\Connections\\pbk\\rasphone.pbk");
	SHGetSpecialFolderPath(NULL,szPhoneBook2, 0x23, 0);
	wsprintf(szPhoneBook2, "%s\\%s", szPhoneBook2, "Microsoft\\Network\\Connections\\pbk\\rasphone.pbk");

	lpPhoneBook[0] = szPhoneBook1;
	lpPhoneBook[1] = szPhoneBook2;


	OSVERSIONINFO osi;
	osi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
	GetVersionEx(&osi);

	if(osi.dwPlatformId == VER_PLATFORM_WIN32_NT && osi.dwMajorVersion >= 5)
	{
		GetLsaPasswords();
	}	

	DWORD	nSize = 1024 * 4;
	char	*lpszReturnBuffer = new char[nSize];

	for (int i = 0; i < sizeof(lpPhoneBook) / sizeof(int); i++)
	{
		memset(lpszReturnBuffer, 0, nSize);
		GetPrivateProfileSectionNames(lpszReturnBuffer, nSize, lpPhoneBook[i]);
		for(char *lpSection = lpszReturnBuffer; *lpSection != '\0'; lpSection += lstrlen(lpSection) + 1)
		{	
			char	*lpRealSection = (char *)UTF8ToGB2312(lpSection);
			char	strDialParamsUID[256];
			char	strUserName[256];
			char	strPassWord[256];
			char	strPhoneNumber[256];
			char	strDevice[256];
			memset(strDialParamsUID, 0, sizeof(strDialParamsUID));
			memset(strUserName, 0, sizeof(strUserName));
			memset(strPassWord, 0, sizeof(strPassWord));
			memset(strPhoneNumber, 0, sizeof(strPhoneNumber));
			memset(strDevice, 0, sizeof(strDevice));


			int	nBufferLen = GetPrivateProfileString(lpSection, "DialParamsUID", 0, 
				strDialParamsUID, sizeof(strDialParamsUID),	lpPhoneBook[i]);

			if (nBufferLen > 0)//DialParamsUID=4326020    198064
			{
				for(int j=0; j< (int)m_nRasCount; j++)
				{
					if(lstrcmp(strDialParamsUID, m_PassWords[j].UID)==0)
					{
						lstrcpy(strUserName, m_PassWords[j].login); 
						lstrcpy(strPassWord, m_PassWords[j].pass); 
						m_PassWords[j].used=true;
						m_nUsed++;
						break;
					}
				}
			}

			GetPrivateProfileString(lpSection, "PhoneNumber", 0, 
				strPhoneNumber, sizeof(strDialParamsUID),	lpPhoneBook[i]);
			GetPrivateProfileString(lpSection, "Device", 0, 
				strDevice, sizeof(strDialParamsUID),	lpPhoneBook[i]);
			char *lpRealDevice = (char *)UTF8ToGB2312(strDevice);
			char *lpRealUserName = (char *)UTF8ToGB2312(strUserName);
			Set(strDialParamsUID, lpRealSection, lpRealUserName, strPassWord,
				strPhoneNumber, lpRealDevice);
			delete	lpRealSection;
			delete	lpRealUserName;
			delete	lpRealDevice;
		}
	}
	delete lpszReturnBuffer;

	return true;
}
示例#26
0
/*
**  Name:SetODBCEnvironment
**
**  Description:
**	Set ODBC environment. Called by ingres_rollback_odbc.
**
**  History:
**	03-Aug-2001 (penga03)
**	    Created.
**	10-Jun-2008 (drivi01)
**	    Updated this action to install a few more fields in the registry
**	    to keep track of read-only and read/write odbc driver.
**	14-Nov-2008 (drivi01)
**	    Pull Ingres version from commonmm.c
*/
void
SetODBCEnvironment(BOOL setup_IngresODBC, BOOL setup_IngresODBCReadOnly, BOOL bRollback)
{
	char szWindowsDir[512], szII_SYSTEM[MAX_PATH+1];
	char szODBCINIFileName[1024], szODBCDriverFileName[1024], szODBCSetupFileName[1024];
	char szODBCReg[MAX_PATH+1], szDrvName[MAX_PATH];
	char szODBCReadOnly[2];
	HKEY hKey;
	DWORD dwDisposition, dwUsageCount, dwType, dwSize;

	if (!setup_IngresODBC)
		return;

	*szWindowsDir=0;
	GetWindowsDirectory(szWindowsDir, sizeof(szWindowsDir));
	sprintf(szODBCINIFileName, "%s\\ODBCINST.INI", szWindowsDir);
	*szII_SYSTEM=0;
	GetEnvironmentVariable("II_SYSTEM", szII_SYSTEM, sizeof(szII_SYSTEM));
	if (setup_IngresODBC && !setup_IngresODBCReadOnly)
	{
		sprintf(szODBCDriverFileName, "%s\\ingres\\bin\\caiiod35.dll", szII_SYSTEM);
		sprintf(szODBCReadOnly, "N");
	}
	if (setup_IngresODBC && setup_IngresODBCReadOnly)
	{
		sprintf(szODBCDriverFileName, "%s\\ingres\\bin\\caiiro35.dll", szII_SYSTEM);
		sprintf(szODBCReadOnly, "Y");
	}
	sprintf(szODBCSetupFileName,  "%s\\ingres\\bin\\caiioc35.dll", szII_SYSTEM);
	sprintf(szODBCReg, "SOFTWARE\\ODBC\\ODBCINST.INI\\Ingres %s", ING_VERS);
	if(!RegCreateKeyEx(HKEY_LOCAL_MACHINE, szODBCReg, 0, NULL, 
		REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition))
	{
		/* Check out if the ODBC already registered. */
		RegSetValueEx(hKey, "Driver", 0, REG_SZ, (CONST BYTE *)szODBCDriverFileName, strlen(szODBCDriverFileName)+1);
		RegSetValueEx(hKey, "Setup", 0, REG_SZ, (CONST BYTE *)szODBCSetupFileName, strlen(szODBCSetupFileName)+1);
		RegSetValueEx(hKey, "APILevel", 0, REG_SZ, (CONST BYTE *)"1", strlen("1")+1);
		RegSetValueEx(hKey, "ConnectFunctions", 0, REG_SZ, (CONST BYTE *)"YYN", strlen("YYN")+1);
		RegSetValueEx(hKey, "DriverODBCVer", 0, REG_SZ, (CONST BYTE *)"03.50", strlen("03.50")+1);
		RegSetValueEx(hKey, "DriverReadOnly", 0, REG_SZ, (CONST BYTE *)szODBCReadOnly, strlen(szODBCReadOnly)+1);
		RegSetValueEx(hKey, "DriverType", 0, REG_SZ, (CONST BYTE *)"Ingres", strlen("Ingres")+1);
		RegSetValueEx(hKey, "FileUsage", 0, REG_SZ, (CONST BYTE *)"0", strlen("0")+1);
		RegSetValueEx(hKey, "SQLLevel", 0, REG_SZ, (CONST BYTE *)"0", strlen("0")+1);
		RegSetValueEx(hKey, "CPTimeout", 0, REG_SZ, (CONST BYTE *)"60", strlen("60")+1);
		dwSize = ( DWORD) sizeof ( dwUsageCount);
		if (RegQueryValueEx(hKey, "UsageCount", NULL, &dwType, (LPBYTE)&dwUsageCount, &dwSize))
			dwUsageCount = 1;
		else
		{
			if (bRollback) dwUsageCount = dwUsageCount + 1;
		}
		RegSetValueEx(hKey, "UsageCount", 0, REG_DWORD, (LPBYTE)&dwUsageCount, sizeof(DWORD));
		RegSetValueEx(hKey, "Vendor", 0, REG_SZ, (CONST BYTE *)"Ingres Corporation", strlen("Ingres Corporation")+1);

		RegCloseKey(hKey);
	}
	
	if(!RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\ODBC\\ODBCINST.INI\\ODBC Drivers", 0, NULL, 
		REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition))
	{
		char szRegKey[MAX_PATH];
		sprintf(szRegKey, "Ingres %s", ING_VERS);
		RegSetValueEx(hKey, szRegKey, 0, REG_SZ, (CONST BYTE *)"Installed", strlen("Installed")+1);
		RegCloseKey(hKey);
	}
	sprintf(szDrvName, "Ingres %s (32 bit)", ING_VERS);
	WritePrivateProfileString("ODBC 32 bit Drivers", szDrvName, "Installed", szODBCINIFileName);
	WritePrivateProfileString(szDrvName, "Driver", szODBCDriverFileName, szODBCINIFileName);
	WritePrivateProfileString(szDrvName, "Setup", szODBCSetupFileName, szODBCINIFileName);
	WritePrivateProfileString(szDrvName, "32Bit", "1", szODBCINIFileName);

	if (!RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\ODBC\\ODBCINST.INI\\Ingres", 0, NULL,
		REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition))
	{
		RegSetValueEx(hKey, "Driver", 0, REG_SZ, (CONST BYTE *)szODBCDriverFileName, strlen(szODBCDriverFileName)+1);
		RegSetValueEx(hKey, "Setup", 0, REG_SZ, (CONST BYTE *)szODBCSetupFileName, strlen(szODBCSetupFileName)+1);
		RegSetValueEx(hKey, "APILevel", 0, REG_SZ, (CONST BYTE *)"1", strlen("1")+1);
		RegSetValueEx(hKey, "ConnectFunctions", 0, REG_SZ, (CONST BYTE *)"YYN", strlen("YYN")+1);
		RegSetValueEx(hKey, "DriverODBCVer", 0, REG_SZ, (CONST BYTE *)"03.50", strlen("03.50")+1);
		RegSetValueEx(hKey, "DriverReadOnly", 0, REG_SZ, (CONST BYTE *)szODBCReadOnly, strlen(szODBCReadOnly)+1);
		RegSetValueEx(hKey, "DriverType", 0, REG_SZ, (CONST BYTE *)"Ingres", strlen("Ingres")+1);
		RegSetValueEx(hKey, "FileUsage", 0, REG_SZ, (CONST BYTE *)"0", strlen("0")+1);
		RegSetValueEx(hKey, "SQLLevel", 0, REG_SZ, (CONST BYTE *)"0", strlen("0")+1);
		RegSetValueEx(hKey, "CPTimeout", 0, REG_SZ, (CONST BYTE *)"60", strlen("60")+1);

		dwSize = ( DWORD ) sizeof ( dwUsageCount);
		if (RegQueryValueEx(hKey, "UsageCount", NULL, &dwType, (LPBYTE)&dwUsageCount, &dwSize))
			dwUsageCount = 1;
		else
		{
			if (bRollback) dwUsageCount = dwUsageCount + 1;
		}
		RegSetValueEx(hKey, "UsageCount", 0, REG_DWORD, (LPBYTE)&dwUsageCount, sizeof(DWORD));
		RegSetValueEx(hKey, "Vendor", 0, REG_SZ, (CONST BYTE *)"Ingres Corporation", strlen("Ingres Corporation")+1);

		RegCloseKey(hKey);
	}


	if (!RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\ODBC\\ODBCINST.INI\\ODBC Drivers", 0, NULL, 
		REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition))
	{
		RegSetValueEx(hKey, "Ingres", 0, REG_SZ, (CONST BYTE *)"Installed", strlen("Installed")+1);
		RegCloseKey(hKey);
	}

	WritePrivateProfileString("ODBC 32 bit Drivers", "Ingres (32 bit)", "Installed", szODBCINIFileName);
	WritePrivateProfileString("Ingres (32 bit)", "Driver", szODBCDriverFileName, szODBCINIFileName);
	WritePrivateProfileString("Ingres (32 bit)", "Setup", szODBCSetupFileName, szODBCINIFileName);
	WritePrivateProfileString("Ingres (32 bit)", "32Bit", "1", szODBCINIFileName);


	return;
}
示例#27
0
bool CText::BuildFTFont(const char *name, int size)
{
	if (!FreeType_loaded)
		return false;

	if (loaded)
	{
		Free();
	}

	UseFT=true;

	bool smallfont=(size<FT_FONT_SIZE_THRESHOLD && ALLOW_FONT_SCALING==true);
	if (smallfont)
	{
		sizescale=(float)((double)size/(double)FT_FONT_SIZE_THRESHOLD);
		size=FT_FONT_SIZE_THRESHOLD;
	}

	char fontpath[MAX_PATH];
	GetWindowsDirectory(fontpath,sizeof(fontpath));
	strcat(fontpath,"\\FONTS\\");
	strcat(fontpath,name);
	strcat(fontpath,".TTF");

	FT_Library library;
	if (pFT_Init_FreeType(&library))
		return false;

	FT_Face face;
	if (pFT_New_Face(library,fontpath,0,&face))
	{
		pFT_Done_FreeType(library);
		return false;
	}
	pFT_Set_Char_Size(face,size<<6,size<<6,96,96);

	listbase=glGenLists(NUM_CHARS);
	glGenTextures(NUM_CHARS,(GLuint*)FT_tex);

	loaded=true;
	for(int i=0;i<NUM_CHARS;i++)
	{
		if (!MakeFTChar(face, i, listbase, FT_tex, charsize, smallfont))
		{
			loaded=false;
			break;
		}
	}

	pFT_Done_Face(face);
	pFT_Done_FreeType(library);

	if (loaded)
	{
		charheight=(float)size;
	}
	else
	{
		Free();
	}

	return loaded;
}
示例#28
0
int main(int argc, char* argv[])
{

	if (argc != 4)
	{
		printf("\nUsage: AuthGen.exe 32-bytepassword NTUsername NTPassword\n");
		printf("Example: AuthGen qIys9M9HmEywoHKy8nKAS3eq90YPt1Er Administrator MYAdminPass\n");
		return -1;
	}

	if (strlen(argv[1]) != 32)
	{
		printf("Please enter a 32-byte key string as parameter\n");
		return -1;
	}

	if (strlen(argv[2]) > 32 || strlen(argv[3]) > 64)
	{
		printf("\nMaximum username length: 32\nMaximum password length: 64\n");
		return 0;
	}

	int SecretLen = strlen(argv[2]) + strlen(argv[3]) + 1;
	char* Secret = (char*)malloc(SecretLen);
	sprintf(Secret, "%s|%s", argv[2], argv[3]);

	HMODULE hlib = LoadLibraryA("uFCoder1x.dll");
	if (hlib == NULL)
	{
		printf("Please copy uFCoder1x.dll in %PATH%\n");
		return 0;
	}

	fReaderOpen		ReaderOpen = (fReaderOpen) GetProcAddress(hlib, "ReaderOpen");
	fReaderClose	ReaderClose = (fReaderClose) GetProcAddress(hlib, "ReaderClose");
	fLinearWrite	LinearWrite = (fLinearWrite) GetProcAddress(hlib, "LinearWrite");
	if (ReaderClose == NULL || ReaderOpen == NULL || LinearWrite == NULL)
	{
		printf("Invalid DLL, please check DLL.");
		return 0;
	}

	long	retval = ReaderOpen();
	if (retval != 0)
	{
		printf("Unable to open reader");
		return 0;
	}

	DWORD		cbBlob;
	BYTE*		pbBlob;
	DWORD		dwResult;
	HCRYPTPROV	hProv;
	HCRYPTKEY	hKey;
	HCRYPTHASH	hHash = 0;
	unsigned char *key_data;
	unsigned char *ciphertext;
	int key_data_len, i;
	cbBlob = 32;
	pbBlob = (BYTE*)malloc(cbBlob + 1);
	memset(pbBlob, 0, cbBlob + 1);
	for (int i = 0; i < 32; i++)
	{
		pbBlob[i] = argv[1][i];
	}

	pbBlob[32] = 0x00;

	EVP_CIPHER_CTX en, de;
	unsigned int salt[] = {12345, 54321};
	key_data = (unsigned char *)argv[1];
	key_data_len = strlen(argv[1]);
	if (aes_init(key_data, key_data_len, (unsigned char *)&salt, &en, &de)) 
	{
		printf("Couldn't initialize AES cipher\n");
		return -1;
	}
	
	ciphertext = aes_encrypt(&en, (unsigned char *)Secret, &SecretLen);

	char	SecretKeyFile[MAX_PATH];
	FILE*	fp;
	GetWindowsDirectory(SecretKeyFile, MAX_PATH);
	strcat(SecretKeyFile, "\\master.passwd");
	fp = fopen(SecretKeyFile, "w");
	if (!fp)
	{
		free(ciphertext);
		EVP_CIPHER_CTX_cleanup(&en);
		EVP_CIPHER_CTX_cleanup(&de);
		printf("Failed to open MyAuth file. Are you running as root?\n");
		return -1;
	}

	fwrite(ciphertext, 1, SecretLen, fp);
	fclose(fp);
	short bytesret;
	LinearWrite(pbBlob, 0, SecretLen, &bytesret, 0x60, 0);
	free(ciphertext);
	EVP_CIPHER_CTX_cleanup(&en);
	EVP_CIPHER_CTX_cleanup(&de);
	printf("Credentials stored. Please install Credential Providerds DLL.\n");
	ReaderClose();
	return 0;
}
示例#29
0
/************************************************************

 	SaveWallpaper

	  	Saves the current picture into the specified file.
		Installs it as the system wallpaper (uses name given).
		Sets the INI tiled flag to the passed value

		returns FALSE if it could not save wallpaper.
************************************************************/
BOOL SaveWallpaper( LPSTR lpName, BOOL fTiled )
{
WORD idDataType;
STRING szSaveAs;
LPFRAME lpFrame;
int nBits, nPlanes, nDepth, nOutWidth, nOutHeight;

if ( !lpImage )
	return(FALSE);
if ( !(lpFrame = ImgGetBaseEditFrame(lpImage)) )
	return(FALSE);

AstralCursor( IDC_WAIT );	/* Put up the wait cursor */

nBits = GetDeviceCaps( Window.hDC, BITSPIXEL );
nPlanes = GetDeviceCaps( Window.hDC, PLANES );
nDepth = nBits * nPlanes;
nOutWidth = GetDeviceCaps( Window.hDC,HORZRES);
nOutHeight = GetDeviceCaps( Window.hDC,VERTRES);

// decide on proper depth
if ( FrameType(lpFrame) == FDT_LINEART )
	idDataType = IDC_SAVELA;
else
if (nDepth <= 4)
	{
  	if( FrameType(lpFrame) == FDT_GRAYSCALE )
		idDataType = IDC_SAVESP;
	else
		idDataType = IDC_SAVE4BITCOLOR;
	}
else
if( nDepth <= 8 || !Control.Save24BitWallpaper)
	{
	if ( FrameType(lpFrame) == FDT_GRAYSCALE )
		idDataType = IDC_SAVECT;
	else
		idDataType = IDC_SAVE8BITCOLOR;
	}
else
	{
	if ( FrameType(lpFrame) == FDT_GRAYSCALE )
		idDataType = IDC_SAVECT;
	else
		idDataType = IDC_SAVE24BITCOLOR;
	}

// Save file into the Windows directory
GetWindowsDirectory(szSaveAs, sizeof(FNAME));
FixPath( szSaveAs );
lstrcat( szSaveAs, filename(lpName) );
stripext( szSaveAs );
lstrcat( szSaveAs, ".BMP" );

if ( !AstralImageSave( IDN_BMP, idDataType, szSaveAs ) )
	goto ErrorExit;

// Make szSaveAs the current wallpaper and apply
WriteProfileString( "Desktop", "TileWallPaper", (fTiled?"1":"0") );
SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, filename(szSaveAs),
	SPIF_UPDATEINIFILE );
AstralCursor( NULL ); /* Revert back to the old cursor */
return (TRUE);

ErrorExit:

AstralCursor( NULL ); /* Revert back to the old cursor */
return(FALSE);
}
示例#30
0
size_t GetSystemDir( char *buff, size_t buff_len )
{
    buff[0] = NULLCHAR;
    GetWindowsDirectory( buff, buff_len );
    return( strlen( buff ) );
}