当前位置: 首页>>代码示例>>C++>>正文


C++ RegDeleteKey函数代码示例

本文整理汇总了C++中RegDeleteKey函数的典型用法代码示例。如果您正苦于以下问题:C++ RegDeleteKey函数的具体用法?C++ RegDeleteKey怎么用?C++ RegDeleteKey使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了RegDeleteKey函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UnregisterService

    /*
     * Unregister the service with the  Windows SCM 
     * Input - ServiceName
     */
int
UnregisterService (LPCTSTR lpszServiceName, int quiet)
{
  TCHAR MsgErrorString[MAX_STR_SIZE];	/* Message or Error string */
  SC_HANDLE hSCManager = NULL;	/* SCM handle */
  SC_HANDLE hService = NULL;	/* Service Handle */
  SERVICE_STATUS sStatus;
  TCHAR szRegAppLogKey[] =
    _T("SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\");
  TCHAR szRegKey[512];
  int exitStatus = 0;
/*  HKEY hKey = NULL;		?* Key to registry entry */
  TRY
  {
    /*
     * Open Service Control Manager 
     */
    hSCManager = OpenSCManager (NULL, NULL, SC_MANAGER_CREATE_SERVICE);
    if (hSCManager == NULL)
      {
        ProcessError (EVENTLOG_ERROR_TYPE, _T ("Can't open SCM (Service Control Manager)"), 1, quiet);
        exitStatus = SERVICE_ERROR_SCM_OPEN;       
	LEAVE;
      }

    /*
     * Open registered service 
     */
    hService = OpenService (hSCManager, lpszServiceName, SERVICE_ALL_ACCESS);
    if (hService == NULL)
      {
	_sntprintf (MsgErrorString, CountOf(MsgErrorString), _T("%s %s"), _T ("Can't open service"),
		   lpszServiceName);
        ProcessError (EVENTLOG_ERROR_TYPE, MsgErrorString, 1, quiet);
        exitStatus = SERVICE_ERROR_OPEN_SERVICE;       
	LEAVE;
      }

    /*
     * Query service status 
     * If running stop before deleting 
     */
    if (QueryServiceStatus (hService, &sStatus))
      {
	if (sStatus.dwCurrentState == SERVICE_RUNNING
	    || sStatus.dwCurrentState == SERVICE_PAUSED)
	  {
	    ControlService (hService, SERVICE_CONTROL_STOP, &sStatus);
	  }
      };

    /*
     * Delete the service  
     */
    if (DeleteService (hService) == FALSE)
      {
	_sntprintf (MsgErrorString, CountOf(MsgErrorString), _T("%s %s"), _T ("Can't delete service"),
		   lpszServiceName);

	/*
	 * Log message to eventlog 
	 */
        ProcessError (EVENTLOG_ERROR_TYPE, MsgErrorString, 0, quiet);
	LEAVE;
      }

    /*
     * Log "Service deleted successfully " message to eventlog
     */
    _sntprintf (MsgErrorString, CountOf(MsgErrorString), _T("%s %s"), lpszServiceName, _T ("service deleted"));
    ProcessError (EVENTLOG_INFORMATION_TYPE, MsgErrorString, 0, quiet);

    /*
     * Delete registry entries for EventLog 
     */
    _tcscpy (szRegKey, szRegAppLogKey);
    _tcscat (szRegKey, lpszServiceName);
    RegDeleteKey (HKEY_LOCAL_MACHINE, szRegKey);
  }

  /*
   * Delete the handles 
   */
  FINALLY
  {
    if (hService)
      CloseServiceHandle (hService);
    if (hSCManager)
      CloseServiceHandle (hSCManager);
  }
  return (exitStatus);
}
开发者ID:duniansampa,项目名称:SigLog,代码行数:96,代码来源:winservice.c

示例2: DeletePrevInstance

void DeletePrevInstance()
{
	TCHAR* janusguid = _T("{63C4751A-5B1B-41DD-862B-C1230691B403}");
	TCHAR* rootKey = _T("Software\\Microsoft\\Internet Explorer\\MenuExt\\");

	HKEY hCU;
	LONG lResult = RegOpenKeyEx(HKEY_CURRENT_USER,rootKey,
								0,KEY_ENUMERATE_SUB_KEYS | KEY_SET_VALUE | KEY_QUERY_VALUE | KEY_CREATE_SUB_KEY,
								&hCU);

	if(ERROR_SUCCESS == lResult)
	{

		TCHAR buffer[MAX_PATH] = {0};
		DWORD idx = 0;

		TCHAR subkeyName[MAX_PATH] = {0};
		DWORD subkeyLength = MAX_PATH;

		lResult = RegEnumKeyEx(hCU,idx,subkeyName,&subkeyLength,NULL,NULL,NULL,NULL);
		if(ERROR_SUCCESS == lResult)
		{
			do
			{
				lstrcpy(buffer,rootKey);
				lstrcat(buffer,subkeyName);

				
				HKEY hCheckKey;
				lResult = RegOpenKeyEx(HKEY_CURRENT_USER,buffer,0,KEY_QUERY_VALUE,&hCheckKey);
				if(ERROR_SUCCESS == lResult)
				{
					
					DWORD dwTmp;
					lResult = RegQueryValueEx(hCheckKey,janusguid,NULL,NULL,NULL,&dwTmp);
					if(ERROR_SUCCESS == lResult)
					{
						RegCloseKey(hCheckKey);
						//RegCloseKey(hCU);
						//hCU = NULL;

						RegDeleteKey(HKEY_CURRENT_USER,buffer);

						//continue;

					} // if(ERROR_SUCCESS == lResult)
					else
					{
						RegCloseKey(hCheckKey);
					}
				} // if(ERROR_SUCCESS == lResult)


				subkeyLength = MAX_PATH;
				idx++;
			} while(RegEnumKeyEx(hCU,idx,subkeyName,&subkeyLength,NULL,NULL,NULL,NULL) != ERROR_NO_MORE_ITEMS);

		} // if(ERROR_SUCCESS == lResult)

		if(hCU)
			RegCloseKey(hCU);
	} // if(ERROR_SUCCESS == lResult)
}
开发者ID:rsdn,项目名称:janus,代码行数:63,代码来源:gojanus.cpp

示例3: create_parameters

int create_parameters(nssm_service_t *service, bool editing) {
  /* Try to open the registry */
  HKEY key = open_registry(service->name, KEY_WRITE);
  if (! key) return 1;

  /* Remember parameters in case we need to delete them. */
  TCHAR registry[KEY_LENGTH];
  int ret = service_registry_path(service->name, true, 0, registry, _countof(registry));

  /* Try to create the parameters */
  if (set_expand_string(key, NSSM_REG_EXE, service->exe)) {
    if (ret > 0) RegDeleteKey(HKEY_LOCAL_MACHINE, registry);
    RegCloseKey(key);
    return 2;
  }
  if (set_expand_string(key, NSSM_REG_FLAGS, service->flags)) {
    if (ret > 0) RegDeleteKey(HKEY_LOCAL_MACHINE, registry);
    RegCloseKey(key);
    return 3;
  }
  if (set_expand_string(key, NSSM_REG_DIR, service->dir)) {
    if (ret > 0) RegDeleteKey(HKEY_LOCAL_MACHINE, registry);
    RegCloseKey(key);
    return 4;
  }

  /* Other non-default parameters. May fail. */
  if (service->priority != NORMAL_PRIORITY_CLASS) set_number(key, NSSM_REG_PRIORITY, service->priority);
  else if (editing) RegDeleteValue(key, NSSM_REG_PRIORITY);
  if (service->affinity) {
    TCHAR *string;
    if (! affinity_mask_to_string(service->affinity, &string)) {
      if (RegSetValueEx(key, NSSM_REG_AFFINITY, 0, REG_SZ, (const unsigned char *) string, (unsigned long) (_tcslen(string) + 1) * sizeof(TCHAR)) != ERROR_SUCCESS) {
        log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_SETVALUE_FAILED, NSSM_REG_AFFINITY, error_string(GetLastError()), 0);
        HeapFree(GetProcessHeap(), 0, string);
        return 5;
      }
    }
    if (string) HeapFree(GetProcessHeap(), 0, string);
  }
  else if (editing) RegDeleteValue(key, NSSM_REG_AFFINITY);
  unsigned long stop_method_skip = ~service->stop_method;
  if (stop_method_skip) set_number(key, NSSM_REG_STOP_METHOD_SKIP, stop_method_skip);
  else if (editing) RegDeleteValue(key, NSSM_REG_STOP_METHOD_SKIP);
  if (service->default_exit_action < NSSM_NUM_EXIT_ACTIONS) create_exit_action(service->name, exit_action_strings[service->default_exit_action], editing);
  if (service->restart_delay) set_number(key, NSSM_REG_RESTART_DELAY, service->restart_delay);
  else if (editing) RegDeleteValue(key, NSSM_REG_RESTART_DELAY);
  if (service->throttle_delay != NSSM_RESET_THROTTLE_RESTART) set_number(key, NSSM_REG_THROTTLE, service->throttle_delay);
  else if (editing) RegDeleteValue(key, NSSM_REG_THROTTLE);
  if (service->kill_console_delay != NSSM_KILL_CONSOLE_GRACE_PERIOD) set_number(key, NSSM_REG_KILL_CONSOLE_GRACE_PERIOD, service->kill_console_delay);
  else if (editing) RegDeleteValue(key, NSSM_REG_KILL_CONSOLE_GRACE_PERIOD);
  if (service->kill_window_delay != NSSM_KILL_WINDOW_GRACE_PERIOD) set_number(key, NSSM_REG_KILL_WINDOW_GRACE_PERIOD, service->kill_window_delay);
  else if (editing) RegDeleteValue(key, NSSM_REG_KILL_WINDOW_GRACE_PERIOD);
  if (service->kill_threads_delay != NSSM_KILL_THREADS_GRACE_PERIOD) set_number(key, NSSM_REG_KILL_THREADS_GRACE_PERIOD, service->kill_threads_delay);
  else if (editing) RegDeleteValue(key, NSSM_REG_KILL_THREADS_GRACE_PERIOD);
  if (! service->kill_process_tree) set_number(key, NSSM_REG_KILL_PROCESS_TREE, 0);
  else if (editing) RegDeleteValue(key, NSSM_REG_KILL_PROCESS_TREE);
  if (service->stdin_path[0] || editing) {
    if (service->stdin_path[0]) set_expand_string(key, NSSM_REG_STDIN, service->stdin_path);
    else if (editing) RegDeleteValue(key, NSSM_REG_STDIN);
    if (service->stdin_sharing != NSSM_STDIN_SHARING) set_createfile_parameter(key, NSSM_REG_STDIN, NSSM_REG_STDIO_SHARING, service->stdin_sharing);
    else if (editing) delete_createfile_parameter(key, NSSM_REG_STDIN, NSSM_REG_STDIO_SHARING);
    if (service->stdin_disposition != NSSM_STDIN_DISPOSITION) set_createfile_parameter(key, NSSM_REG_STDIN, NSSM_REG_STDIO_DISPOSITION, service->stdin_disposition);
    else if (editing) delete_createfile_parameter(key, NSSM_REG_STDIN, NSSM_REG_STDIO_DISPOSITION);
    if (service->stdin_flags != NSSM_STDIN_FLAGS) set_createfile_parameter(key, NSSM_REG_STDIN, NSSM_REG_STDIO_FLAGS, service->stdin_flags);
    else if (editing) delete_createfile_parameter(key, NSSM_REG_STDIN, NSSM_REG_STDIO_FLAGS);
  }
  if (service->stdout_path[0] || editing) {
    if (service->stdout_path[0]) set_expand_string(key, NSSM_REG_STDOUT, service->stdout_path);
    else if (editing) RegDeleteValue(key, NSSM_REG_STDOUT);
    if (service->stdout_sharing != NSSM_STDOUT_SHARING) set_createfile_parameter(key, NSSM_REG_STDOUT, NSSM_REG_STDIO_SHARING, service->stdout_sharing);
    else if (editing) delete_createfile_parameter(key, NSSM_REG_STDOUT, NSSM_REG_STDIO_SHARING);
    if (service->stdout_disposition != NSSM_STDOUT_DISPOSITION) set_createfile_parameter(key, NSSM_REG_STDOUT, NSSM_REG_STDIO_DISPOSITION, service->stdout_disposition);
    else if (editing) delete_createfile_parameter(key, NSSM_REG_STDOUT, NSSM_REG_STDIO_DISPOSITION);
    if (service->stdout_flags != NSSM_STDOUT_FLAGS) set_createfile_parameter(key, NSSM_REG_STDOUT, NSSM_REG_STDIO_FLAGS, service->stdout_flags);
    else if (editing) delete_createfile_parameter(key, NSSM_REG_STDOUT, NSSM_REG_STDIO_FLAGS);
    if (service->stdout_copy_and_truncate) set_createfile_parameter(key, NSSM_REG_STDOUT, NSSM_REG_STDIO_COPY_AND_TRUNCATE, 1);
    else if (editing) delete_createfile_parameter(key, NSSM_REG_STDOUT, NSSM_REG_STDIO_COPY_AND_TRUNCATE);
  }
  if (service->stderr_path[0] || editing) {
    if (service->stderr_path[0]) set_expand_string(key, NSSM_REG_STDERR, service->stderr_path);
    else if (editing) RegDeleteValue(key, NSSM_REG_STDERR);
    if (service->stderr_sharing != NSSM_STDERR_SHARING) set_createfile_parameter(key, NSSM_REG_STDERR, NSSM_REG_STDIO_SHARING, service->stderr_sharing);
    else if (editing) delete_createfile_parameter(key, NSSM_REG_STDERR, NSSM_REG_STDIO_SHARING);
    if (service->stderr_disposition != NSSM_STDERR_DISPOSITION) set_createfile_parameter(key, NSSM_REG_STDERR, NSSM_REG_STDIO_DISPOSITION, service->stderr_disposition);
    else if (editing) delete_createfile_parameter(key, NSSM_REG_STDERR, NSSM_REG_STDIO_DISPOSITION);
    if (service->stderr_flags != NSSM_STDERR_FLAGS) set_createfile_parameter(key, NSSM_REG_STDERR, NSSM_REG_STDIO_FLAGS, service->stderr_flags);
    else if (editing) delete_createfile_parameter(key, NSSM_REG_STDERR, NSSM_REG_STDIO_FLAGS);
    if (service->stderr_copy_and_truncate) set_createfile_parameter(key, NSSM_REG_STDERR, NSSM_REG_STDIO_COPY_AND_TRUNCATE, 1);
    else if (editing) delete_createfile_parameter(key, NSSM_REG_STDERR, NSSM_REG_STDIO_COPY_AND_TRUNCATE);
  }
  if (service->timestamp_log) set_number(key, NSSM_REG_TIMESTAMP_LOG, 1);
  else if (editing) RegDeleteValue(key, NSSM_REG_TIMESTAMP_LOG);
  if (service->hook_share_output_handles) set_number(key, NSSM_REG_HOOK_SHARE_OUTPUT_HANDLES, 1);
  else if (editing) RegDeleteValue(key, NSSM_REG_HOOK_SHARE_OUTPUT_HANDLES);
  if (service->rotate_files) set_number(key, NSSM_REG_ROTATE, 1);
  else if (editing) RegDeleteValue(key, NSSM_REG_ROTATE);
  if (service->rotate_stdout_online) set_number(key, NSSM_REG_ROTATE_ONLINE, 1);
  else if (editing) RegDeleteValue(key, NSSM_REG_ROTATE_ONLINE);
  if (service->rotate_seconds) set_number(key, NSSM_REG_ROTATE_SECONDS, service->rotate_seconds);
//.........这里部分代码省略.........
开发者ID:kirillkovalenko,项目名称:nssm,代码行数:101,代码来源:registry.cpp

示例4: RegCloseKey

void CUninstallApp::DelValveKeysIfEmpty()
{
	LONG lResult;
	HKEY hKey;
	
	char keyname[256]={0};
	DWORD namesize=256;
	
	//do HKEY_LOCAL_MACHINE first
	lResult=RegOpenKeyEx(HKEY_LOCAL_MACHINE,REG_VALVE_KEY,0,KEY_ALL_ACCESS,&hKey);
	if (lResult==ERROR_SUCCESS)
	{
		lResult=RegEnumKeyEx(hKey,0,keyname,&namesize,NULL,NULL,NULL,NULL);
		if (lResult==ERROR_NO_MORE_ITEMS)
		{
			RegCloseKey(hKey);
			lResult=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE",0,KEY_ALL_ACCESS,&hKey);
			if (lResult==ERROR_SUCCESS)
			{
				RegDeleteKey(hKey,"Valve");
				RegCloseKey(hKey);
			}
#ifdef _DEBUG
			else 
			{
				AfxMessageBox("Couldn't open HKLM\\Software");
			}
#endif
		}
#ifdef _DEBUG
		else 
		{
			AfxMessageBox("found something in HKLM\\software\\valve, not deleting");
		}
#endif
	}
#ifdef _DEBUG
	else 
	{
		AfxMessageBox(CString("failed trying open: HKLM ")+CString(REG_VALVE_KEY));
	}
#endif

	//now do HKEY_CURRENT_USER
	lResult=RegOpenKeyEx(HKEY_CURRENT_USER,REG_VALVE_KEY,0,KEY_ALL_ACCESS,&hKey);
	if (lResult==ERROR_SUCCESS)
	{
		lResult=RegEnumKeyEx(hKey,0,keyname,&namesize,NULL,NULL,NULL,NULL);
		if (lResult==ERROR_NO_MORE_ITEMS)
		{
			RegCloseKey(hKey);
			lResult=RegOpenKeyEx(HKEY_CURRENT_USER,"SOFTWARE",0,KEY_ALL_ACCESS,&hKey);
			if (lResult==ERROR_SUCCESS)
			{
				RegDeleteKey(hKey,"Valve");
				RegCloseKey(hKey);
			}
#ifdef _DEBUG
			else 
			{
				AfxMessageBox("Couldn't open HKCU\\Software");
			}
#endif
		}
#ifdef _DEBUG
		else 
		{
			AfxMessageBox("found something in HKCU\\software\\valve, not deleting");
		}
#endif
	}
#ifdef _DEBUG
	else 
	{
		AfxMessageBox(CString("failed trying open: HKCU ")+CString(REG_VALVE_KEY));
	}
#endif
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:78,代码来源:uninstall.cpp

示例5: icvSaveWindowPos

// Window positions saving/loading added by Philip Gruebele.
//<a href="mailto:[email protected]">[email protected]</a>
// philipg.  Saves the window position in the registry
static void
icvSaveWindowPos( const char* name, CvRect rect )
{
    static const DWORD MAX_RECORD_COUNT = 100;
    HKEY hkey;
    char szKey[1024];
    char rootKey[1024];
    strcpy( szKey, icvWindowPosRootKey );
    strcat( szKey, name );
    
    if( RegOpenKeyEx( HKEY_CURRENT_USER,szKey,0,KEY_READ,&hkey) != ERROR_SUCCESS )
    {
        HKEY hroot;
        DWORD count = 0;
        FILETIME oldestTime = { UINT_MAX, UINT_MAX };
        char oldestKey[1024];
        char currentKey[1024];

        strcpy( rootKey, icvWindowPosRootKey );
        rootKey[strlen(rootKey)-1] = '\0';
        if( RegCreateKeyEx(HKEY_CURRENT_USER, rootKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ+KEY_WRITE, 0, &hroot, NULL) != ERROR_SUCCESS )
            //RegOpenKeyEx( HKEY_CURRENT_USER,rootKey,0,KEY_READ,&hroot) != ERROR_SUCCESS )
            return;

        for(;;)
        {
            DWORD csize = sizeof(currentKey);
            FILETIME accesstime = { 0, 0 };
            LONG code = RegEnumKeyEx( hroot, count, currentKey, &csize, NULL, NULL, NULL, &accesstime );
            if( code != ERROR_SUCCESS && code != ERROR_MORE_DATA )
                break;
            count++;
            if( oldestTime.dwHighDateTime > accesstime.dwHighDateTime ||
                (oldestTime.dwHighDateTime == accesstime.dwHighDateTime &&
                oldestTime.dwLowDateTime > accesstime.dwLowDateTime) )
            {
                oldestTime = accesstime;
                strcpy( oldestKey, currentKey );
            }
        }

        if( count >= MAX_RECORD_COUNT )
            RegDeleteKey( hroot, oldestKey );
        RegCloseKey( hroot );

        if( RegCreateKeyEx(HKEY_CURRENT_USER,szKey,0,NULL,REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, &hkey, NULL) != ERROR_SUCCESS )
            return;
    }
    else
    {
        RegCloseKey( hkey );
        if( RegOpenKeyEx( HKEY_CURRENT_USER,szKey,0,KEY_WRITE,&hkey) != ERROR_SUCCESS )
            return;
    }
    
    RegSetValueEx(hkey, "Left", 0, REG_DWORD, (BYTE*)&rect.x, sizeof(rect.x));
    RegSetValueEx(hkey, "Top", 0, REG_DWORD, (BYTE*)&rect.y, sizeof(rect.y));
    RegSetValueEx(hkey, "Width", 0, REG_DWORD, (BYTE*)&rect.width, sizeof(rect.width));
    RegSetValueEx(hkey, "Height", 0, REG_DWORD, (BYTE*)&rect.height, sizeof(rect.height));
    RegCloseKey(hkey);
}
开发者ID:NaterGator,项目名称:AndroidOpenCV_mods,代码行数:64,代码来源:window_w32.cpp

示例6: UnregisterServer

STDAPI UnregisterServer(CLSID clsid, LPTSTR lpszTitle)
{
    int      i;
    LRESULT  lResult;
    TCHAR    szSubKey[MAX_PATH];
    TCHAR    szCLSID[MAX_PATH];
    TCHAR    szModule[MAX_PATH];
    LPWSTR   pwsz;
    DWORD    retval;
    HRESULT  hr;

    // Get the CLSID in string form.
    StringFromIID(clsid, &pwsz);

    if(pwsz)
    {
#ifdef UNICODE
        hr = StringCchCopyW(szCLSID, MAX_PATH, pwsz);
        // TODO: Add error handling for hr here.
#else
        WideCharToMultiByte( CP_ACP,
            0,
            pwsz,
            -1,
            szCLSID,
            MAX_PATH * sizeof(TCHAR),
            NULL,
            NULL);
#endif

        // Free the string.
        LPMALLOC pMalloc;
        CoGetMalloc(1, &pMalloc);
        pMalloc->Free(pwsz);
        pMalloc->Release();
    }

    // Get this app's path and file name.
    retval = GetModuleFileName(DllhInstance, szModule, MAX_PATH);
    // TODO: Add error handling to check return value for success/failure
    //       before using szModule.

    DOREGSTRUCT ClsidEntries[ ] = {
        {HKEY_CLASSES_ROOT,TEXT("CLSID\\%38s"),NULL,lpszTitle},
        {HKEY_CLASSES_ROOT,TEXT("CLSID\\%38s\\InprocServer32"),NULL,szModule},
        {HKEY_CLASSES_ROOT,TEXT("CLSID\\%38s\\InprocServer32"),TEXT("ThreadingModel"),TEXT("Apartment")},
        {NULL,NULL,NULL,NULL}
    };

    //register the CLSID entries
    for(i = 0; ClsidEntries[i].hRootKey; i++)
    {
        //create the sub key string - for this case, insert the file extension
        hr = StringCchPrintf(szSubKey, 
            MAX_PATH, 
            ClsidEntries[i].szSubKey, 
            szCLSID);
        // TODO: Add error handling code here to check the hr return value.

        lResult = RegDeleteKey(ClsidEntries[i].hRootKey,ClsidEntries[i].szSubKey);
    }
    return S_OK;  
}
开发者ID:340211173,项目名称:hf-2011,代码行数:63,代码来源:ComStuff.cpp

示例7: RegOpenKeyEx

void tst_QValueSpaceSubscriber::initTestCase()
{
    qRegisterMetaType<QVariant>("QVariant");
    qRegisterMetaType<QValueSpace::LayerOptions>("QValueSpace::LayerOptions");

#ifdef Q_OS_WIN
    HKEY key;
    long result = RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Nokia",
                               0, KEY_ALL_ACCESS, &key);
    if (result == ERROR_SUCCESS) {
        result = RegDeleteKey(key, L"QtMobility\\volatileContext");
        result = RegDeleteKey(key, L"QtMobility\\nonVolatileContext");
        result = RegDeleteKey(key, L"QtMobility");

        RegCloseKey(key);
    }
#endif

#if defined(Q_OS_UNIX) && defined(QT_START_VALUESPACE)
    QFile::remove("/tmp/qt-0/valuespace_shmlayer");
#endif

#if defined(QT_START_VALUESPACE)
    QValueSpace::initValueSpaceServer();
#endif

    QList<QAbstractValueSpaceLayer *> layers = QValueSpaceManager::instance()->getLayers();
    for (int i = 0; i < layers.count(); ++i) {
        QValueSpacePublisher *root = new QValueSpacePublisher(layers.at(i)->id(), "/");
        root->setValue("/home/user/bool", true);
        root->setValue("/home/user/int", 3);
        root->setValue("/home/user/QString", QString("testString"));
        QStringList stringList;
        stringList << QString("String 1") << QString("String 2");
        root->setValue("/home/user/QStringList", stringList);
        root->setValue("/home/user/qint64", qint64(64));
        root->setValue("/home/user/QByteArray", QByteArray("testByteArray"));
        root->setValue("/home/user/double", 4.56);
        root->setValue("/home/user/float", (float)4.56f);
        root->setValue("/home/user/QChar", QChar('c'));
        //so far not a lot of data types are supported
        //root->setValue("/home/user/QRect", QRect(0,0,5,6));

        root->setValue("/home/usercount", 1);

        root->setValue("/layer/name", layers.at(i)->name());
        root->setValue("/layer/id", layers.at(i)->id().toString());
        root->setValue("/layer/options", uint(layers.at(i)->layerOptions()));

        root->sync();

        roots.insert(layers.at(i), root);

        QValueSpacePublisher *busy = new QValueSpacePublisher(layers.at(i)->id(), "/usr");
        busy->setValue("alex/busy", true);
        busy->setValue("lorn/busy", false);
        busy->sync();

        busys.insert(layers.at(i), busy);
    }
}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:61,代码来源:tst_qvaluespacesubscribershared.cpp

示例8: BV2RecentsDlgProc

LRESULT CALLBACK BV2RecentsDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	int dlgItemID;
	int i;
	char filename[256];
	HWND mCtrl;
	RECT cr,r,r1;

	switch (message)
	{
		case WM_INITDIALOG:
		mCtrl = GetDlgItem(hDlg, IDC_LISTTEXT);
		sdata_init(&myrecents.rct);
		if (ReadRecentFilesInReg())
		{
		    for(i=0;i<sdata_jumlahdata(&myrecents.rct);i++)
		    {
		        sdata_ambildatanomor(&myrecents.rct, i, filename);
		        AddListBoxItem (mCtrl, filename, i);
		    }
		}

		//return TRUE;
		case WM_SIZE:
		GetClientRect (hDlg, &cr);
		mCtrl = GetDlgItem(hDlg, IDC_LISTTEXT);
		MoveWindow (mCtrl, 2, 2, cr.right-4, cr.bottom-28, TRUE);
		mCtrl = GetDlgItem(hDlg, IDOK);
		GetWindowRect(mCtrl, &r);
		MoveWindow (mCtrl, 2, cr.bottom-24, (r.right-r.left), (r.bottom-r.top), TRUE);
		mCtrl = GetDlgItem(hDlg, IDCANCEL);
		MoveWindow (mCtrl, 4+(r.right-r.left), cr.bottom-24, (r.right-r.left), (r.bottom-r.top), TRUE);
		mCtrl = GetDlgItem(hDlg, IDC_CLEAR);
		MoveWindow (mCtrl, 6+(r.right-r.left)*2, cr.bottom-24, (r.right-r.left), (r.bottom-r.top), TRUE);
		mCtrl = GetDlgItem(hDlg, IDC_NEWWINDOW);

		/* shb-20070906 */
		GetWindowRect(mCtrl, &r1);
		MoveWindow (mCtrl, 12+(r.right-r.left)*3, cr.bottom-20, (r1.right-r1.left), (r1.bottom-r1.top), TRUE);
		/* shb-20070906 */

		return TRUE;
		break;

		case WM_COMMAND:
		dlgItemID = LOWORD(wParam);
		if (dlgItemID==IDOK || (dlgItemID==IDC_LISTTEXT && HIWORD(wParam)==LBN_DBLCLK))
		{
            GetListBoxCurSelString (GetDlgItem(hDlg, IDC_LISTTEXT), myrecents.file);
            myrecents.newwin = IsDlgButtonChecked (hDlg, IDC_NEWWINDOW);
		    EndDialog(hDlg, IDOK);
		}
		else if (dlgItemID==IDCANCEL)
		{
		    EndDialog(hDlg, dlgItemID);
		}
		else if (dlgItemID==IDC_CLEAR)
		{
		    RegDeleteKey (HKEY_CURRENT_USER, "Software\\eshabe\\BeeVee\\MRU");
		    EndDialog(hDlg, dlgItemID);
		}
		break;
		case WM_DESTROY:
		sdata_hapussemua (&myrecents.rct);
		break;
	}
	return FALSE;
}
开发者ID:apla,项目名称:beevee,代码行数:68,代码来源:bv2recents.c

