Example #1
0
/* 初始化全局变量 */
unsigned WINAPI init_global_env(void * pParam)
{
	BOOL diff = read_appint(L"General", L"Nocompatete") > 0;
	if ( read_appkey(L"General",L"PortableDataPath",appdata_path,sizeof(appdata_path)) )
	{ 
		/* 如果ini文件里的appdata设置路径为相对路径 */
		if (appdata_path[1] != L':')
		{
			PathToCombineW(appdata_path,VALUE_LEN);
		}
		/* 处理localdata变量 */
		if ( !read_appkey(L"Env",L"TmpDataPath",localdata_path,sizeof(appdata_path)) )
		{
			wcsncpy(localdata_path,appdata_path,VALUE_LEN);
		}
		/* 修正相对路径问题 */
		if (localdata_path[1] != L':')
		{
			PathToCombineW(localdata_path,VALUE_LEN);
		}
		/* 为appdata建立目录 */
		charTochar(appdata_path);
		wcsncat(appdata_path,L"\\AppData",VALUE_LEN);
		SHCreateDirectoryExW(NULL,appdata_path,NULL);
		/* 为localdata建立目录 */
		charTochar(localdata_path);
		wcsncat(localdata_path,L"\\LocalAppData\\Temp\\Fx",VALUE_LEN);
		SHCreateDirectoryExW(NULL,localdata_path,NULL);
		if ( diff )
		{
			WaitWriteFile(appdata_path);
		}
	}
	return (unsigned)diff;
}
Example #2
0
ULONG
MyMakeDirectory(
	__in PWCHAR FileName 
)
{
	ULONG verdict  = efVerdict_Default;

// 	BOOL res = CreateDirectoryW(
// 					FileName,
// 					NULL
// 				);
	
	int res = SHCreateDirectoryExW(
		NULL,
		FileName,
		NULL
		);


	if (res == ERROR_SUCCESS || res == ERROR_ALREADY_EXISTS || res ==ERROR_FILE_EXISTS )
	{
		verdict = efVerdict_Allow;
	}
	else
	{
		verdict = efVerdict_Deny;
	}
	
	//verdict = (res == ERROR_SUCCESS)? efVerdict_Allow : efVerdict_Deny ;

	return efVerdict_Allow;
}
Example #3
0
bool VT::ensure_path_exist( const std::wstring& path )
{
    std::wstring folder = path.substr(0, path.rfind(VT_SLASH));
    SHCreateDirectoryExW(NULL, folder.c_str(), NULL);

    return true;
}
Example #4
0
	void CreateParentDirectory(const string &filename)
	{
		wstring wfn = StringFormat::UTF82Wide(filename);

		wfn = dirname(wfn);

		// This function needs \\s not /s. So stupid!
		for(size_t i=0; i < wfn.size(); i++)
			if(wfn[i] == L'/')
				wfn[i] = L'\\';

		SHCreateDirectoryExW(NULL, wfn.c_str(), NULL);
	}
