Skip to content

Commit

Permalink
imported from version 1.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
yuryu committed Mar 27, 2022
0 parents commit c52723b
Show file tree
Hide file tree
Showing 21 changed files with 2,760 additions and 0 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions ReadMe2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
========================================================================
MICROSOFT FOUNDATION CLASS ���C�u���� : YbInfo
========================================================================


AppWizard ���������� YbInfo �ɂ́AMicrosoft Foundation Class �̊�{�I��
�g������������Ă��܂��B�A�v���P�[�V�����쐬�̂ЂȌ^�Ƃ��Ă��g�����������B

���̃t�@�C���ɂ� YbInfo ���\�����Ă���e�t�@�C���̊T�v�������܂܂�Ă��܂��B

YbInfo.dsp
���̃t�@�C�� (�v���W�F�N�g �t�@�C��) �̓v���W�F�N�g ���x���̏����܂݁A
�V���O�� �v���W�F�N�g�܂��̓T�u �v���W�F�N�g�̃r���h�Ɏg�p����܂��B����
���[�U�[�ƃv���W�F�N�g �t�@�C�� (.dsp) �����L�ł��܂����A���C�N �t�@�C��
�̓��[�J���ɃG�N�X�|�[�g���Ă��������B

YbInfo.h
���̃t�@�C���̓A�v���P�[�V�����̒��S�ƂȂ�C���N���[�h�t�@�C���ł��B����
�t�@�C���͑��̃v���W�F�N�g�̌ŗL�̃C���N���[�h�t�@�C���iResource.h ����
�݂܂��j ���C���N���[�h���A�܂� CYbInfoApp �A�v���P�[�V�����N���X���
�����܂��B

YbInfo.cpp
���̃t�@�C���� CYbInfoApp �A�v���P�[�V�����N���X���܂ރA�v���P�[�V����
�̒��S�ƂȂ�\�[�X�t�@�C���ł��B

YbInfo.rc
���̃t�@�C���̓v���O�������g�p���� Microsoft Windows �̃��\�[�X��񋓂���
���B���̃t�@�C���� RES �T�u�f�B���N�g���ɕۑ�����Ă���A�C�R���A�r�b�g�}
�b�v�A�J�[�\�����܂݂܂��B���̃t�@�C���� Microsoft Visual C++ �Œ���
�ҏW�”\�ł��B

YbInfo.clw
���̃t�@�C���� ClassWizard �������̃N���X�̕ҏW��N���X��V�K�쐬�����
���Ɏg�����������Ă��܂��B�܂����̃t�@�C���́AClassWizard �ɂ�郁�b�Z
�[�W �}�b�v��_�C�A���O �f�[�^ �}�b�v�̕ҏW�␶���A�v���g�^�C�v �����o��
���̐����ɕK�v�ȏ��������Ă��܂��B

res\YbInfo.ico
���̃t�@�C���́A�A�v���P�[�V�����̃A�C�R���Ƃ��Ďg�p�����A�C�R���t�@�C
���ł��B���̃A�C�R���̓��\�[�X �t�@�C�� YbInfo.rc �ɂ���ăC���N���[�h
����܂��B

res\YbInfo.rc2
���̃t�@�C���� Microsoft Visual C++ �ɂ���ĕҏW����Ȃ����\�[�X���܂�ł���
���B���̃t�@�C���Ƀ��\�[�X �G�f�B�^�ŕҏW����Ȃ����ׂẴ��\�[�X���L�q
�����������B




/////////////////////////////////////////////////////////////////////////////

AppWizard �� 1 �‚̃_�C�A���O �N���X���쐬���܂�:

YbInfoDlg.h, YbInfoDlg.cpp - �_�C�A���O
�����̃t�@�C���� CYbInfoDlg �N���X���܂݂܂��B���̃N���X��
�A�v���P�[�V�����̃��C�� �_�C�A���O�̓�����`���܂��B�_�C�A���O
�e���v���[�g�� Microsoft Visual C++ �ŕҏW�”\�� YbInfo.rc �Ɋ�
�܂�܂��B


/////////////////////////////////////////////////////////////////////////////
���̑��̕W���t�@�C��:

StdAfx.h, StdAfx.cpp
�����̃t�@�C���̓v���R���p�C���σw�b�_�[ �t�@�C�� (PCH) YbInfo.pch
��v���R���p�C���ό^�t�@�C�� StdAfx.obj ���\�z���邽�߂Ɏg����t�@�C���ł��B

Resource.h
���̃t�@�C���͐V�K���\�[�X ID ���`����W���w�b�_�[ �t�@�C���ł��B
Microsoft Visual C++ �͂��̃t�@�C����ǂݍ��ݍX�V���܂��B

/////////////////////////////////////////////////////////////////////////////
���̑��̒���:

"TODO:" �Ŏn�܂�R�����g�́A�\�[�X�R�[�h�̒lj���J�X�^�}�C�Y�̕K�v�ȏꏊ����
���܂��B

�A�v���P�[�V�����ŋ��L DLL ���� MFC ���g�p����ꍇ��A�A�v���P�[�V������
�I�y���[�e�B���O �V�X�e���Ō��ݎg�p���Ă��錾��ȊO�̌�����g�p���Ă���ꍇ�́A
Microsoft Visual C++ CD-ROM ����A���[�J���C�Y���ꂽ���\�[�X�ɑΉ�����
MFC42XXX.DLL �� system �܂��� system32 �f�B���N�g���ɃR�s�[���āA�t�@�C������
MFC42LOC.DLL �ɂ���K�v������܂��B("XXX" �͌���̏ȗ��`�������܂��B�Ⴆ�΁A
MFC42JPN.DLL �͓��{��ɖ|�󂳂ꂽ���\�[�X���܂݂܂��B)
���̂悤�ɂ��Ȃ������ꍇ�ɂ́A�A�v���P�[�V�������̂����‚��� UI �v�f�̓I�y
���[�e�B���O �V�X�e���̌���̂܂܎c��܂��B

/////////////////////////////////////////////////////////////////////////////
25 changes: 25 additions & 0 deletions StdAfx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Yuryu's Battery Information, displays detailed battery info.
Copyright (C) 2008 Yuryu
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// stdafx.cpp : 標準インクルードファイルを含むソース ファイル
// YbInfo.pch : 生成されるプリコンパイル済ヘッダー
// stdafx.obj : 生成されるプリコンパイル済タイプ情報

#include "stdafx.h"



53 changes: 53 additions & 0 deletions StdAfx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Yuryu's Battery Information, displays detailed battery info.
Copyright (C) 2008 Yuryu
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// stdafx.h : 標準のシステム インクルード ファイル、
// または参照回数が多く、かつあまり変更されない
// プロジェクト専用のインクルード ファイルを記述します。
//

#if !defined(AFX_STDAFX_H__CF244373_8410_471E_B7B4_1216C0BA68CD__INCLUDED_)
#define AFX_STDAFX_H__CF244373_8410_471E_B7B4_1216C0BA68CD__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

//#define VC_EXTRALEAN // Windows ヘッダーから殆ど使用されないスタッフを除外します。

#include <afxwin.h> // MFC のコアおよび標準コンポーネント
#include <afxext.h> // MFC の拡張部分
#include <afxdisp.h> // MFC のオートメーション クラス
#include <afxdtctl.h> // MFC の Internet Explorer 4 コモン コントロール サポート
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC の Windows コモン コントロール サポート
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <initguid.h>
#include <batclass.h>

#include <winioctl.h>
#include <initguid.h>
#include <setupapi.h>

#include <vector>
#include <cstdlib>

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ は前行の直前に追加の宣言を挿入します。

#endif // !defined(AFX_STDAFX_H__CF244373_8410_471E_B7B4_1216C0BA68CD__INCLUDED_)
88 changes: 88 additions & 0 deletions YBatteries.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
Yuryu's Battery Information, displays detailed battery info.
Copyright (C) 2008 Yuryu
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// YBatteries.cpp: CYBatteries クラスのインプリメンテーション
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "YbInfo.h"
#include "YBatteries.h"

#include "YBattery.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// 構築/消滅
//////////////////////////////////////////////////////////////////////

CYBatteries::CYBatteries()
{
HDEVINFO hBatDevInfo=
SetupDiGetClassDevs(&GUID_DEVICE_BATTERY, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);

int nIndex = 0, nNumberOfBatteries = 0;
for(;;){
BOOL bEnumDev;
SP_DEVICE_INTERFACE_DATA devInterfaceData;
devInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
bEnumDev = SetupDiEnumDeviceInterfaces(hBatDevInfo, NULL, &GUID_DEVICE_BATTERY, nIndex, &devInterfaceData);
// FIXED A BUG 06/07/2004
// it was trying to get device information even when SetupDi... fails.
if(bEnumDev){
// add battery when successful
DWORD reqSize;
SetupDiGetDeviceInterfaceDetail(hBatDevInfo, &devInterfaceData, NULL, 0, &reqSize, NULL);

PSP_DEVICE_INTERFACE_DETAIL_DATA pDevDetailData;
pDevDetailData = reinterpret_cast<PSP_DEVICE_INTERFACE_DETAIL_DATA>(std::malloc(reqSize));
pDevDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);

SetupDiGetDeviceInterfaceDetail(hBatDevInfo, &devInterfaceData, pDevDetailData, reqSize, NULL, NULL);
CString csDevicePath = pDevDetailData->DevicePath;
std::free(pDevDetailData);
CYBattery* pcyBattery = new CYBattery;
pcyBattery->Open(csDevicePath);
m_vcpBatteries.push_back(pcyBattery);
nNumberOfBatteries++;
}else{
// FIXED A BUG 06/06/2004, where batteries are not correctly detected
// according to the SDK document, we must double-check with GetLastError()
// because there are some cases that SetupDiEnumDeviceInterface fails due to different reasons
if(GetLastError() == ERROR_NO_MORE_ITEMS){
break;
}
}
nIndex++;
}
SetupDiDestroyDeviceInfoList(hBatDevInfo);
m_nBatteries = nNumberOfBatteries;

}

CYBatteries::~CYBatteries()
{
while(m_nBatteries--){
delete m_vcpBatteries[m_nBatteries];
m_vcpBatteries.pop_back();
}
}
44 changes: 44 additions & 0 deletions YBatteries.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Yuryu's Battery Information, displays detailed battery info.
Copyright (C) 2008 Yuryu
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

// YBatteries.h: CYBatteries クラスのインターフェイス
//
//////////////////////////////////////////////////////////////////////


#if !defined(AFX_YBATTERIES_H__2020652B_477C_4953_9B0D_AFFC64BDE37B__INCLUDED_)
#define AFX_YBATTERIES_H__2020652B_477C_4953_9B0D_AFFC64BDE37B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CYBattery;

class CYBatteries
{
public:
int m_nBatteries;
std::vector<CYBattery*> m_vcpBatteries;

CYBatteries();
virtual ~CYBatteries();

};

#endif // !defined(AFX_YBATTERIES_H__2020652B_477C_4953_9B0D_AFFC64BDE37B__INCLUDED_)
Loading

0 comments on commit c52723b

Please sign in to comment.