示例9: RemoveService

BOOL 
RemoveService(const char* pServiceName)
{
    long	lRet		= 0;
    HKEY	hkParameters	= NULL;
    SC_HANDLE	schService	= NULL;
    SC_HANDLE   schSCManager	= NULL;
    BOOL	bStatus		= TRUE;

    SERVICE_STATUS  ssStatus; 
    
    // Open the service control manager
    schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
    if(schSCManager == NULL)
    {                           
	bStatus = FALSE;
	goto cleanup;
    }

    // Open the service entry
    schService = OpenService(schSCManager, pServiceName, SERVICE_ALL_ACCESS);

    if(schService == NULL) 
    {   
	if (GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST)
	{
	    bStatus = TRUE;
	    goto cleanup;
	}
	else 
	{
	    LPVOID lpMsgBuf;

	    FormatMessage( 
		FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
		NULL,
		GetLastError(),
		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
		(LPTSTR) &lpMsgBuf,
		0,
		NULL 
	    );

	    // Display the string
	    fprintf(stderr, "%s\n", lpMsgBuf);

	    // Free the buffer.
	    LocalFree( lpMsgBuf );

	    bStatus = FALSE;
	    goto cleanup;
	}
    }

    // Determine the status of the service (started/stopped)
    if (!QueryServiceStatus(schService, &ssStatus))
    {
	bStatus = FALSE;
	goto cleanup;
    }

    if (ssStatus.dwCurrentState == SERVICE_RUNNING)
    {
	// Service is still running!
	bStatus = FALSE;
	goto cleanup;
    }

    // Delete the service
    if (!DeleteService(schService))
    {
	bStatus = FALSE;
	goto cleanup;
    }

    // Clean up the registry entry associated with the service
    lRet = RegOpenKeyEx(
	HKEY_LOCAL_MACHINE,
	REGISTRY_KEY_EVENTLOG,
	0,
	KEY_ALL_ACCESS,
	&hkParameters);

    if (lRet != ERROR_SUCCESS)
    {
	bStatus = FALSE;
	goto cleanup;
    }

    // Delete the service specific keys
    lRet = RegDeleteKey(hkParameters, pServiceName);
    if (lRet != ERROR_SUCCESS)
    {
	bStatus = FALSE;
	goto cleanup;
    }

    bStatus = TRUE;

cleanup:
//.........这里部分代码省略.........
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:101,代码来源:service.cpp

示例10: DeletePrintProvidorW

/*
 * @unimplemented
 */
BOOL
WINAPI
DeletePrintProvidorW(LPWSTR Name, LPWSTR Environment, LPWSTR PrintProvidor)
{
   HKEY hKey;
   BOOL bFound;
   DWORD dwType, dwSize, dwOffset, dwLength;
   LPWSTR pOrder, pBuffer, pNew;

   if (Name || !Environment || !PrintProvidor)
   {
      SetLastError(ERROR_INVALID_PARAMETER);
      return FALSE;
   }

   if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Print\\Providers", 0, KEY_READ | KEY_WRITE, &hKey) != ERROR_SUCCESS)
   {
      return FALSE;
   }

   if (RegQueryValueExW(hKey, L"Order", NULL, &dwType, NULL, &dwSize) != ERROR_SUCCESS || dwType != REG_MULTI_SZ)
   {
      RegCloseKey(hKey);
      return FALSE;
   }

   pOrder = HeapAlloc(GetProcessHeap(), 0, dwSize);
   if (!pOrder)
   {
      RegCloseKey(hKey);
      return FALSE;
   }

   if (RegQueryValueExW(hKey, L"Order", NULL, &dwType, (LPBYTE)pOrder, &dwSize) != ERROR_SUCCESS || dwType != REG_MULTI_SZ)
   {
      RegCloseKey(hKey);
      return FALSE;
   }


   pBuffer = pOrder;
   bFound = FALSE;
   while(pBuffer[0])
   {
       if (!wcsicmp(pBuffer, PrintProvidor))
       {
            bFound = TRUE;
            break;
         }
         pBuffer += wcslen(pBuffer) + 1;
   }

   if (!bFound)
   {
      RegCloseKey(hKey);
      HeapFree(GetProcessHeap(), 0, pOrder);
      return FALSE;
   }

   pNew = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize);
   if (!pNew)
   {
      RegCloseKey(hKey);
      HeapFree(GetProcessHeap(), 0, pOrder);
      return FALSE;
   }

   dwOffset = pBuffer - pOrder;
   dwLength = (dwSize / sizeof(WCHAR)) - (dwOffset + wcslen(pBuffer) + 1);
   CopyMemory(pNew, pOrder, dwOffset * sizeof(WCHAR));
   CopyMemory(&pNew[dwOffset], pBuffer + wcslen(pBuffer) + 1, dwLength);

   RegSetValueExW(hKey, L"Order", 0, REG_MULTI_SZ, (LPBYTE)pNew, (dwOffset + dwLength) * sizeof(WCHAR));
   RegDeleteKey(hKey, PrintProvidor);

   HeapFree(GetProcessHeap(), 0, pOrder);
   HeapFree(GetProcessHeap(), 0, pNew);
   RegCloseKey(hKey);

   return TRUE;
}
开发者ID:hoangduit,项目名称:reactos,代码行数:84,代码来源:info.c

