CStdString ImanageDetector::GetInstalledExecutablePath() { CStdString sIntallDir = GetInstallDirectory(); if(sIntallDir.IsEmpty()) return _T(""); CStdString sFile = sIntallDir + _T("\\Manage32.exe"); if (DoesFileExist(sFile)) return sFile; return sIntallDir + _T("\\portbl32.exe"); }
HRESULT CopyYontmaBinaryToInstallLocation() { HRESULT hr; DWORD rc; TCHAR szInstallDestinationDirectory[MAX_PATH]; TCHAR szInstallDestinationPath[MAX_PATH]; TCHAR szInstallerBinaryPath[MAX_PATH]; hr = GetInstallDirectory(szInstallDestinationDirectory, ARRAYSIZE(szInstallDestinationDirectory)); if(HB_FAILED(hr)) { goto cleanexit; } if(!CreateDirectory(szInstallDestinationDirectory, NULL)) { rc = GetLastError(); if(rc != ERROR_ALREADY_EXISTS) { hr = HRESULT_FROM_WIN32(rc); goto cleanexit; } } if(!GetModuleFileName(NULL, szInstallerBinaryPath, ARRAYSIZE(szInstallerBinaryPath))) { hr = HRESULT_FROM_WIN32(GetLastError()); goto cleanexit; } hr = GetInstallPath(szInstallDestinationPath, ARRAYSIZE(szInstallDestinationPath)); if(HB_FAILED(hr)) { goto cleanexit; } // // If the installing binary is already in the installed location, no need to copy. // if(_tcscmp(szInstallerBinaryPath, szInstallDestinationPath) == 0) { hr = S_OK; goto cleanexit; } if(!CopyFile(szInstallerBinaryPath, szInstallDestinationPath, FALSE)) { hr = HRESULT_FROM_WIN32(GetLastError()); goto cleanexit; } hr = S_OK; cleanexit: return hr; }
HRESULT GetInstallPath(__out TCHAR* pszInstallPath, __in size_t cchInstallPath) { HRESULT hr; TCHAR szModuleFilename[MAX_PATH]; PTSTR pszYontmaInstallFilename; TCHAR szInstallDirectory[MAX_PATH]; if(!GetModuleFileName(NULL, szModuleFilename, ARRAYSIZE(szModuleFilename))) { hr = HRESULT_FROM_WIN32(GetLastError()); goto cleanexit; } hr = GetPathFilename(szModuleFilename, &pszYontmaInstallFilename); if(HB_FAILED(hr)) { goto cleanexit; } hr = GetInstallDirectory(szInstallDirectory, ARRAYSIZE(szInstallDirectory)); if(HB_FAILED(hr)) { goto cleanexit; } hr = StringCchPrintf(pszInstallPath, cchInstallPath, TEXT("%s\\%s"), szInstallDirectory, pszYontmaInstallFilename); if(HB_FAILED(hr)) { goto cleanexit; } hr = S_OK; cleanexit: return hr; }