예제 #1
0
 LONG SetKey(LPCWSTR lpSubKey, LPCWSTR lpData, DWORD dwSize)
   const
 {
   if (!IsValidHandle())
     return ERROR_INVALID_HANDLE;
   return RegSetValueW(hKey(), lpSubKey, REG_SZ, lpData, dwSize);
 }
예제 #2
0
 LONG DeleteValue(LPCWSTR lpValueName)
   const
 {
   if (!IsValidHandle())
     return ERROR_INVALID_HANDLE;
   return RegDeleteValueW(hKey(), lpValueName);
 }
int CXTPRegistryManager::EnumValues(LPCTSTR lpszSection, CMap<CString, LPCTSTR, DWORD, DWORD&>* mapItems,
									CStringArray * arrayNames)
{
	ASSERT(lpszSection != NULL);

	CHKey hKey(GetSectionKey(lpszSection, KEY_READ));
	if (hKey == NULL)
		return 0;

	int index = 0;

	TCHAR szValue[512];
	DWORD dwLen = 512;
	DWORD dwType;

	while (::RegEnumValue(hKey, index++, szValue, &dwLen,
		NULL, &dwType, NULL, NULL) == ERROR_SUCCESS)
	{
		if (mapItems) mapItems->SetAt(szValue, dwType);
		if (arrayNames) arrayNames->Add(szValue);
		dwLen = 512;
	}

	return --index;
}
예제 #4
0
 LONG QueryKey(LPCWSTR lpSubKey, LPWSTR lpData, PLONG lpSize)
   const
 {
   if (!IsValidHandle())
     return ERROR_INVALID_HANDLE;
   return RegQueryValueW(hKey(), lpSubKey, lpData, lpSize);
 }
예제 #5
0
  LONG SetValue(LPCWSTR lpValueName = NULL, const LPVOID lpData = NULL,
		DWORD dwSize = 0, DWORD dwType = REG_BINARY)
    const
  {
    if (!IsValidHandle())
      return ERROR_INVALID_HANDLE;
    return RegSetValueExW(hKey(), lpValueName, NULL, dwType,
			  (CONST LPBYTE)lpData, dwSize);
  }
예제 #6
0
  LONG QueryValue(LPCWSTR lpValueName = NULL, LPVOID lpData = NULL,
		  LPDWORD lpSize = 0, LPDWORD lpType = NULL)
    const
  {
    if (!IsValidHandle())
      return ERROR_INVALID_HANDLE;
    return RegQueryValueExW(hKey(), lpValueName, NULL, lpType, (LPBYTE)lpData,
			    lpSize);
  }
예제 #7
0
파일: app.cpp 프로젝트: dawikur/ioDirect
bool Autorun::is() {
  DWORD size = 0;
  utils::Scope(HKEY, &::RegCloseKey) hKey(NULL);
  ::RegOpenKeyEx(
    HKEY_CURRENT_USER, RUN_REG_KEY, 0, KEY_QUERY_VALUE, &hKey.get());
  ::RegQueryValueEx(hKey.get(), g_name, 0, NULL, NULL, &size);
  std::vector<BYTE> buffer(size);
  return ::RegQueryValueEx(hKey.get(), g_name, 0, NULL, buffer.data(), &size) ==
         ERROR_SUCCESS;
}
예제 #8
0
파일: app.cpp 프로젝트: dawikur/ioDirect
void Autorun::on() {
  utils::Scope(HKEY, &::RegCloseKey) hKey(NULL);
  ::RegOpenKeyEx(HKEY_CURRENT_USER, RUN_REG_KEY, 0, KEY_SET_VALUE, &hKey.get());
  ::RegSetValueEx(hKey.get(),
                  g_name,
                  0,
                  REG_SZ,
                  (BYTE *)g_path.c_str(),
                  (DWORD)g_path.size() + 1);
}
예제 #9
0
  /// Closes the embedded handle if it is valid.
  bool Close()
  {
    if (!IsValidHandle())
      return false;
    
    LONG lRegError = RegCloseKey(hKey());
    if (lRegError == ERROR_SUCCESS)
      {
	hObject = INVALID_HANDLE_VALUE;
	return true;
      }
    else
      {
	SetLastError(lRegError);
	return false;
      }
  }
int CXTPRegistryManager::EnumKeys(LPCTSTR lpszSection, CStringArray & arrayKeys)
{
	ASSERT(lpszSection != NULL);

	CHKey hKey(GetSectionKey(lpszSection, KEY_READ));
	if (hKey == NULL)
		return 0;

	int index = 0;

	TCHAR szValue[512];
	DWORD dwLen = 512;

	while (::RegEnumKeyEx(hKey, index++, szValue, &dwLen,
		NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
	{
		arrayKeys.Add(szValue);
		dwLen = 512;
	}

	return --index;
}
예제 #11
0
파일: app.cpp 프로젝트: dawikur/ioDirect
void Autorun::off() {
  utils::Scope(HKEY, &::RegCloseKey) hKey(NULL);
  ::RegOpenKeyEx(HKEY_CURRENT_USER, RUN_REG_KEY, 0, KEY_SET_VALUE, &hKey.get());
  ::RegDeleteValue(hKey.get(), g_name);
}