|
김동원 님이 쓰신 글 :
: UAC관련 문제가 아닌가 합니다.
: OpenKeyReadOnly를 이용해보세요.
: 다음은 참고용 소스입니다.
:
: static bool __fastcall ReadBinary(TMemoryStream* pStream)
: {
: //
: HKEY hKey;
: DWORD dwAccess = STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS; // KEY_ALL_ACCESS
:
: LONG nRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\services\\mssmbios\\Data", 0, dwAccess, &hKey);
: if(nRet != ERROR_SUCCESS)
: {
: Application->MessageBox(SysErrorMessage(nRet).c_str(), L"RegCreateKeyEx - Error", MB_OK | MB_ICONSTOP);
: return false;
: }
:
: DWORD dwType, dwDataSize;
: nRet = ::RegQueryValueEx(hKey, "BiosData", NULL, &dwType, NULL, &dwDataSize);
: if(nRet != ERROR_SUCCESS)
: {
: Application->MessageBox(SysErrorMessage(nRet).c_str(), L"RegQueryValueEx(GetDataSize) - Error", MB_OK | MB_ICONSTOP);
: ::RegCloseKey(hKey);
: return false;
: }
:
: if(dwType == REG_BINARY && 0 < dwDataSize)
: {
: pStream->Size = dwDataSize;
:
: nRet = ::RegQueryValueEx(hKey, "BiosData", NULL, &dwType, (LPBYTE)pStream->Memory, &dwDataSize);
: if(nRet != ERROR_SUCCESS)
: {
: Application->MessageBox(SysErrorMessage(nRet).c_str(), L"RegQueryValueEx(GetData) - Error", MB_OK | MB_ICONSTOP);
: ::RegCloseKey(hKey);
: return false;
: }
: ::RegCloseKey(hKey);
: return true;
: }
: else
: {
: ::RegCloseKey(hKey);
: return false;
: }
: }
: //---------------------------------------------------------------------------
: void __fastcall TForm2::Button1Click(TObject *Sender)
: {
: TMemoryStream* pStream = new TMemoryStream();
: try
: {
: if(ReadBinary(pStream) == true)
: {
: Memo1->Lines->BeginUpdate();
: try
: {
: Memo1->Lines->Clear();
:
: LPBYTE p = (LPBYTE) pStream->Memory;
: int nLine = pStream->Size / 10;
: int nCol = pStream->Size % 10;
:
: int n = 0;
: for(int i = 0 ; i < nLine ; i++, n+=10)
: {
: Memo1->Lines->Add(UnicodeString().sprintf(L"%.02X %.02X %.02X %.02X %.02X %.02X %.02X %.02X %.02X %.02X",
: p[n+0], p[n+1], p[n+2], p[n+3], p[n+4], p[n+5], p[n+6], p[n+7], p[n+8], p[n+9]));
: }
:
: if(nCol != 0)
: {
: UnicodeString strLine = L"";
: for(int i = 0 ; i < nCol ; i++, n++)
: {
: strLine += IntToHex(p[n], 2) + L" ";
: }
: Memo1->Lines->Add(strLine);
: }
: }
: __finally
: {
: Memo1->Lines->EndUpdate();
: }
: }
: else
: Memo1->Lines->Clear();
: }
: __finally
: {
: pStream->Free();
: }
: }
: //---------------------------------------------------------------------------
|