示例11: DllUnregisterServer

STDAPI
DllUnregisterServer(
    void)
{
    LONG nStatus;
    DWORD dwDisp;
    HRESULT hReturnStatus = NO_ERROR;
    HKEY hProviders = NULL;
#ifdef SCARD_CSP
    SCARDCONTEXT hCtx = NULL;
#endif

#ifdef _AFXDLL
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
#endif


    //
    // Delete the Registry key for this CSP.
    //

    nStatus = RegCreateKeyEx(
                    HKEY_LOCAL_MACHINE,
                    TEXT("SOFTWARE\\Microsoft\\Cryptography\\Defaults\\Provider"),
                    0,
                    TEXT(""),
                    REG_OPTION_NON_VOLATILE,
                    KEY_ALL_ACCESS,
                    NULL,
                    &hProviders,
                    &dwDisp);
    if (ERROR_SUCCESS == nStatus)
    {
        RegDeleteKey(hProviders, l_szProviderName);
        RegCloseKey(hProviders);
        hProviders = NULL;
    }


#ifdef SCARD_CSP
    //
    // Forget the card type.
    //

    hCtx = NULL;
    SCardEstablishContext(SCARD_SCOPE_SYSTEM, 0, 0, &hCtx);
    SCardForgetCardType(hCtx, l_szCardName);
    if (NULL != hCtx)
    {
        SCardReleaseContext(hCtx);
        hCtx = NULL;
    }
#endif


    //
    // ?vendor?
    // Delete vendor specific registry entries.
    //



    //
    // All done!
    //

    return hReturnStatus;
}
开发者ID:zdmatrix,项目名称:eIDApplicationManageProject,代码行数:68,代码来源:AutoReg.cpp

