1*32b1fd08SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*32b1fd08SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*32b1fd08SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*32b1fd08SAndrew Rist * distributed with this work for additional information 6*32b1fd08SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*32b1fd08SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*32b1fd08SAndrew Rist * "License"); you may not use this file except in compliance 9*32b1fd08SAndrew Rist * with the License. You may obtain a copy of the License at 10*32b1fd08SAndrew Rist * 11*32b1fd08SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*32b1fd08SAndrew Rist * 13*32b1fd08SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*32b1fd08SAndrew Rist * software distributed under the License is distributed on an 15*32b1fd08SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*32b1fd08SAndrew Rist * KIND, either express or implied. See the License for the 17*32b1fd08SAndrew Rist * specific language governing permissions and limitations 18*32b1fd08SAndrew Rist * under the License. 19*32b1fd08SAndrew Rist * 20*32b1fd08SAndrew Rist *************************************************************/ 21*32b1fd08SAndrew Rist 22*32b1fd08SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #undef UNICODE 25cdf0e10cSrcweir #undef _UNICODE 26cdf0e10cSrcweir 27cdf0e10cSrcweir #define _WIN32_WINDOWS 0x0410 28cdf0e10cSrcweir 29cdf0e10cSrcweir #ifdef _MSC_VER 30cdf0e10cSrcweir #pragma warning(push, 1) /* disable warnings within system headers */ 31cdf0e10cSrcweir #define WIN32_LEAN_AND_MEAN 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #include <windows.h> 34cdf0e10cSrcweir #include <msiquery.h> 35cdf0e10cSrcweir #include <shellapi.h> 36cdf0e10cSrcweir #ifdef _MSC_VER 37cdf0e10cSrcweir #pragma warning(pop) 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <malloc.h> 41cdf0e10cSrcweir #include <assert.h> 42cdf0e10cSrcweir #include <string.h> 43cdf0e10cSrcweir 44cdf0e10cSrcweir #ifdef UNICODE 45cdf0e10cSrcweir #define _UNICODE 46cdf0e10cSrcweir #define _tstring wstring 47cdf0e10cSrcweir #else 48cdf0e10cSrcweir #define _tstring string 49cdf0e10cSrcweir #endif 50cdf0e10cSrcweir #include <tchar.h> 51cdf0e10cSrcweir #include <string> 52cdf0e10cSrcweir 53cdf0e10cSrcweir /** creates a temporary folder with a unique name. 54cdf0e10cSrcweir 55cdf0e10cSrcweir The returned string is a file URL. 56cdf0e10cSrcweir */ 57cdf0e10cSrcweir // static std::_tstring createTempFolder() 58cdf0e10cSrcweir // { 59cdf0e10cSrcweir // BOOL bExist = FALSE; 60cdf0e10cSrcweir // TCHAR szTempName[MAX_PATH]; 61cdf0e10cSrcweir // do 62cdf0e10cSrcweir // { 63cdf0e10cSrcweir // bExist = FALSE; 64cdf0e10cSrcweir // // Get the temp path. 65cdf0e10cSrcweir // TCHAR lpPathBuffer[MAX_PATH]; 66cdf0e10cSrcweir // DWORD dwRetVal = GetTempPath(MAX_PATH, lpPathBuffer); 67cdf0e10cSrcweir // if (dwRetVal > MAX_PATH || (dwRetVal == 0)) 68cdf0e10cSrcweir // { 69cdf0e10cSrcweir // //fprintf (stderr, "GetTempPath failed with error %d.\n", GetLastError()); 70cdf0e10cSrcweir // return TEXT(""); 71cdf0e10cSrcweir // } 72cdf0e10cSrcweir // // Create a temporary file. 73cdf0e10cSrcweir // UINT uRetVal = GetTempFileName(lpPathBuffer, // directory for tmp files 74cdf0e10cSrcweir // "upg", // temp file name prefix 75cdf0e10cSrcweir // 0, // create unique name 76cdf0e10cSrcweir // szTempName); // buffer for name 77cdf0e10cSrcweir // if (uRetVal == 0) 78cdf0e10cSrcweir // { 79cdf0e10cSrcweir // //fprintf (stderr, "GetTempFileName failed with error %d.\n", GetLastError()); 80cdf0e10cSrcweir // return TEXT(""); 81cdf0e10cSrcweir // } 82cdf0e10cSrcweir // //Delete the file 83cdf0e10cSrcweir // BOOL bDel = DeleteFile(szTempName); 84cdf0e10cSrcweir // if (FALSE == bDel) 85cdf0e10cSrcweir // { 86cdf0e10cSrcweir // //fprintf(stderr, "Could not delete temp file. Error %d.\n", GetLastError()); 87cdf0e10cSrcweir // return TEXT(""); 88cdf0e10cSrcweir // } 89cdf0e10cSrcweir // // Create the directory 90cdf0e10cSrcweir // BOOL bDir = CreateDirectory(szTempName, NULL); 91cdf0e10cSrcweir // if (FALSE == bDir) 92cdf0e10cSrcweir // { 93cdf0e10cSrcweir // DWORD error =GetLastError(); 94cdf0e10cSrcweir // if (ERROR_ALREADY_EXISTS == error) 95cdf0e10cSrcweir // { 96cdf0e10cSrcweir // bExist = TRUE; 97cdf0e10cSrcweir // } 98cdf0e10cSrcweir // else 99cdf0e10cSrcweir // { 100cdf0e10cSrcweir // //fprintf(stderr, "CreateDirectory failed with error %d.\n", error); 101cdf0e10cSrcweir // return TEXT(""); 102cdf0e10cSrcweir // } 103cdf0e10cSrcweir // } 104cdf0e10cSrcweir // } while(bExist); 105cdf0e10cSrcweir 106cdf0e10cSrcweir // std::_tstring cur(szTempName); 107cdf0e10cSrcweir // //make a file URL from the path 108cdf0e10cSrcweir // std::_tstring ret(TEXT("file:///")); 109cdf0e10cSrcweir // for (std::_tstring::iterator i = cur.begin(); i != cur.end(); i++) 110cdf0e10cSrcweir // { 111cdf0e10cSrcweir // if (*i == '\\') 112cdf0e10cSrcweir // ret.append(TEXT("/")); 113cdf0e10cSrcweir // else 114cdf0e10cSrcweir // ret.push_back(*i); 115cdf0e10cSrcweir // } 116cdf0e10cSrcweir // // MessageBox(NULL, ret.c_str(), "createTempFolder", MB_OK); 117cdf0e10cSrcweir // return ret.c_str(); 118cdf0e10cSrcweir // } 119cdf0e10cSrcweir 120cdf0e10cSrcweir /** deletes the temporary folder. 121cdf0e10cSrcweir The argument must be a file URL. 122cdf0e10cSrcweir */ 123cdf0e10cSrcweir // static void deleteTempFolder(const std::_tstring& sTempFolder) 124cdf0e10cSrcweir // { 125cdf0e10cSrcweir // if (sTempFolder.size() == 0) 126cdf0e10cSrcweir // return; 127cdf0e10cSrcweir // //convert the file URL to a path 128cdf0e10cSrcweir // const std::_tstring path(sTempFolder.substr(8)); 129cdf0e10cSrcweir // std::_tstring path2; 130cdf0e10cSrcweir // // MessageBox(NULL, path.c_str(), "del1", MB_OK); 131cdf0e10cSrcweir // for (std::_tstring::const_iterator i = path.begin(); i != path.end(); i++) 132cdf0e10cSrcweir // { 133cdf0e10cSrcweir // if (*i == '/') 134cdf0e10cSrcweir // path2.append(TEXT("\\")); 135cdf0e10cSrcweir // else 136cdf0e10cSrcweir // path2.push_back(*i); 137cdf0e10cSrcweir // } 138cdf0e10cSrcweir 139cdf0e10cSrcweir // //We need a null terminated string with two nulls in the end 140cdf0e10cSrcweir // //for the SHFILEOPSTRUCT 141cdf0e10cSrcweir // const TCHAR * szTemp = path2.c_str(); 142cdf0e10cSrcweir // size_t size = path2.size(); 143cdf0e10cSrcweir // TCHAR * szTemp2 = new TCHAR[size + 2]; 144cdf0e10cSrcweir // ZeroMemory(szTemp2, (size + 2) * sizeof(TCHAR)); 145cdf0e10cSrcweir // memcpy(szTemp2, szTemp, size * sizeof(TCHAR)); 146cdf0e10cSrcweir 147cdf0e10cSrcweir // // MessageBox(NULL, szTemp2, "del3", MB_OK); 148cdf0e10cSrcweir // SHFILEOPSTRUCT operation = 149cdf0e10cSrcweir // { 150cdf0e10cSrcweir // NULL, 151cdf0e10cSrcweir // FO_DELETE, 152cdf0e10cSrcweir // szTemp2, 153cdf0e10cSrcweir // NULL, 154cdf0e10cSrcweir // FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR, 155cdf0e10cSrcweir // FALSE, 156cdf0e10cSrcweir // NULL, 157cdf0e10cSrcweir // NULL 158cdf0e10cSrcweir // }; 159cdf0e10cSrcweir 160cdf0e10cSrcweir // SHFileOperation( &operation); 161cdf0e10cSrcweir // delete [] szTemp2; 162cdf0e10cSrcweir // } 163cdf0e10cSrcweir 164cdf0e10cSrcweir 165cdf0e10cSrcweir 166cdf0e10cSrcweir static std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty ) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir std::_tstring result; 169cdf0e10cSrcweir TCHAR szDummy[1] = TEXT(""); 170cdf0e10cSrcweir DWORD nChars = 0; 171cdf0e10cSrcweir 172cdf0e10cSrcweir if ( MsiGetProperty( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA ) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir DWORD nBytes = ++nChars * sizeof(TCHAR); 175cdf0e10cSrcweir LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes)); 176cdf0e10cSrcweir ZeroMemory( buffer, nBytes ); 177cdf0e10cSrcweir MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars); 178cdf0e10cSrcweir result = buffer; 179cdf0e10cSrcweir } 180cdf0e10cSrcweir 181cdf0e10cSrcweir return result; 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir /* creates a child process which is specified in lpCommand. 185cdf0e10cSrcweir 186cdf0e10cSrcweir out_exitCode is the exit code of the child process 187cdf0e10cSrcweir 188cdf0e10cSrcweir 189cdf0e10cSrcweir **/ 190cdf0e10cSrcweir static BOOL ExecuteCommand( LPCTSTR lpCommand, DWORD * out_exitCode) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir BOOL fSuccess = FALSE; 193cdf0e10cSrcweir STARTUPINFO si; 194cdf0e10cSrcweir PROCESS_INFORMATION pi; 195cdf0e10cSrcweir 196cdf0e10cSrcweir ZeroMemory( &si, sizeof(si) ); 197cdf0e10cSrcweir si.cb = sizeof(si); 198cdf0e10cSrcweir 199cdf0e10cSrcweir fSuccess = CreateProcess( 200cdf0e10cSrcweir NULL, 201cdf0e10cSrcweir (LPTSTR)lpCommand, 202cdf0e10cSrcweir NULL, 203cdf0e10cSrcweir NULL, 204cdf0e10cSrcweir FALSE, 205cdf0e10cSrcweir 0, 206cdf0e10cSrcweir NULL, 207cdf0e10cSrcweir NULL, 208cdf0e10cSrcweir &si, 209cdf0e10cSrcweir &pi 210cdf0e10cSrcweir ); 211cdf0e10cSrcweir 212cdf0e10cSrcweir if ( fSuccess ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir WaitForSingleObject( pi.hProcess, INFINITE ); 215cdf0e10cSrcweir 216cdf0e10cSrcweir if (!GetExitCodeProcess( pi.hProcess, out_exitCode)) 217cdf0e10cSrcweir fSuccess = FALSE; 218cdf0e10cSrcweir 219cdf0e10cSrcweir CloseHandle( pi.hProcess ); 220cdf0e10cSrcweir CloseHandle( pi.hThread ); 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir return fSuccess; 224cdf0e10cSrcweir } 225cdf0e10cSrcweir 226cdf0e10cSrcweir static BOOL RemoveCompleteDirectory( std::_tstring sPath ) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir bool bDirectoryRemoved = true; 229cdf0e10cSrcweir 230cdf0e10cSrcweir std::_tstring mystr; 231cdf0e10cSrcweir std::_tstring sPattern = sPath + TEXT("\\") + TEXT("*.*"); 232cdf0e10cSrcweir WIN32_FIND_DATA aFindData; 233cdf0e10cSrcweir 234cdf0e10cSrcweir // Finding all content in sPath 235cdf0e10cSrcweir 236cdf0e10cSrcweir HANDLE hFindContent = FindFirstFile( sPattern.c_str(), &aFindData ); 237cdf0e10cSrcweir 238cdf0e10cSrcweir if ( hFindContent != INVALID_HANDLE_VALUE ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir bool fNextFile = false; 241cdf0e10cSrcweir 242cdf0e10cSrcweir do 243cdf0e10cSrcweir { 244cdf0e10cSrcweir std::_tstring sFileName = aFindData.cFileName; 245cdf0e10cSrcweir std::_tstring sCurrentDir = TEXT("."); 246cdf0e10cSrcweir std::_tstring sParentDir = TEXT(".."); 247cdf0e10cSrcweir 248cdf0e10cSrcweir mystr = "Current short file: " + sFileName; 249cdf0e10cSrcweir // MessageBox(NULL, mystr.c_str(), "Current Content", MB_OK); 250cdf0e10cSrcweir 251cdf0e10cSrcweir if (( strcmp(sFileName.c_str(),sCurrentDir.c_str()) != 0 ) && 252cdf0e10cSrcweir ( strcmp(sFileName.c_str(),sParentDir.c_str()) != 0 )) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir std::_tstring sCompleteFileName = sPath + TEXT("\\") + sFileName; 255cdf0e10cSrcweir 256cdf0e10cSrcweir if ( aFindData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY ) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir bool fSuccess = RemoveCompleteDirectory(sCompleteFileName); 259cdf0e10cSrcweir if ( fSuccess ) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir mystr = "Successfully removed content of dir " + sCompleteFileName; 262cdf0e10cSrcweir // MessageBox(NULL, mystr.c_str(), "Removed Directory", MB_OK); 263cdf0e10cSrcweir } 264cdf0e10cSrcweir else 265cdf0e10cSrcweir { 266cdf0e10cSrcweir mystr = "An error occured during removing content of " + sCompleteFileName; 267cdf0e10cSrcweir // MessageBox(NULL, mystr.c_str(), "Error removing directory", MB_OK); 268cdf0e10cSrcweir } 269cdf0e10cSrcweir } 270cdf0e10cSrcweir else 271cdf0e10cSrcweir { 272cdf0e10cSrcweir bool fSuccess = DeleteFile( sCompleteFileName.c_str() ); 273cdf0e10cSrcweir if ( fSuccess ) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir mystr = "Successfully removed file " + sCompleteFileName; 276cdf0e10cSrcweir // MessageBox(NULL, mystr.c_str(), "Removed File", MB_OK); 277cdf0e10cSrcweir } 278cdf0e10cSrcweir else 279cdf0e10cSrcweir { 280cdf0e10cSrcweir mystr = "An error occured during removal of file " + sCompleteFileName; 281cdf0e10cSrcweir // MessageBox(NULL, mystr.c_str(), "Error removing file", MB_OK); 282cdf0e10cSrcweir } 283cdf0e10cSrcweir } 284cdf0e10cSrcweir } 285cdf0e10cSrcweir 286cdf0e10cSrcweir fNextFile = FindNextFile( hFindContent, &aFindData ); 287cdf0e10cSrcweir 288cdf0e10cSrcweir } while ( fNextFile ); 289cdf0e10cSrcweir 290cdf0e10cSrcweir FindClose( hFindContent ); 291cdf0e10cSrcweir 292cdf0e10cSrcweir // empty directory can be removed now 293cdf0e10cSrcweir // RemoveDirectory is only successful, if the last handle to the directory is closed 294cdf0e10cSrcweir // -> first removing content -> closing handle -> remove empty directory 295cdf0e10cSrcweir 296cdf0e10cSrcweir bool fRemoveDirSuccess = RemoveDirectory(sPath.c_str()); 297cdf0e10cSrcweir 298cdf0e10cSrcweir if ( fRemoveDirSuccess ) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir mystr = "Successfully removed dir " + sPath; 301cdf0e10cSrcweir // MessageBox(NULL, mystr.c_str(), "Removed Directory", MB_OK); 302cdf0e10cSrcweir } 303cdf0e10cSrcweir else 304cdf0e10cSrcweir { 305cdf0e10cSrcweir mystr = "An error occured during removal of empty directory " + sPath; 306cdf0e10cSrcweir // MessageBox(NULL, mystr.c_str(), "Error removing directory", MB_OK); 307cdf0e10cSrcweir bDirectoryRemoved = false; 308cdf0e10cSrcweir } 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir return bDirectoryRemoved; 312cdf0e10cSrcweir } 313cdf0e10cSrcweir 314cdf0e10cSrcweir extern "C" UINT __stdcall RegisterExtensions(MSIHANDLE handle) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir // std::_tstring sInstDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") ); 317cdf0e10cSrcweir std::_tstring sInstDir = GetMsiProperty( handle, TEXT("CustomActionData") ); 318cdf0e10cSrcweir std::_tstring sUnoPkgFile = sInstDir + TEXT("program\\unopkg.exe"); 319cdf0e10cSrcweir std::_tstring mystr; 320cdf0e10cSrcweir 321cdf0e10cSrcweir WIN32_FIND_DATA aFindFileData; 322cdf0e10cSrcweir bool registrationError = false; 323cdf0e10cSrcweir 324cdf0e10cSrcweir // Find unopkg.exe 325cdf0e10cSrcweir HANDLE hFindUnopkg = FindFirstFile( sUnoPkgFile.c_str(), &aFindFileData ); 326cdf0e10cSrcweir 327cdf0e10cSrcweir if ( hFindUnopkg != INVALID_HANDLE_VALUE ) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir // unopkg.exe exists in program directory 330cdf0e10cSrcweir std::_tstring sCommand = sUnoPkgFile + " sync"; 331cdf0e10cSrcweir 332cdf0e10cSrcweir DWORD exitCode = 0; 333cdf0e10cSrcweir bool fSuccess = ExecuteCommand( sCommand.c_str(), & exitCode); 334cdf0e10cSrcweir 335cdf0e10cSrcweir // if ( fSuccess ) 336cdf0e10cSrcweir // { 337cdf0e10cSrcweir // mystr = "Executed successfully!"; 338cdf0e10cSrcweir // MessageBox(NULL, mystr.c_str(), "Command", MB_OK); 339cdf0e10cSrcweir // } 340cdf0e10cSrcweir // else 341cdf0e10cSrcweir // { 342cdf0e10cSrcweir // mystr = "An error occured during execution!"; 343cdf0e10cSrcweir // MessageBox(NULL, mystr.c_str(), "Command", MB_OK); 344cdf0e10cSrcweir // } 345cdf0e10cSrcweir 346cdf0e10cSrcweir if ( ! fSuccess ) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir mystr = "ERROR: An error occured during registration of extensions!"; 349cdf0e10cSrcweir MessageBox(NULL, mystr.c_str(), "ERROR", MB_OK); 350cdf0e10cSrcweir registrationError = true; 351cdf0e10cSrcweir } 352cdf0e10cSrcweir 353cdf0e10cSrcweir FindClose( hFindUnopkg ); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir // else 356cdf0e10cSrcweir // { 357cdf0e10cSrcweir // mystr = "Error: Did not find " + sUnoPkgFile; 358cdf0e10cSrcweir // MessageBox(NULL, mystr.c_str(), "Command", MB_OK); 359cdf0e10cSrcweir // } 360cdf0e10cSrcweir 361cdf0e10cSrcweir if ( registrationError ) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir return 1; 364cdf0e10cSrcweir } 365cdf0e10cSrcweir else 366cdf0e10cSrcweir { 367cdf0e10cSrcweir return ERROR_SUCCESS; 368cdf0e10cSrcweir } 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir 372cdf0e10cSrcweir extern "C" UINT __stdcall RemoveExtensions(MSIHANDLE handle) 373cdf0e10cSrcweir { 374cdf0e10cSrcweir std::_tstring mystr; 375cdf0e10cSrcweir 376cdf0e10cSrcweir // Finding the product with the help of the propery FINDPRODUCT, 377cdf0e10cSrcweir // that contains a Windows Registry key, that points to the install location. 378cdf0e10cSrcweir 379cdf0e10cSrcweir TCHAR szValue[8192]; 380cdf0e10cSrcweir DWORD nValueSize = sizeof(szValue); 381cdf0e10cSrcweir HKEY hKey; 382cdf0e10cSrcweir std::_tstring sInstDir; 383cdf0e10cSrcweir 384cdf0e10cSrcweir std::_tstring sProductKey = GetMsiProperty( handle, TEXT("FINDPRODUCT") ); 385cdf0e10cSrcweir //MessageBox( NULL, sProductKey.c_str(), "Titel", MB_OK ); 386cdf0e10cSrcweir 387cdf0e10cSrcweir if ( ERROR_SUCCESS == RegOpenKey( HKEY_CURRENT_USER, sProductKey.c_str(), &hKey ) ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) 390cdf0e10cSrcweir { 391cdf0e10cSrcweir sInstDir = szValue; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir RegCloseKey( hKey ); 394cdf0e10cSrcweir } 395cdf0e10cSrcweir else if ( ERROR_SUCCESS == RegOpenKey( HKEY_LOCAL_MACHINE, sProductKey.c_str(), &hKey ) ) 396cdf0e10cSrcweir { 397cdf0e10cSrcweir if ( ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("INSTALLLOCATION"), NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir sInstDir = szValue; 400cdf0e10cSrcweir } 401cdf0e10cSrcweir RegCloseKey( hKey ); 402cdf0e10cSrcweir } 403cdf0e10cSrcweir else 404cdf0e10cSrcweir { 405cdf0e10cSrcweir return ERROR_SUCCESS; 406cdf0e10cSrcweir } 407cdf0e10cSrcweir 408cdf0e10cSrcweir // Removing complete directory "Basis\presets\bundled" 409cdf0e10cSrcweir 410cdf0e10cSrcweir std::_tstring sCacheDir = sInstDir + TEXT("share\\prereg\\bundled"); 411cdf0e10cSrcweir 412cdf0e10cSrcweir bool fSuccess = RemoveCompleteDirectory( sCacheDir ); 413cdf0e10cSrcweir 414cdf0e10cSrcweir // if ( fSuccess ) 415cdf0e10cSrcweir // { 416cdf0e10cSrcweir // mystr = "Executed successfully!"; 417cdf0e10cSrcweir // MessageBox(NULL, mystr.c_str(), "Main methode", MB_OK); 418cdf0e10cSrcweir // } 419cdf0e10cSrcweir // else 420cdf0e10cSrcweir // { 421cdf0e10cSrcweir // mystr = "An error occured during execution!"; 422cdf0e10cSrcweir // MessageBox(NULL, mystr.c_str(), "Main methode", MB_OK); 423cdf0e10cSrcweir // } 424cdf0e10cSrcweir 425cdf0e10cSrcweir return ERROR_SUCCESS; 426cdf0e10cSrcweir } 427