ホーム » 2011 » 1月 » 07

日別アーカイブ: 2011/01/07

2011年1月
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

カテゴリー

アーカイブ

ブログ統計情報

  • 79,648 アクセス



登録エントリ (.reg) ファイルの構文

kb 310516 登録エントリ (.reg) ファイルを使用してレジストリ サブキーおよび値を追加、変更、または削除する方法
kb 256986 上級ユーザー向けの Windows レジストリ情報

reg export  key file
Win 7 で file が存在する時,”y/n” の確認が入る.XP ではない.
ShellExec クラス経由で呼び出していたので,file は更新されず原因がわかり難かったのでメモ.

{
 CString command = _T(“Reg.exe”) ;
 CString param ;
 {
  CString dateTime= CTime::GetCurrentTime().Format(_T(“%y%m%d%H%M%S”)) ;
  CString tmpFile = ::FolderAddLastSP(::GetTempPath()) + _T(“M___.tmp\\Reg\\”) + dateTime + _T(“.reg”) ;
  ::CreateEmptyFile(tmpFile) ;
   CFile::Remove(tmpFile) ;
  param = _T(“export hkcu\\”) + subKey + _T(” “) + tmpFile ;
  }
 {
  ShellExec se ;
  se.SetFile(command) ;
  se.SetNon2QMark(TRUE) ;
  se.SetParamaters(param) ;
  se.SetShowCmd(SW_HIDE) ;
  se.Execute() ;
  }
 }

//*******************************************************************************
// 関数名 :文字列に変換
// 作成日 :’10/03/05
//*******************************************************************************
CString RegAccessF::ToString (HKEY hKey,LPCTSTR subKey,LPCTSTR entry)
{
 HSecKey = GetSecKey(hKey,subKey,KEY_QUERY_VALUE) ;
 if (HSecKey == NULL) { return _T(“”) ; }
 Entry = entry ;
 Type = REG_NONE ;
 Count = 0 ;
 wchar_t wcEntry[1024] ;
 ::ToStringWC(wcEntry,countof(wcEntry),Entry) ;
 LONG checkStatus = ::RegQueryValueExW(HSecKey,wcEntry,0,&Type,NULL,&Count) ;
 if (checkStatus != ERROR_SUCCESS) { return _T(“”) ; }
 CByteArray dataAry ; dataAry.SetSize(Count+10) ;
 BYTE* dataPtr = dataAry.GetData() ;
 LONG get__Status = ::RegQueryValueExW(HSecKey,wcEntry,0,&Type,dataPtr,&Count) ;
 if (checkStatus != ERROR_SUCCESS) { return _T(“”) ; }
 CString str ;
 str.Format(_T(“\”%s\”=hex(%x):”),entry,Type) ;
 for (int index=0 ; index BYTE b1 = dataAry[index] ;
  CString bStr ; bStr.Format(_T(“%02x,”),b1) ;
  str += bStr ;
  }
 CloseSecKey() ;
 return str ;
 }
 

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.