Ejemplo n.º 1
0
/**
 * Append our subdirectories to the Application Path for this
 * application
 */  
bool RegistryTool::setPathInfo()
{
    Glib::ustring fullPath;
    Glib::ustring path;
    Glib::ustring exeName;

    if (!getExeInfo(fullPath, path, exeName))
        return false;

    //printf("full:'%s' path:'%s' exe:'%s'\n",
    //    fullPath.c_str(), path.c_str(), exeName.c_str());

    Glib::ustring keyName =
    "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\";
    keyName.append(exeName);

    Glib::ustring valueName = "";
    Glib::ustring value     = fullPath;

    if (!setStringValue(keyName, valueName, value))
        return false;

    //add our subdirectories
    Glib::ustring appPath = path;
    appPath.append("\\python;");
    appPath.append(path);
    appPath.append("\\perl");
    valueName = "Path";
    value     = appPath;

    if (!setStringValue(keyName, valueName, value))
        return false;

    return true;
}
void INIFile::Key::setBoolValue(bool newValue)
{
	if(newValue == true) {
		setStringValue("true");
	} else {
		setStringValue("false");
	}
}
void INIFile::Section::setBoolValue(const std::string& key, bool newValue)
{
	if(newValue == true) {
		setStringValue(key, "true");
	} else {
		setStringValue(key, "false");
	}
}
/**
	Sets the boolean that is adressed by the section/key pair to value. If the section and/or the key does not exist it will
	be created. A valid sectionname/keyname is not allowed to contain '[',']',';' or '#' and can not start or end with
	whitespaces (' ' or '\\t').
	\param	section			sectionname
	\param	key				keyname
	\param	value			value that should be set
*/
void INIFile::setBoolValue(const std::string& section, const std::string& key, bool value)
{
	if(value == true) {
		setStringValue(section, key, "true");
	} else {
		setStringValue(section, key, "false");
	}
}
Ejemplo n.º 5
0
/**
	Sets the boolean that is adressed by the section/key pair to value. If the section and/or the key does not exist it will
	be created. A valid sectionname/keyname is not allowed to contain '[',']',';' or '#' and can not start or end with
	whitespaces (' ' or '\\t').
	\param	section			sectionname
	\param	key				keyname
	\param	value			value that should be set
*/
void IniFile::setBoolValue(std::string section, std::string key, bool value)
{
	if(value == true) {
		setStringValue(section, key, "true");
	} else {
		setStringValue(section, key, "false");	
	}
}
Ejemplo n.º 6
0
	/**
	 * Sets value on chunk
	 * @param value Value to set
	 */
	void XmlChunk::setBoolValue(bool value)
	{
		if(value)
		{
			setStringValue(BOOL_TRUE);
		}else
		{
			setStringValue(BOOL_FALSE);
		}
	}
Ejemplo n.º 7
0
PublisherDialog::PublisherDialog(QWidget *parent)
:   QMainWindow(parent), ui(new Ui::PublisherDialog), publisher(0)
{
    ui->setupUi(this);

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
    QPushButton* button = ui->buttonBox->button(QDialogButtonBox::Close);
    if (button) {
        ui->buttonBox->removeButton(button);
    }
    QPushButton *switchButton =
        ui->buttonBox->addButton(tr("Switch"), QDialogButtonBox::ActionRole);
    connect(switchButton, SIGNAL(clicked()), this, SIGNAL(switchRequested()));
#elif defined(MEEGO_EDITION_HARMATTAN)
    connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SIGNAL(closeApp()));
