C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[54552] Re:노트북 배터리 용량 알아내는 방법?
Julien [julien] 1717 읽음    2008-09-11 12:53
MSDN 에 있네요 http://msdn.microsoft.com/ko-kr/library/6khfastx(VS.80).aspx

void CTestView::OnBatterylife() 
{
   COleDispatchDriver disp;
   COleException *e = new COleException;
   
   try {
      // Create instance of Microsoft System Information Control 
      // by using ProgID.
      if (disp.CreateDispatch("SYSINFO.Sysinfo.1", e))
      {
         //Call BatteryLifePercent.     
         short nBatteryLifePercent;
         
         disp.InvokeHelper(0x03, DISPATCH_PROPERTYGET, VT_I2, 
            (void*)&nBatteryLifePercent, NULL);            

         if (nBatteryLifePercent == 255)
            AfxMessageBox("Battery Life % unknown");            
         else
         {
            CString cStr;
            cStr.Format("Battery Life is at %d%%",
                nBatteryLifePercent);
            AfxMessageBox(cStr);
         }
      }
      else
         throw e;

   }
   
   //Catch control-specific exceptions.
    catch (COleDispatchException * e) 
   {
      CString cStr;

      if (!e->m_strSource.IsEmpty())
         cStr = e->m_strSource + " - ";
      if (!e->m_strDescription.IsEmpty())
         cStr += e->m_strDescription;
      else
         cStr += "unknown error";

      AfxMessageBox(cStr, MB_OK, 
         (e->m_strHelpFile.IsEmpty())? 0:e->m_dwHelpContext);

      e->Delete();
   }
   //Catch all MFC exceptions, including COleExceptions.
   // OS exceptions will not be caught.
    catch (CException *e) 
   {
      TRACE("%s(%d): OLE Execption caught: SCODE = %x", 
         __FILE__, __LINE__, COleException::Process(e));
      e->Delete();
   }
}

이피지기 님이 쓰신 글 :
: 안녕하세요.
:
: 다름아니라 제 노트북이 배터리 용량은 나오는데
: 남은 시간이 표시가 안되서 남은 시간을 계산해서 보여주는 프로그램을 만들려고 하는데요.
:
: 어디에도 노트북 배터리 용량을 알아내는 것이 안 나와 있네요 ㅠㅠ;
:
: C++ Builder 6.0에서 알아낼 수 있는 방법이 있을까요..?
:
: 답변 부탁드리겠습니다. 감사합니다.

+ -

관련 글 리스트
54549 노트북 배터리 용량 알아내는 방법? 이피지기 2248 2008/09/11
54552     Re:노트북 배터리 용량 알아내는 방법? Julien 1717 2008/09/11
54567         Re:Re:노트북 배터리 용량 알아내는 방법? 이피지기 1815 2008/09/12
54570             Re:Re:Re:노트북 배터리 용량 알아내는 방법? Julien 2386 2008/09/12
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.