示例12: RegDeleteKey

/* delete the given value or key in the registry with all of its subkeys in subkey */
bool CReg::DeleteKey (LPCTSTR pszSubKey, LPCTSTR pszValName)
{
  return RegDeleteKey (hKey, pszSubKey, pszValName);
}
开发者ID:sdottaka,项目名称:winmerge-v2,代码行数:5,代码来源:registry.cpp

示例13: SavePasswordToRegistry

BOOL SavePasswordToRegistry(TCHAR *szAccount, TCHAR *szPassword, bool persistent)
{
	int nError;
	BOOL bResult = TRUE;
	
	TCHAR szKey[256];
	HKEY hRegKey = NULL;
	_tcscpy(szKey, MPICHKEY);
	
	if (persistent)
	{
		if (RegCreateKeyEx(HKEY_CURRENT_USER, szKey,
			0, 
			NULL, 
			REG_OPTION_NON_VOLATILE,
			KEY_ALL_ACCESS, 
			NULL,
			&hRegKey, 
			NULL) != ERROR_SUCCESS) 
		{
			nError = GetLastError();
			printf("SavePasswordToRegistry:RegCreateKeyEx(...) failed, error: %d\n", nError);
			return FALSE;
		}
	}
	else
	{
		RegDeleteKey(HKEY_CURRENT_USER, szKey);
		if (RegCreateKeyEx(HKEY_CURRENT_USER, szKey,
			0, 
			NULL, 
			REG_OPTION_VOLATILE,
			KEY_ALL_ACCESS, 
			NULL,
			&hRegKey, 
			NULL) != ERROR_SUCCESS) 
		{
			nError = GetLastError();
			printf("SavePasswordToRegistry:RegDeleteKey(...) failed, error: %d\n", nError);
			return FALSE;
		}
	}

	// Store the account name
	if (::RegSetValueEx(
			hRegKey, _T("Account"), 0, REG_SZ, 
			(BYTE*)szAccount, 
			sizeof(TCHAR)*(_tcslen(szAccount)+1)
			)!=ERROR_SUCCESS)
	{
		nError = GetLastError();
		printf("SavePasswordToRegistry:RegSetValueEx(...) failed, error: %d\n", nError);
		::RegCloseKey(hRegKey);
		return FALSE;
	}

	HCRYPTPROV hProv = NULL;
	HCRYPTKEY hKey = NULL;
	HCRYPTKEY hXchgKey = NULL;
	HCRYPTHASH hHash = NULL;
	DWORD dwLength;
	// Used to encrypt the real password
	TCHAR szLocalPassword[] = _T("[email protected]*I%Ll");

	// Get handle to user default provider.
	//if (CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, 0))
	if (CryptAcquireContext(&hProv, "MPICH", NULL, PROV_RSA_FULL, 0))
	{
		// Create hash object.
		if (CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash))
		{
			// Hash password string.
			dwLength = sizeof(TCHAR)*_tcslen(szLocalPassword);
			if (CryptHashData(hHash, (BYTE *)szLocalPassword, dwLength, 0))
			{
				// Create block cipher session key based on hash of the password.
				if (CryptDeriveKey(hProv, CALG_RC4, hHash, CRYPT_EXPORTABLE, &hKey))
				{
					// Determine number of bytes to encrypt at a time.
					dwLength = sizeof(TCHAR)*(_tcslen(szPassword)+1);

					// Allocate memory.
					BYTE *pbBuffer = (BYTE *)malloc(dwLength);
					if (pbBuffer != NULL)
					{
						memcpy(pbBuffer, szPassword, dwLength);
						// Encrypt data
						if (CryptEncrypt(hKey, 0, TRUE, 0, pbBuffer, &dwLength, dwLength)) 
						{
							// Write data to registry.
							DWORD dwType = REG_BINARY;
							// Add the password.
							if (::RegSetValueEx(hRegKey, _T("Password"), 0, REG_BINARY, pbBuffer, dwLength)!=ERROR_SUCCESS)
							{
								nError = GetLastError();
								printf("SavePasswordToRegistry:RegSetValueEx(...) failed, error: %d\n", nError);
								bResult = FALSE;
							}
							::RegCloseKey(hRegKey);
						}	
//.........这里部分代码省略.........
开发者ID:hpc,项目名称:mvapich-cce,代码行数:101,代码来源:MPICH_pwd.cpp

示例14: RegDeleteKey

LONG RegDeleteKey( HKEY hKey, const char* lpSubKey )
{ USES_CONVERSION; return RegDeleteKey( hKey, A2T(lpSubKey) ); }
开发者ID:gawadepd,项目名称:kh323phone,代码行数:2,代码来源:stdlibx.cpp

示例15: LoadDriver

bool LoadDriver(char * szDrvName, char * szDrvPath)
{
	char szSubKey[MAX_PATH];
	char szDrvFullPath[MAX_PATH];
//	LSA_UNICODE_STRING buf1;
//	LSA_UNICODE_STRING buf2;
	int iBuffLen;
	HKEY hkResult;
//	char Data[4];
	DWORD dwOK;
	iBuffLen = sprintf_s(szSubKey, MAX_PATH, "System\\CurrentControlSet\\Services\\%s", szDrvName);
	szSubKey[iBuffLen]=0;
	dwOK = RegCreateKey(HKEY_LOCAL_MACHINE,szSubKey,&hkResult);
	if(dwOK!=ERROR_SUCCESS)
		return false;


	DWORD val;
	val = 1;
	if(RegSetValueEx(hkResult, "Type", 0, REG_DWORD, (PBYTE)&val, sizeof(val)) != ERROR_SUCCESS)
		return FALSE;

	if(RegSetValueEx(hkResult, "ErrorControl", 0, REG_DWORD, (PBYTE)&val, sizeof(val)) != ERROR_SUCCESS)
		return FALSE;

	val = 3;
	if(RegSetValueEx(hkResult, "Start", 0, REG_DWORD, (PBYTE)&val, sizeof(val)) != ERROR_SUCCESS)
		return FALSE;

	GetFullPathName(szDrvPath, MAX_PATH, szDrvFullPath, NULL);  
	printf("  Loading driver: %s\r\n", szDrvFullPath);
	iBuffLen = sprintf_s(szSubKey, MAX_PATH, "\\??\\%s", szDrvFullPath);
	szSubKey[iBuffLen]=0;
	dwOK=RegSetValueEx(hkResult,"ImagePath",0,1,(const unsigned char *)szSubKey,iBuffLen);
	RegCloseKey(hkResult); 


	HMODULE hntdll;

	hntdll = LoadLibrary( "ntdll.dll" ); 

	VOID (WINAPI *_RtlInitAnsiString)
		(IN OUT PANSI_STRING  DestinationString,
		IN PCHAR  SourceString);

	*(FARPROC *)&_RtlInitAnsiString = 
		GetProcAddress(hntdll, "RtlInitAnsiString");

	ANSI_STRING aStr;
	char szServicePath[MAX_PATH];
	sprintf_s(szServicePath, MAX_PATH, "\\Registry\\Machine\\System\\CurrentControlSet\\Services\\%s", szDrvName);
	_RtlInitAnsiString(&aStr, szServicePath);

	UNICODE_STRING uStr;

	if(RtlAnsiStringToUnicodeString(&uStr, &aStr, TRUE) != STATUS_SUCCESS)
	{
		return FALSE;
	}
	else
	{
		DWORD	dwRet=ZwLoadDriver(&uStr); 
		#define STATUS_IMAGE_ALREADY_LOADED      ((NTSTATUS)0xC000010EL)
		if (STATUS_IMAGE_ALREADY_LOADED== dwRet)
		{
			OutputDebugString("ZwLoadDriver return STATUS_IMAGE_ALREADY_LOADED\n");
		}
		if( dwRet== STATUS_SUCCESS || dwRet==STATUS_IMAGE_ALREADY_LOADED )
		{
			RtlFreeUnicodeString(&uStr);
		}
		else
		{

			
			RtlFreeUnicodeString(&uStr);			
			return FALSE;
		}
	}

	iBuffLen=sprintf_s(szSubKey, MAX_PATH, "%s%s\\Enum","System\\CurrentControlSet\\Services\\", szDrvName);
	szSubKey[iBuffLen]=0;
	RegDeleteKey(HKEY_LOCAL_MACHINE,szSubKey);
	iBuffLen=sprintf_s(szSubKey, MAX_PATH, "%s%s\\Security","System\\CurrentControlSet\\Services\\", szDrvName);
	szSubKey[iBuffLen]=0;
	RegDeleteKey(HKEY_LOCAL_MACHINE,szSubKey);
	iBuffLen=sprintf_s(szSubKey, MAX_PATH, "%s%s","System\\CurrentControlSet\\Services\\", szDrvName);
	szSubKey[iBuffLen]=0;
	RegDeleteKey(HKEY_LOCAL_MACHINE,szSubKey);
	iBuffLen=sprintf_s(szSubKey, MAX_PATH, "\\\\.\\%s", szDrvName);
	szSubKey[iBuffLen]=0;
	return true;
}
开发者ID:wtxpwh,项目名称:cyber-interceptor,代码行数:93,代码来源:DriverLoader.cpp


注:本文中的RegDeleteKey函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。