#endif

    //! [1]
    connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(createNewObject()));
    connect(ui->intValue, SIGNAL(valueChanged(int)), this, SLOT(intValueChanged(int)));
    connect(ui->unsetIntButton, SIGNAL(clicked()), this, SLOT(unsetIntValue()));
    connect(ui->setStringButton, SIGNAL(clicked()), this, SLOT(setStringValue()));
    connect(ui->setByteArrayButton, SIGNAL(clicked()), this, SLOT(setByteArrayValue()));
    //! [1]

    //! [3]
    createNewObject();
    //! [3]
}
Ejemplo n.º 8
0
arangodb::traverser::EdgeCursor*
arangodb::traverser::TraverserOptions::nextCursorLocal(ManagedDocumentResult* mmdr,
    VPackSlice vertex, size_t depth, std::vector<LookupInfo>& list) const {
  TRI_ASSERT(mmdr != nullptr);
  auto allCursor = std::make_unique<SingleServerEdgeCursor>(mmdr, _trx, list.size());
  auto& opCursors = allCursor->getCursors();
  VPackValueLength vidLength;
  char const* vid = vertex.getString(vidLength);
  for (auto& info : list) {
    auto& node = info.indexCondition;
    TRI_ASSERT(node->numMembers() > 0);
    if (info.conditionNeedUpdate) {
      // We have to inject _from/_to iff the condition needs it
      auto dirCmp = node->getMemberUnchecked(info.conditionMemberToUpdate);
      TRI_ASSERT(dirCmp->type == aql::NODE_TYPE_OPERATOR_BINARY_EQ);
      TRI_ASSERT(dirCmp->numMembers() == 2);

      auto idNode = dirCmp->getMemberUnchecked(1);
      TRI_ASSERT(idNode->type == aql::NODE_TYPE_VALUE);
      TRI_ASSERT(idNode->isValueType(aql::VALUE_TYPE_STRING));
      idNode->setStringValue(vid, vidLength);
    }
    std::vector<OperationCursor*> csrs;
    csrs.reserve(info.idxHandles.size());
    for (auto const& it : info.idxHandles) {
      csrs.emplace_back(_trx->indexScanForCondition(
          it, node, _tmpVar, mmdr, UINT64_MAX, 1000, false));
    }
    opCursors.emplace_back(std::move(csrs));
  }
  return allCursor.release();
}
Ejemplo n.º 9
0
bool ExpressionItem::setValue(void* value_str,const data_type type) {
    switch(type) {
    case t_int: {
        setIntValue(*(int *)value_str);
        break;
    }
    case t_float: {
        setFloatValue(*(float *)value_str);
        break;
    }
    case t_smallInt:
    {
        setSmallIntValue(*(short *)value_str);
        break;
    }
    case t_double: {
        setDoubleValue(*(double *)value_str);
        break;
    }
    case t_u_long: {
        setULongValue(*(unsigned long*)value_str);
        break;
    }
    case t_string: {
        setStringValue(string((char *)value_str));
        break;
    }
    case t_decimal: {
        setDecimalValue((const char *)value_str);
        break;
    }
    case t_datetime: {
        setDatetimeValue((const char *)value_str);
        break;
    }
    case t_date: {
        setDateValue((const char *)value_str);
        break;
    }
    case t_time: {
        setTimeValue((const char *)value_str);
        break;
    }
    case t_boolean: {
        setBooleanValue(*(bool *)value_str);
        break;
    }
    default: {
        cout<<"no matching operator exists!!!"<<endl;
        /*
         * In the debug phase, it's better to show the assert failure in case of unexpected input.
         * The bug can be found much more easily in such a way.
         */
        assert(false);
        break;
    }
    }
    return true;
}
Ejemplo n.º 10
0
static DWORD copyIpNetPhysAddr(AsnAny *value, void *src)
{
    PMIB_IPNETROW row = (PMIB_IPNETROW)((BYTE *)src - FIELD_OFFSET(MIB_IPNETROW,
                                        dwPhysAddrLen));

    setStringValue(value, ASN_OCTETSTRING, row->dwPhysAddrLen, row->bPhysAddr);
    return SNMP_ERRORSTATUS_NOERROR;
}
Ejemplo n.º 11
0
void CIniFile::readInfo(void)
{
    m_lstNodeInfo.clear();

    std::fstream inStream(m_strFile.c_str(), std::ios::in);
    if (!inStream.good())
    {
        Q_Printf("open file %s error.", m_strFile.c_str());
        inStream.close();

        return;
    }

    char pBuffer[Q_ONEK];
    std::string strTmp;
    std::string strNode;

    while(inStream.good())
    {
        Q_Zero(pBuffer, sizeof(pBuffer));

        inStream.getline(pBuffer, (std::streamsize)(sizeof(pBuffer) - 1));

        strTmp = std::string(pBuffer);
        strTmp = Q_Trim(strTmp);
        if (strTmp.empty()
            || isNote(strTmp))
        {
            continue;
        }

        //去掉注释
        removeNote(strTmp);
        strTmp = Q_Trim(strTmp);
        if (strTmp.empty())
        {
            continue;
        }

        if (isNode(strTmp))
        {
            strNode = getNode(strTmp);

            continue;
        }

        if (isKey(strTmp))
        {
            setStringValue(strNode.c_str(), getKey(strTmp).c_str(), getVal(strTmp).c_str());
        }
    }

    inStream.close();

    return;
}
Ejemplo n.º 12
0
void IniFile::setDoubleValue(const char * section, const char * key, const double value)
{
	std::stringstream buffer;
	std::string valuestr;
	
	buffer << value;
	buffer >> valuestr;
	
	setStringValue(section, key, valuestr.c_str());
}
Ejemplo n.º 13
0
bool arangodb::traverser::TraverserOptions::evaluateEdgeExpression(
    arangodb::velocypack::Slice edge, arangodb::velocypack::Slice vertex,
    size_t depth, size_t cursorId) const {
  if (_isCoordinator) {
    // The Coordinator never checks conditions. The DBServer is responsible!
    return true;
  }
  arangodb::aql::Expression* expression = nullptr;

  auto specific = _depthLookupInfo.find(depth);

  if (specific != _depthLookupInfo.end()) {
    TRI_ASSERT(!specific->second.empty());
    TRI_ASSERT(specific->second.size() > cursorId);
    expression = specific->second[cursorId].expression;
  } else {
    TRI_ASSERT(!_baseLookupInfos.empty());
    TRI_ASSERT(_baseLookupInfos.size() > cursorId);
    expression = _baseLookupInfos[cursorId].expression;
  }
  if (expression != nullptr) {
    TRI_ASSERT(!expression->isV8());
    expression->setVariable(_tmpVar, edge);
  
    VPackValueLength vidLength;
    char const* vid = vertex.getString(vidLength);

    // inject _from/_to value
    auto node = expression->nodeForModification();

    TRI_ASSERT(node->numMembers() > 0);
    auto dirCmp = node->getMemberUnchecked(node->numMembers() - 1);
    TRI_ASSERT(dirCmp->type == aql::NODE_TYPE_OPERATOR_BINARY_EQ); 
    TRI_ASSERT(dirCmp->numMembers() == 2);

    auto idNode = dirCmp->getMemberUnchecked(1);
    TRI_ASSERT(idNode->type == aql::NODE_TYPE_VALUE);
    TRI_ASSERT(idNode->isValueType(aql::VALUE_TYPE_STRING));
    idNode->stealComputedValue();
    idNode->setStringValue(vid, vidLength);

    bool mustDestroy = false;
    aql::AqlValue res = expression->execute(_trx, _ctx, mustDestroy);
    expression->clearVariable(_tmpVar);
    bool result = res.toBoolean();
    if (mustDestroy) {
      res.destroy();
    }
    return result;
  }
  return true;
}
Ejemplo n.º 14
0
static DWORD copyIfRowDescr(AsnAny *value, void *src)
{
    PMIB_IFROW row = (PMIB_IFROW)((BYTE *)src -
                                  FIELD_OFFSET(MIB_IFROW, dwDescrLen));
    DWORD ret;

    if (row->dwDescrLen)
    {
        setStringValue(value, ASN_OCTETSTRING, row->dwDescrLen, row->bDescr);
        ret = SNMP_ERRORSTATUS_NOERROR;
    }
    else
        ret = SNMP_ERRORSTATUS_NOSUCHNAME;
    return ret;
}
Ejemplo n.º 15
0
//! [2]
void PublisherDialog::createNewObject()
{
    if (publisher)
        delete publisher;

    publisher = new QValueSpacePublisher(QValueSpace::WritableLayer, ui->basePath->text());
    if (publisher->isConnected()) {
        ui->setters->setEnabled(true);
        intValueChanged(ui->intValue->value());
        setStringValue();
        setByteArrayValue();
    } else {
        ui->setters->setEnabled(false);
    }
}
Ejemplo n.º 16
0
void PropertyManager::setValue(QtProperty *prop, const QVariant &value)
{
	QtAbstractPropertyManager *mngr = prop->propertyManager();

	if (mngr == m_boolManager)
		setBoolValue(prop, value.toBool());
	else if (mngr == m_stringManager)
		setStringValue(prop, value.toString());
	else if (mngr == m_intManager)
		setIntValue(prop, value.toInt());
	else if (mngr == m_scriptManager)
		setScriptValue(prop, value.toString());
	else if (mngr == m_labelManager)
		setLabelValue(prop, value.toString());
}
Ejemplo n.º 17
0
Var::Var(VarType type, const string& name) :
    _type(type) {
    _name = string(name);
    switch (type) {
    case VT_DOUBLE:
        setDoubleValue(0.0);
        break;
    case VT_INT:
        setIntValue(0);
        break;
    case VT_STRING:
        setStringValue(0);
        break;
    default:
        assert(false);
    }
}
Ejemplo n.º 18
0
PublisherDialog::PublisherDialog(QWidget *parent)
:   QDialog(parent), ui(new Ui::PublisherDialog), publisher(0)
{
    ui->setupUi(this);

#ifdef QTM_EXAMPLES_SMALL_SCREEN
    QPushButton *switchButton =
        ui->buttonBox->addButton(tr("Switch"), QDialogButtonBox::ActionRole);
    connect(switchButton, SIGNAL(clicked()), this, SIGNAL(switchRequested()));
#endif

    //! [1]
    connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(createNewObject()));
    connect(ui->intValue, SIGNAL(valueChanged(int)), this, SLOT(intValueChanged(int)));
    connect(ui->unsetIntButton, SIGNAL(clicked()), this, SLOT(unsetIntValue()));
    connect(ui->setStringButton, SIGNAL(clicked()), this, SLOT(setStringValue()));
    connect(ui->setByteArrayButton, SIGNAL(clicked()), this, SLOT(setByteArrayValue()));
    //! [1]

    //! [3]
    createNewObject();
    //! [3]
}
void INIFile::Key::setDoubleValue(double newValue)
{
	char tmp[30];
	sprintf(tmp,"%f",newValue);
	setStringValue(tmp);
}
Ejemplo n.º 20
0
void CIniFile::setFloatValue(const char *pszNode, const char *pszKey, 
    double dValue)
{
    setStringValue(pszNode, pszKey, Q_ToString(dValue).c_str());
}
Ejemplo n.º 21
0
void CIniFile::setIntValue(const char *pszNode, const char *pszKey, 
    int iValue)
{
    setStringValue(pszNode, pszKey, Q_ToString(iValue).c_str());
}
Ejemplo n.º 22
0
TTErr TTData::setStringValue(const TTValue& value)
{
    if (!mIsSending && mActive) {
		
        // lock
		mIsSending = YES;
        
		if (checkStringType(value)) {
            
            // don't update the internal value with empty value
            if (value.size()) {
                
                // make other value type into symbol
                if (value[0].type() != kTypeSymbol) {
                    
                    TTValue  parsed;
                    TTString s;
                    
                    parsed = value;
                    parsed.toString();
                    s = TTString(parsed[0]);
                    parsed = TTValue(TTSymbol(s));
                    
                    // unlock
                    mIsSending = NO;
                    
                    // set again with the parsed value
                    return setStringValue(parsed);
                }
                
                TTBoolean found = YES;
                
                // check if the string is precised into rangeBounds
                if (mRangeBounds.size()) {
                    
                    found = NO;
                    
                    for (TTUInt32 i = 0; i < mRangeBounds.size(); i++) {
                    
                        found = value[0] == mRangeBounds[i];
                        
                        if (found == YES)
                            break;
                    }
                }
                
                // set internal value
                if (found)
                    mValue = value;
            }
            
            // return the internal value
            returnValue();
            
            // unlock
            mIsSending = NO;
            
            return kTTErrNone;
		}
		else {
			
			// unlock
			mIsSending = NO;
			return kTTErrInvalidValue;
		}
		
		// unlock
		mIsSending = NO;
		
		return kTTErrNone;
	}
    
	return kTTErrGeneric;
}
Ejemplo n.º 23
0
static DWORD copyIpAddr(AsnAny *value, void *src)
{
    setStringValue(value, ASN_IPADDRESS, sizeof(DWORD), src);
    return SNMP_ERRORSTATUS_NOERROR;
}
/**
	Sets the double that is adressed by the section/key pair to value. If the section and/or the key does not exist it will
	be created. A valid sectionname/keyname is not allowed to contain '[',']',';' or '#' and can not start or end with
	whitespaces (' ' or '\\t').
	\param	section			sectionname
	\param	key				keyname
	\param	value			value that should be set
*/
void INIFile::setDoubleValue(const std::string& section, const std::string& key, double value)
{
	char tmp[30];
	sprintf(tmp,"%f",value);
	setStringValue(section, key, tmp);
}
Ejemplo n.º 25
0
void installService(int argc, char **argv)
{
	SC_HANDLE   schService;
	SC_HANDLE   schSCManager;

	TCHAR szPath[512], szDescr[256];

	TCHAR szAppParameters[8192];

	char szParamKey[1025], szParamKey2[1025];

	sprintf(szParamKey,"SYSTEM\\CurrentControlSet\\Services\\%s\\Parameters",SZSERVICENAME);

	// Get the full path and filename of this program
	if ( GetModuleFileName( NULL, szPath, 512 ) == 0 ){
		_tprintf(TEXT("Unable to install %s - %s\n"), TEXT(SZSERVICEDISPLAYNAME),
			GetLastErrorText(szErr, 256));
		return;
	}

	// Next, get a handle to the service control manager
	schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);

	if ( schSCManager ) {
		schService = CreateService(schSCManager,   // SCManager database
			TEXT(SZSERVICENAME),        // name of service
			TEXT(SZSERVICEDISPLAYNAME), // name to display
			SERVICE_ALL_ACCESS,         // desired access
			SERVICE_WIN32_OWN_PROCESS,  // service type
			SERVICESTARTTYPE,           // start type
			SERVICE_ERROR_NORMAL,       // error control type
			szPath,                     // service's binary
			NULL,                       // no load ordering group
			NULL,                       // no tag identifier
			TEXT(SZDEPENDENCIES),       // dependencies
			NULL,                       // LocalSystem account
			NULL);                      // no password

		if (schService){
			_tprintf(TEXT("%s installed.\n"), TEXT(SZSERVICEDISPLAYNAME) );

			// Close the handle to this service object
			CloseServiceHandle(schService);

			/* ****************************************** */
			// Set the service name. Courtesy of Yuri Francalacci <*****@*****.**>
			sprintf(szParamKey2, "SYSTEM\\CurrentControlSet\\Services\\%s",SZSERVICENAME);
			strcpy(szDescr, "ntopng: Web-based network traffic monitor");

			// Set the file value (where the message resources are located.... in this case, our runfile.)
			if(0 != setStringValue((const unsigned char *)szDescr,
				strlen(szDescr) + 1,HKEY_LOCAL_MACHINE, szParamKey2,TEXT("Description")))
			{
				_tprintf(TEXT("The Message File value could\nnot be assigned.\n"));
			}
			/* ********************************************** */


			//Make a registry key to support logging messages using the service name.
			sprintf(szParamKey2, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\%s",SZSERVICENAME);
			if(0 != makeNewKey(HKEY_LOCAL_MACHINE, szParamKey2)){
				_tprintf(TEXT("The EventLog subkey could not be created.\n"));
			}

			// Set the file value (where the message resources are located.... in this case, our runfile.)
			if(0 != setStringValue((const unsigned char *) szPath,
				strlen(szPath) + 1,HKEY_LOCAL_MACHINE,
				szParamKey2,TEXT("EventMessageFile")))
			{
				_tprintf(TEXT("The Message File value could\nnot be assigned.\n"));
			}

			// Set the supported types flags.
			if(0 != setDwordValue(EVENTLOG_INFORMATION_TYPE,HKEY_LOCAL_MACHINE, szParamKey2,TEXT("TypesSupported"))){
				_tprintf(TEXT("The Types Supported value could\nnot be assigned.\n"));
			}

			// Try to create a subkey to hold the runtime args for the JavaVM and
			// Java application
			if(0 != makeNewKey(HKEY_LOCAL_MACHINE, szParamKey)){
				_tprintf(TEXT("Could not create Parameters subkey.\n"));
			} else {
				//Create an argument string from the argument list
				// J. R. Duarte: modified it to store the full command line
				convertArgListToArgString((LPTSTR) szAppParameters,0, argc, argv);
				if(NULL == szAppParameters){
					_tprintf(TEXT("Could not create AppParameters string.\n"));
				} else {
					HKEY hkey;
					DWORD disposition;
					_TCHAR data[] = "redis\0\0";

					// Try to save the argument string under the new subkey
					if(0 != setStringValue(szAppParameters, strlen(szAppParameters)+1,
						HKEY_LOCAL_MACHINE, szParamKey, SZAPPPARAMS)){
							_tprintf(TEXT("Could not save AppParameters value.\n"));
					}

					sprintf(szParamKey,"SYSTEM\\CurrentControlSet\\Services\\%s",SZSERVICENAME);


					if( RegCreateKeyEx( HKEY_LOCAL_MACHINE, szParamKey,
										0, "", 0, KEY_ALL_ACCESS, NULL, &hkey, &disposition) != ERROR_SUCCESS)
					{
						_tprintf(TEXT("Could not create service registry key"));
						return;
					}

					
					strcpy(szAppParameters, "redis");
					// Try to save the argument string under the new subkey
					if(RegSetValueEx (hkey, TEXT("DependOnService"), 0, REG_MULTI_SZ, (LPBYTE)data, strlen(data)+2) != 0) {
							_tprintf(TEXT("Could not save DependOnService value.\n"));
					}

					RegCloseKey(hkey);
				}
			}

		}
		else{
			_tprintf(TEXT("CreateService failed - %s\n"), GetLastErrorText(szErr, 256));
		}

		// Close the handle to the service control manager database
		CloseServiceHandle(schSCManager);
	}
	else{
		_tprintf(TEXT(SZSCMGRFAILURE), GetLastErrorText(szErr,256));
	}
}
Ejemplo n.º 26
0
void installService(char *service_name, int argc, char **argv)
{
  SC_HANDLE   schService;
  SC_HANDLE   schSCManager;
  TCHAR szPath[512], szDescr[256];
  TCHAR szAppParameters[8192];
  SERVICE_DESCRIPTION sdBuf;
  char szParamKey[1025], szParamKey2[1025];

#if 0
  thisIsAservice = 1; bConsole = 0;
  if(argc >=1) traceEvent(TRACE_ERROR, "argv[1] = %s", argv[1]);
  if(argc >=2) traceEvent(TRACE_ERROR, "argv[2] = %s", argv[2]);
  if(argc >=3) traceEvent(TRACE_ERROR, "argv[3] = %s", argv[3]);
#endif

  sprintf(szParamKey, "SYSTEM\\CurrentControlSet\\Services\\%s\\Parameters", service_name);

  // Get the full path and filename of this program
  if ( GetModuleFileName( NULL, szPath, 512 ) == 0 ){
    _tprintf(TEXT("Unable to install %s - %s\n"), TEXT(service_name),
	     GetLastErrorText(szErr, 256));
    return;
  }

  // Next, get a handle to the service control manager
  schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);

  if ( schSCManager ) {

    schService = CreateService(schSCManager,   // SCManager database
			       TEXT(service_name),        // name of service
			       TEXT(service_name), // name to display
			       SERVICE_ALL_ACCESS,         // desired access
			       SERVICE_WIN32_OWN_PROCESS,  // service type
			       SERVICESTARTTYPE,           // start type
			       SERVICE_ERROR_NORMAL,       // error control type
			       szPath,                     // service's binary
			       NULL,                       // no load ordering group
			       NULL,                       // no tag identifier
			       TEXT(SZDEPENDENCIES),       // dependencies
			       NULL,                       // LocalSystem account
			       NULL);                      // no password

    if (schService){
      _tprintf(TEXT("%s installed.\n"), TEXT(service_name) );

      //Create an argument string from the argument list
      // J. R. Duarte: modified it to store the full command line
      convertArgListToArgString((LPTSTR) szAppParameters, 0, argc, argv);

      /* Modify the service description string */
      if(szAppParameters != NULL) {
	sdBuf.lpDescription = szAppParameters;

	if( !ChangeServiceConfig2(
				  schService,                 // handle to service
				  SERVICE_CONFIG_DESCRIPTION, // change: description
				  &sdBuf) )                   // value: new description
	  {
	    ; /* Failed */
	  }
      }

      // Close the handle to this service object
      CloseServiceHandle(schService);

      /* ****************************************** */
      // Set the service name. Courtesy of Yuri Francalacci <*****@*****.**>
      sprintf(szParamKey2, "SYSTEM\\CurrentControlSet\\Services\\%s",service_name);
      snprintf(szDescr, sizeof(szDescr), "lprobe v.%s - NetFlow/IPFIX Probe. http://www.ltop.org/",
	       version);

      // Set the file value (where the message resources are located.... in this case, our runfile.)
      if(0 != setStringValue((const unsigned char *)szDescr,
			     strlen(szDescr) + 1,HKEY_LOCAL_MACHINE, szParamKey2,TEXT("Description")))
	{
	  _tprintf(TEXT("Unable to set service description .\n"));
	}
      /* ********************************************** */



      //Make a registry key to support logging messages using the service name.
      sprintf(szParamKey2, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\%s", service_name);
      if(0 != makeNewKey(HKEY_LOCAL_MACHINE, szParamKey2)){
	_tprintf(TEXT("The EventLog subkey could not be created.\n"));
      }

      // Set the file value (where the message resources are located.... in this case, our runfile.)
      if(0 != setStringValue((const unsigned char *) szPath,
			     strlen(szPath) + 1,HKEY_LOCAL_MACHINE,
			     szParamKey2,TEXT("EventMessageFile")))
	{
	  _tprintf(TEXT("The Message File value could\nnot be assigned.\n"));
	}

      // Set the supported types flags.
      if(0 != setDwordValue(EVENTLOG_INFORMATION_TYPE,HKEY_LOCAL_MACHINE, szParamKey2,TEXT("TypesSupported"))){
	_tprintf(TEXT("The Types Supported value could\nnot be assigned.\n"));
      }

      // Try to create a subkey to hold the runtime args for the JavaVM and
      // Java application
      if(0 != makeNewKey(HKEY_LOCAL_MACHINE, szParamKey)){
	_tprintf(TEXT("Could not create Parameters subkey.\n"));
      } else {
	if(NULL == szAppParameters){
	  _tprintf(TEXT("Could not create AppParameters string.\n"));
	} else{
	  // Try to save the argument string under the new subkey
	  if(0 != setStringValue(szAppParameters, strlen(szAppParameters)+1,
				 HKEY_LOCAL_MACHINE, szParamKey, SZAPPPARAMS)){
	    _tprintf(TEXT("Could not save AppParameters value.\n"));
	  }
	}
      }
    }
    else{
      _tprintf(TEXT("CreateService failed - %s\n"), GetLastErrorText(szErr, 256));
    }

    // Close the handle to the service control manager database
    CloseServiceHandle(schSCManager);
  }
  else{
    _tprintf(TEXT(SZSCMGRFAILURE), GetLastErrorText(szErr,256));
  }
}
/**
	Sets the int that is adressed by the section/key pair to value. If the section and/or the key does not exist it will
	be created. A valid sectionname/keyname is not allowed to contain '[',']',';' or '#' and can not start or end with
	whitespaces (' ' or '\\t').
	\param	section			sectionname
	\param	key				keyname
	\param	value			value that should be set
*/
void INIFile::setIntValue(const std::string& section, const std::string& key, int value)
{
	char tmp[20];
	sprintf(tmp,"%d",value);
	setStringValue(section, key, tmp);
}
void INIFile::Section::setDoubleValue(const std::string& key, double newValue)
{
	char tmp[30];
	sprintf(tmp,"%f",newValue);
	setStringValue(key, tmp);
}
void INIFile::Key::setIntValue(int newValue)
{
	char tmp[20];
	sprintf(tmp,"%d",newValue);
	setStringValue(tmp);
}
void INIFile::Section::setIntValue(const std::string& key, int newValue)
{
	char tmp[20];
	sprintf(tmp,"%d",newValue);
	setStringValue(key, tmp);
}