Example #5
0
static void create_target_directory(LPWSTR Target)
{
    WCHAR dir[MAX_PATH];
    int res;

    strcpyW(dir, Target);
    *PathFindFileNameW(dir) = 0; /* Truncate file name */
    if(!PathIsDirectoryW(dir))
    {
        res = SHCreateDirectoryExW(NULL, dir, NULL);
        if(res != ERROR_SUCCESS && res != ERROR_ALREADY_EXISTS)
            WINE_ERR("Can't create directory: %s\n", wine_dbgstr_w(dir));
    }
}
Example #6
0
BOOL WINAPI WaitWriteFile(LPCWSTR ap_path)
{
	BOOL  ret = FALSE;
	WCHAR profile_path[MAX_PATH+1] = {0};
	BOOL  pname = is_thunderbird();
	if (pname)
	{
		_snwprintf(profile_path,MAX_PATH,L"%ls%ls",ap_path,L"\\Thunderbird\\profiles.ini");
	}
	else
	{
		_snwprintf(profile_path,MAX_PATH,L"%ls%ls",ap_path,L"\\Mozilla\\Firefox\\profiles.ini");
	}
	if ( PathFileExistsW(profile_path) )
	{
		if (pname)
		{
			ret = WritePrivateProfileStringW(L"Profile0",L"Path",L"../../",profile_path);
		}
		else
		{
			ret = WritePrivateProfileStringW(L"Profile0",L"Path",L"../../../",profile_path);
		}
	}
	else
	{
		LPWSTR szDir;
		if ( (szDir = (LPWSTR)SYS_MALLOC( sizeof(profile_path) ) ) != NULL )
		{
			wcsncpy (szDir, profile_path, MAX_PATH);
			PathRemoveFileSpecW( szDir );
			SHCreateDirectoryExW(NULL,szDir,NULL);
			SYS_FREE(szDir);
			WritePrivateProfileSectionW(L"General",L"StartWithLastProfile=1\r\n\0",profile_path);
			if (pname)
			{
				ret = WritePrivateProfileSectionW(L"Profile0",L"Name=default\r\nIsRelative=1\r\nPath=../../\r\nDefault=1\r\n\0" \
												,profile_path);
			}
			else
			{
				ret = WritePrivateProfileSectionW(L"Profile0",L"Name=default\r\nIsRelative=1\r\nPath=../../../\r\nDefault=1\r\n\0" \
												,profile_path);
			}
		}
	}
	return ret;
}
Example #7
0
/*******************************************************************************
 * GAMEUX_createStatsDirectory
 *
 * Helper function, creates directory to store game statistics
 *
 * Parameters
 *  path                [I]     path to game statistics file.
 *                              base directory of this file will
 *                              be created if it doesn't exists
 */
