void VNDispatcher::initDataDir() { CString cstrDir; TCHAR cBuffer[260]; GetCurrentDirectory(MAX_PATH, cBuffer); CString cstrPath(cBuffer); if (FolderExist(cstrPath + _T("\\data"))) { cstrDir = cstrPath; } else { int nCount = cstrPath.ReverseFind(_T('\\')); cstrPath.Delete(nCount, cstrPath.GetLength() - nCount); if (FolderExist(cstrPath + _T("\\data"))) { cstrDir = cstrPath; } else { MyMessageBox_Error(_T("initDataDir")); return; } } cstrDir += _T("\\data\\"); m_strDataDirectory = cstrDir; }
/*++ Routine Name: CXPSArchive::CXPSArchive Routine Description: CXPSArchive class constructor Arguments: pReadStream - Pointer to the print read stream pWriteStream - Pointer to the print write stream Return Value: None Throws CXDException(HRESULT) on an error --*/ CXPSArchive::CXPSArchive( _In_ IPrintReadStream* pReadStream, _In_ IPrintWriteStream* pWriteStream ) : m_pWriteStream(pWriteStream), m_pPkArchive(NULL), m_hPkArch(NULL) { HRESULT hr = S_OK; // // Get the current directory to load the pk archive library // DWORD cchName = 0; TCHAR* szFileName = new(std::nothrow) TCHAR[MAX_PATH]; if (SUCCEEDED(hr = CHECK_POINTER(szFileName, E_OUTOFMEMORY))) { cchName = GetModuleFileName(g_hInstance, szFileName, MAX_PATH); if (cchName == 0) { hr = GetLastErrorAsHResult(); } } if (SUCCEEDED(hr) && cchName > 0) { // // Remove the filespec // PathRemoveFileSpec(szFileName); try { // // Append the PK archive DLL name // CStringXD cstrPath(szFileName); cstrPath += TEXT("\\pkarch.dll"); // // Try to load the PK archive DLL // m_hPkArch = LoadLibrary(cstrPath); } catch (CXDException& e) { hr = e; } } if (szFileName != NULL) { delete[] szFileName; szFileName = NULL; } if (SUCCEEDED(hr)) { // // Get DllGetClassObject from the PK archive and instantiate the PK archive handler // if (m_hPkArch != NULL) { GetClassObject pfnGetClassObject = reinterpret_cast<GetClassObject>(GetProcAddress(m_hPkArch, "DllGetClassObject")); if (SUCCEEDED(hr = CHECK_POINTER(pfnGetClassObject, E_NOINTERFACE)) && SUCCEEDED(hr = pfnGetClassObject(CLSID_PKArchiveHandler, IID_IPKArchive, reinterpret_cast<LPVOID*>(&m_pPkArchive)))) { hr = CHECK_POINTER(m_pPkArchive, E_NOINTERFACE); } } else { hr = E_NOINTERFACE; } } // // Initialise the IO streams // if (SUCCEEDED(hr) && SUCCEEDED(hr = CHECK_POINTER(pReadStream, E_POINTER)) && SUCCEEDED(hr = CHECK_POINTER(m_pWriteStream, E_POINTER)) && SUCCEEDED(hr = m_pPkArchive->SetReadStream(pReadStream)) && SUCCEEDED(hr = m_pPkArchive->SetWriteStream(m_pWriteStream))) { // // We can now process the read stream to create the file index // hr = m_pPkArchive->ProcessReadStream(); } if (FAILED(hr)) { throw CXDException(hr); } }