bool StWinHandles::registerClasses(StWinHandles* theSlave, WNDPROC theProc) { const StStringUtfWide aBase = getNewClassName(); const StStringUtfWide aNameGl = aBase + StStringUtfWide(L"Gl"); const StStringUtfWide aNameTmp = aBase + StStringUtfWide(L"Tmp"); const StStringUtfWide aNameSlave = aBase + StStringUtfWide(L"SGl"); if(!registerClass(aBase, theProc)) { return false; } ClassBase = aBase; if(!registerClass(aNameGl, theProc)) { return false; } ClassGL = aNameGl; if(!registerClass(aNameTmp, theProc)) { return false; } ClassTmp = aNameTmp; if(theSlave != NULL) { if(!registerClass(aNameSlave, theProc)) { return false; } theSlave->ClassGL = aNameSlave; } return true; }
StSettings::StSettings(const StHandle<StResourceManager>& /*theResMgr*/, const StString& theSettingsSet) : mySettingsSet(theSettingsSet.toUtfWide()), myRegisterPath(StStringUtfWide("SOFTWARE\\sView\\") + theSettingsSet.toUtfWide()), myToFlush(false) { // }
StStringUtfWide StWinHandles::getNewClassName() { return StStringUtfWide(L"StWindowClass") + StStringUtfWide(ST_CLASS_COUNTER.increment()); }
bool StProcess::execProcess(const StString& theExecutablePath, const StArray<StString>& theArguments) { if(!StFileNode::isFileExists(theExecutablePath)) { return false; } #ifdef _WIN32 // convert to wide strings StStringUtfWide anExecutablePathW = theExecutablePath.toUtfWide(); StArrayList<StStringUtfWide> anArgumentsW(theArguments.size()); StStringUtfWide aSplitter = ' '; StStringUtfWide aCmdLineW = StStringUtfWide('\"') + anExecutablePathW + StStringUtfWide("\" "); for(size_t anElem = 0;;) { // TODO (Kirill Gavrilov#9) we should probably quote arguments with spaces... // how to correctly deal this in the same way for UNIX / Windows? aCmdLineW += theArguments[anElem++].toUtfWide(); if(anElem >= theArguments.size()) { break; } aCmdLineW += aSplitter; } STARTUPINFOW aStartInfo; PROCESS_INFORMATION aProcessInfo; stMemSet(&aStartInfo, 0, sizeof(aStartInfo)); aStartInfo.cb = sizeof(aStartInfo); stMemSet(&aProcessInfo, 0, sizeof(aProcessInfo)); // start the process if(!CreateProcessW(anExecutablePathW.toCString(), (wchar_t* )aCmdLineW.toCString(), NULL, NULL, FALSE, 0, NULL, NULL, &aStartInfo, &aProcessInfo)) { return false; } // close process and thread handles CloseHandle(aProcessInfo.hProcess); CloseHandle(aProcessInfo.hThread); return true; #else char** anArgList = new char*[theArguments.size() + 2]; anArgList[0] = (char* )theExecutablePath.toCString(); for(size_t anArgId = 0; anArgId < theArguments.size(); ++anArgId) { anArgList[anArgId + 1] = (char* )theArguments.getValue(anArgId).toCString(); } anArgList[theArguments.size() + 1] = NULL; pid_t aChildPid = vfork(); if(aChildPid == -1) { // fork fail delete[] anArgList; return false; } else if(aChildPid != 0) { // parent process give the control only after child // calls exit() or exec() functions delete[] anArgList; return true; } // child process execv(theExecutablePath.toCString(), anArgList); // fail _exit(1); #endif }