답변 감사합니다만
visual c++ 6.0에서 MFC로 작성하니까 되던데
C++ Builder에서는 COleDispatchDriver를 사용을 못하네요..
BCB에서 사용할 수 있는 방법이 있을까요..? ㅠㅠ;
Julien 님이 쓰신 글 :
: 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에서 알아낼 수 있는 방법이 있을까요..?
: :
: : 답변 부탁드리겠습니다. 감사합니다.
|