static HRESULT GAMEUX_createStatsDirectory(LPCWSTR lpFilePath)
{
    HRESULT hr;
    WCHAR lpDirectoryPath[MAX_PATH];
    LPCWSTR lpEnd;

    lpEnd = StrRChrW(lpFilePath, NULL, '\\');
    lstrcpynW(lpDirectoryPath, lpFilePath, lpEnd-lpFilePath+1);

    hr = HRESULT_FROM_WIN32(SHCreateDirectoryExW(NULL, lpDirectoryPath, NULL));

    if(hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS) ||
       hr == HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS))
        hr = S_FALSE;

    return hr;
}
Example #8
0
ULONG
MyCopyFile(
	__in PWCHAR NewFileName,
	__in PWCHAR OldFileName
)
{
	ULONG verdict  = efVerdict_Default;
	ULONG i = 0;
	i = (ULONG)wcslen(NewFileName);
	
	while ( i > 0 )
	{
		if (NewFileName[i] == L'\\')
			break;
		
		i--;
	}
	
	if (i > 2 )
	{
		PWCHAR wcDirectoryPath;
		
		wcDirectoryPath = new WCHAR[i+1];
		memset(wcDirectoryPath, 0, (i+1)*sizeof(WCHAR) );
		memcpy( wcDirectoryPath, NewFileName, i*sizeof(WCHAR) );

		SHCreateDirectoryExW(
			NULL,
			wcDirectoryPath,
			NULL
			);
		
		delete [] wcDirectoryPath;
	}
	
	BOOL res = CopyFileW(
		OldFileName,
		NewFileName,
		FALSE
		);

	verdict = (res)?efVerdict_Allow : efVerdict_Deny ;


	return verdict;
}
Example #9
0
static bool create_dir(char const* path, int flags, int permissions, bool okay_if_exists, tr_error** error)
{
    TR_ASSERT(path != NULL);

    (void)permissions;

    bool ret;
    DWORD error_code = ERROR_SUCCESS;
    wchar_t* wide_path = path_to_native_path(path);

    if ((flags & TR_SYS_DIR_CREATE_PARENTS) != 0)
    {
        error_code = SHCreateDirectoryExW(NULL, wide_path, NULL);
        ret = error_code == ERROR_SUCCESS;
    }
    else
    {
        ret = CreateDirectoryW(wide_path, NULL);

        if (!ret)
        {
            error_code = GetLastError();
        }
    }

    if (!ret && error_code == ERROR_ALREADY_EXISTS && okay_if_exists)
    {
        DWORD const attributes = GetFileAttributesW(wide_path);

        if (attributes != INVALID_FILE_ATTRIBUTES &&
            (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
        {
            ret = true;
        }
    }

    if (!ret)
    {
        set_system_error(error, error_code);
    }

    tr_free(wide_path);

    return ret;
}
Example #10
0
void ExchndlSetup(const char *packageVersion)
{
# if defined(WZ_CC_MINGW)
	wchar_t miniDumpPath[PATH_MAX] = {'\0'};

#ifdef HAVE_BFD
	bfd_init();
#endif /* HAVE_BFD */

	// Install the unhandled exception filter function
	prevExceptionFilter = SetUnhandledExceptionFilter(TopLevelExceptionFilter);

	// Retrieve the current version
	formattedVersionString = strdup(packageVersion);

	// Because of UAC on vista / win7 we use this to write our dumps to (unless we override it via OverrideRPTDirectory())
	// NOTE: CSIDL_PERSONAL =  C:\Users\user name\Documents
	if ( SUCCEEDED( SHGetFolderPathW( NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, miniDumpPath ) ))
	{
		PathAppendW( miniDumpPath, WSTRING(WZ_WRITEDIR));
		PathAppendW( miniDumpPath, L"\\logs" );

		if( !PathFileExistsW( miniDumpPath ) )
		{
			if( ERROR_SUCCESS != SHCreateDirectoryExW( NULL, miniDumpPath, NULL ) )
			{
				wcscpy(miniDumpPath, L"c:\\temp");
			}
		}
	}
	else
	{	// should never fail, but if it does, we fall back to this
		wcscpy(miniDumpPath, L"c:\\temp");
	}

	wcscat(szLogFileName, L"Warzone2100.RPT");
	wcscat(miniDumpPath, L"\\");
	wcscat(miniDumpPath,szLogFileName);
	wcscpy(szLogFileName, miniDumpPath);

	atexit(ExchndlShutdown);
#endif
}
Example #11
0
	static std::string FindUserDir()
	{
		wchar_t appdata_path[MAX_PATH];
		if (SHGetFolderPathW(0, CSIDL_PERSONAL, 0, SHGFP_TYPE_CURRENT, appdata_path) != S_OK) {
			Output("Couldn't get user documents folder path\n");
			exit(-1);
		}

		std::wstring path(appdata_path);
		path += L"/Pioneersp";

		if (!PathFileExistsW(path.c_str())) {
			if (SHCreateDirectoryExW(0, path.c_str(), 0) != ERROR_SUCCESS) {
				std::string utf8path = transcode_utf16_to_utf8(path);
				Output("Couldn't create user game folder '%s'", utf8path.c_str());
				exit(-1);
			}
		}

		return transcode_utf16_to_utf8(path);
	}
Example #12
0
bool createDirPath(const std::string& path)
{
#ifdef WIN32
    //FIXME: Will work only on WinXP SP2 or newer.
    std::wstring wp = fromUTF8(directory(path).c_str());
    int result = SHCreateDirectoryExW(NULL, wp.c_str(), NULL);
    if ((result != ERROR_SUCCESS) && (result != ERROR_FILE_EXISTS) && (result != ERROR_ALREADY_EXISTS))
        return false;
#else
    int startPos = 0;
    int endPos = 0;
    while ((endPos = path.find(L'/', startPos)) != std::string::npos)
    {
        if (createDir(path.substr(0, endPos + 1).c_str(), 0777))
            return false;
        startPos = endPos + 1;
    }
    if (createDir(path.c_str(), 0777))
        return false;
#endif
    return true;
}
Example #13
0
/* return 0 on success.
 * return -1 if could not write file.
 * return -2 if download failed.
 */
static int install_tox(int create_desktop_shortcut, int create_startmenu_shortcut, int use_with_tox_url, wchar_t *install_path, int install_path_len) {

    char dir[MAX_PATH];

    wchar_t selfpath[MAX_PATH];
    GetModuleFileNameW(MY_HINSTANCE, selfpath, MAX_PATH);

    SHCreateDirectoryExW(NULL, install_path, NULL);
    SetCurrentDirectoryW(install_path);
    if (CopyFileW(selfpath, L""TOX_UPDATER_FILENAME, 0) == 0)
        return -1;

    int ret = write_uninstall();
    if (ret != 0)
        return ret;

    set_current_status("downloading and installing tox...");

    ret = download_and_install_new_utox_version();
    if (ret != 0)
        return ret;

    HRESULT hr;
    HKEY key;

    if (create_desktop_shortcut || create_startmenu_shortcut) {
        hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
        if(SUCCEEDED(hr)) {
            //start menu
            IShellLink* psl;

            // Get a pointer to the IShellLink interface. It is assumed that CoInitialize
            // has already been called.
            hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (LPVOID*)&psl);
            if (SUCCEEDED(hr)) {
                IPersistFile* ppf;

                // Set the path to the shortcut target and add the description.

                GetCurrentDirectory(MAX_PATH, dir);
                psl->lpVtbl->SetWorkingDirectory(psl, dir);
                strcat(dir, "\\"TOX_UPDATER_FILENAME);
                psl->lpVtbl->SetPath(psl, dir);
                psl->lpVtbl->SetDescription(psl, "Tox");

                // Query IShellLink for the IPersistFile interface, used for saving the
                // shortcut in persistent storage.
                hr = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, (LPVOID*)&ppf);

                if (SUCCEEDED(hr)) {
                    wchar_t wsz[MAX_PATH + 64];
                    if (create_startmenu_shortcut) {
                        hr = SHGetFolderPathW(NULL, CSIDL_STARTMENU, NULL, 0, wsz);
                        if (SUCCEEDED(hr)) {
                            LOG_TO_FILE("%ls\n", wsz);
                            wcscat(wsz, L"\\Programs\\Tox.lnk");
                            hr = ppf->lpVtbl->Save(ppf, wsz, TRUE);
                        }
                    }

                    if (create_desktop_shortcut) {
                        hr = SHGetFolderPathW(NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0, wsz);
                        if (SUCCEEDED(hr)) {
                            wcscat(wsz, L"\\Tox.lnk");
                            hr = ppf->lpVtbl->Save(ppf, wsz, TRUE);
                        }
                    }

                    ppf->lpVtbl->Release(ppf);
                }
                psl->lpVtbl->Release(psl);
            }
        }
    }

    if (use_with_tox_url) {
        GetCurrentDirectory(MAX_PATH, dir);
        strcat(dir, "\\" TOX_EXE_NAME);

        char str[MAX_PATH];

        if (RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\tox", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL) == ERROR_SUCCESS) {
            LOG_TO_FILE("nice\n");
            RegSetValueEx(key, NULL, 0, REG_SZ, (BYTE*)"URL:Tox Protocol", sizeof("URL:Tox Protocol"));
            RegSetValueEx(key, "URL Protocol", 0, REG_SZ, (BYTE*)"", sizeof(""));

            HKEY key2;
            if (RegCreateKeyEx(key, "DefaultIcon", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key2, NULL) == ERROR_SUCCESS) {
                int i = sprintf(str, "%s,101", dir) + 1;
                RegSetValueEx(key2, NULL, 0, REG_SZ, (BYTE*)str, i);
            }

            if (RegCreateKeyEx(key, "shell", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key2, NULL) == ERROR_SUCCESS) {
                if (RegCreateKeyEx(key2, "open", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL) == ERROR_SUCCESS) {
                    if (RegCreateKeyEx(key, "command", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key2, NULL) == ERROR_SUCCESS) {
                        int i = sprintf(str, "%s %%1", dir) + 1;
                        RegSetValueEx(key2, NULL, 0, REG_SZ, (BYTE*)str, i);
                    }
                }
            }
        }
    }

    if (RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\uTox", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL) == ERROR_SUCCESS) {
            wchar_t icon[install_path_len + 64];
            wchar_t uninstall[install_path_len + 64];
            memcpy(icon, install_path, install_path_len * 2);
            icon[install_path_len] = 0;
            uninstall[0] = 0;
            wcscat(uninstall, L"cmd /C start \"\" /MIN \"");

            wcscat(icon, L"\\uTox.exe");
            wcscat(uninstall, install_path);
            wcscat(uninstall, L"\\uninstall.bat\"");
    
            RegSetValueEx(key, NULL, 0, REG_SZ, (BYTE*)"", sizeof(""));
            RegSetValueEx(key, "DisplayName", 0, REG_SZ, (BYTE*)"uTox", sizeof("uTox"));
            RegSetValueExW(key, L"InstallLocation", 0, REG_SZ, (BYTE*)install_path, wcslen(install_path) * 2);
            RegSetValueExW(key, L"DisplayIcon", 0, REG_SZ, (BYTE*)icon, wcslen(icon) * 2);
            RegSetValueExW(key, L"UninstallString", 0, REG_SZ, (BYTE*)uninstall, wcslen(uninstall) * 2);
    }
    return 0;
}
Example #14
0
static void on_theme_install(HWND dialog)
{
  static const WCHAR filterMask[] = {0,'*','.','m','s','s','t','y','l','e','s',';',
      '*','.','t','h','e','m','e',0,0};
  static const WCHAR themeExt[] = {'.','T','h','e','m','e',0};
  const int filterMaskLen = sizeof(filterMask)/sizeof(filterMask[0]);
  OPENFILENAMEW ofn;
  WCHAR filetitle[MAX_PATH];
  WCHAR file[MAX_PATH];
  WCHAR filter[100];
  WCHAR title[100];

  LoadStringW (GetModuleHandleW(NULL), IDS_THEMEFILE,
      filter, sizeof (filter) / sizeof (filter[0]) - filterMaskLen);
  memcpy (filter + lstrlenW (filter), filterMask, 
      filterMaskLen * sizeof (WCHAR));
  LoadStringW (GetModuleHandleW(NULL), IDS_THEMEFILE_SELECT,
      title, sizeof (title) / sizeof (title[0]));

  ofn.lStructSize = sizeof(OPENFILENAMEW);
  ofn.hwndOwner = dialog;
  ofn.hInstance = 0;
  ofn.lpstrFilter = filter;
  ofn.lpstrCustomFilter = NULL;
  ofn.nMaxCustFilter = 0;
  ofn.nFilterIndex = 0;
  ofn.lpstrFile = file;
  ofn.lpstrFile[0] = '\0';
  ofn.nMaxFile = sizeof(file)/sizeof(filetitle[0]);
  ofn.lpstrFileTitle = filetitle;
  ofn.lpstrFileTitle[0] = '\0';
  ofn.nMaxFileTitle = sizeof(filetitle)/sizeof(filetitle[0]);
  ofn.lpstrInitialDir = NULL;
  ofn.lpstrTitle = title;
  ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLESIZING;
  ofn.nFileOffset = 0;
  ofn.nFileExtension = 0;
  ofn.lpstrDefExt = NULL;
  ofn.lCustData = 0;
  ofn.lpfnHook = NULL;
  ofn.lpTemplateName = NULL;

  if (GetOpenFileNameW(&ofn))
  {
      static const WCHAR themesSubdir[] = { '\\','T','h','e','m','e','s',0 };
      static const WCHAR backslash[] = { '\\',0 };
      WCHAR themeFilePath[MAX_PATH];
      SHFILEOPSTRUCTW shfop;

      if (FAILED (SHGetFolderPathW (NULL, CSIDL_RESOURCES|CSIDL_FLAG_CREATE, NULL, 
          SHGFP_TYPE_CURRENT, themeFilePath))) return;

      if (lstrcmpiW(PathFindExtensionW(filetitle), themeExt)==0)
      {
          do_parse_theme(file);
          SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0);
          return;
      }

      PathRemoveExtensionW (filetitle);

      /* Construct path into which the theme file goes */
      lstrcatW (themeFilePath, themesSubdir);
      lstrcatW (themeFilePath, backslash);
      lstrcatW (themeFilePath, filetitle);

      /* Create the directory */
      SHCreateDirectoryExW (dialog, themeFilePath, NULL);

      /* Append theme file name itself */
      lstrcatW (themeFilePath, backslash);
      lstrcatW (themeFilePath, PathFindFileNameW (file));
      /* SHFileOperation() takes lists as input, so double-nullterminate */
      themeFilePath[lstrlenW (themeFilePath)+1] = 0;
      file[lstrlenW (file)+1] = 0;

      /* Do the copying */
      WINE_TRACE("copying: %s -> %s\n", wine_dbgstr_w (file), 
          wine_dbgstr_w (themeFilePath));
      shfop.hwnd = dialog;
      shfop.wFunc = FO_COPY;
      shfop.pFrom = file;
      shfop.pTo = themeFilePath;
      shfop.fFlags = FOF_NOCONFIRMMKDIR;
      if (SHFileOperationW (&shfop) == 0)
      {
          scan_theme_files();
          if (!fill_theme_list (GetDlgItem (dialog, IDC_THEME_THEMECOMBO),
              GetDlgItem (dialog, IDC_THEME_COLORCOMBO),
              GetDlgItem (dialog, IDC_THEME_SIZECOMBO)))
          {
              SendMessageW (GetDlgItem (dialog, IDC_THEME_COLORCOMBO), CB_SETCURSEL, -1, 0);
              SendMessageW (GetDlgItem (dialog, IDC_THEME_SIZECOMBO), CB_SETCURSEL, -1, 0);
              enable_size_and_color_controls (dialog, FALSE);
          }
          else
          {
              enable_size_and_color_controls (dialog, TRUE);
          }
      }
      else
          WINE_TRACE("copy operation failed\n");
  }
  else WINE_TRACE("user cancelled\n");
}
Example #15
0
void ExchndlSetup(const char *packageVersion)
{
# if defined(WZ_CC_MINGW)
	wchar_t miniDumpPath[PATH_MAX] = {'\0'};
	DWORD dwRetVal = 0;
#ifdef HAVE_BFD
	bfd_init();
#endif /* HAVE_BFD */

	// Install the unhandled exception filter function
	prevExceptionFilter = SetUnhandledExceptionFilter(TopLevelExceptionFilter);

	// Retrieve the current version
	formattedVersionString = strdup(packageVersion);
#ifndef WZ_PORTABLE
	// Because of UAC on vista / win7 we use this to write our dumps to (unless we override it via OverrideRPTDirectory())
	// NOTE: CSIDL_PERSONAL =  C:\Users\user name\Documents
	if ( SUCCEEDED( SHGetFolderPathW( NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, miniDumpPath ) ))
	{
		PathAppendW( miniDumpPath, WSTRING(WZ_WRITEDIR));
		PathAppendW( miniDumpPath, L"\\logs" );

		if( !PathFileExistsW( miniDumpPath ) )
		{
			if( ERROR_SUCCESS != SHCreateDirectoryExW( NULL, miniDumpPath, NULL ) )
			{
				//last attempt to get a path
				dwRetVal = GetTempPathW(PATH_MAX, miniDumpPath);
				if (dwRetVal > MAX_PATH || (dwRetVal == 0))
				{
					MessageBox((HWND)MB_ICONEXCLAMATION, "Could not created a temporary directory!\nProgram will now exit." , _T("Error"), MB_OK);
					exit(1);
				}
			}
		}
	}
#else
	// we use where they installed it on, since this is a removeable drive (most likely), we will use where the program is located in.
	if (dwRetVal = GetCurrentDirectoryW(MAX_PATH, miniDumpPath))
	{
		if(dwRetVal > MAX_PATH)
		{
			MessageBox((HWND)MB_ICONEXCLAMATION, "Buffer exceeds maximum path to create directory.  Exiting.", _T("Error"), MB_OK);
			exit(1);
		}
		PathAppendW( miniDumpPath, WSTRING(WZ_WRITEDIR));
		PathAppendW( miniDumpPath, L"\\logs" );
	}
#endif
	else
	{	// should never fail, but if it does, we fall back to this
		dwRetVal = GetTempPathW(PATH_MAX, miniDumpPath);
		if (dwRetVal > MAX_PATH || (dwRetVal == 0))
		{
			MessageBox((HWND)MB_ICONEXCLAMATION, "Could not created a temporary directory!\nProgram will now exit." , _T("Error!"), MB_OK);
			exit(1);
		}
	}

	wcscat(szLogFileName, L"Warzone2100.RPT");
	wcscat(miniDumpPath, L"\\");
	wcscat(miniDumpPath,szLogFileName);
	wcscpy(szLogFileName, miniDumpPath);

	atexit(ExchndlShutdown);
#endif
}