システム情報取得クラス


  一般的な情報




  

// *********************************************************
// コンピュータ名の取得
// 戻り値 : 取得した文字列の長さ
// 戻り値 : 失敗した場合は 0
// *********************************************************
int LboxInfo::ComputerName( LPTSTR lpBuffer, int nSize )
{
	int ret;
	BOOL bRet;

	ret = nSize;
	bRet = GetComputerName(
		lpBuffer,  // コンピュータ名
		(LPDWORD)(&ret)
	);

	if ( bRet ) {
		return ret;
	}
	else {
		return 0;
	}
}

// *********************************************************
// ユーザ名の取得
// 戻り値 : 取得した文字列の長さ
// 戻り値 : 失敗した場合は 0
// *********************************************************
int LboxInfo::UserName( LPTSTR lpBuffer, int nSize )
{
	int ret;
	BOOL bRet;

	ret = nSize;
	bRet = GetUserName(
		lpBuffer,
		(LPDWORD)(&ret)
	);

	if ( bRet ) {
		return ret;
	}
	else {
		return 0;
	}
}

// *********************************************************
// Windows ディレクトリのパスを取得
// 戻り値 : 取得した文字列の長さ
// 戻り値 : 失敗した場合は 0
// *********************************************************
int LboxInfo::WindowsDirectory( LPTSTR lpBuffer, int nSize )
{
	int ret;
	UINT uRet;

	uRet = GetWindowsDirectory(
		lpBuffer,
		0
	);
	if ( uRet > (UINT)nSize ) {
		return 0;
	}

	ret = (int)GetWindowsDirectory(
		lpBuffer,
		(UINT)nSize
	);

	return ret;
}

// *********************************************************
// システムディレクトリのパスを取得
// 戻り値 : 取得した文字列の長さ
// 戻り値 : 失敗した場合は 0
// *********************************************************
int LboxInfo::SystemDirectory( LPTSTR lpBuffer, int nSize )
{
	int ret;
	UINT uRet;

	uRet = GetSystemDirectory(
		lpBuffer,
		0
	);
	if ( uRet > (UINT)nSize ) {
		return 0;
	}

	ret = (int)GetSystemDirectory(
		lpBuffer,
		(UINT)nSize
	);

	return ret;
}

// *********************************************************
// カレントディレクトリのパスを取得
// 戻り値 : 取得した文字列の長さ
// 戻り値 : 失敗した場合は 0
// *********************************************************
int LboxInfo::CurrentDirectory( LPTSTR lpBuffer, int nSize )
{
	int ret;
	DWORD nRet;

	nRet = GetCurrentDirectory(
		0,
		lpBuffer
	);
	if ( nRet > (DWORD)nSize ) {
		return 0;
	}

	ret = (int)GetCurrentDirectory(
		(DWORD)nSize,
		lpBuffer
	);

	return ret;
}

// *********************************************************
// システム日付を文字列で取得(9999/99/99)
// 戻り値 : 無し
// *********************************************************
void LboxInfo::Date( LPTSTR lpBuffer )
{
	SYSTEMTIME st;

	GetLocalTime(
		&st   // システム日時
	);

	wsprintf(
		lpBuffer,
		"%04d/%02d/%02d",
		st.wYear,
		st.wMonth,
		st.wDay
	);
}

// *********************************************************
// システム時刻を文字列で取得(99:99:99 999)
// 戻り値 : 無し
// *********************************************************
void LboxInfo::Time( LPTSTR lpBuffer )
{
	SYSTEMTIME st;

	GetLocalTime(
		&st   // システム日時
	);

	wsprintf(
		lpBuffer,
		"%02d:%02d:%02d %03d",
		st.wHour,
		st.wMinute,
		st.wSecond,
		st.wMilliseconds
	);
}

// *********************************************************
// 現在の曜日を文字列で取得(日〜土)
// 戻り値 : 無し
// *********************************************************
void LboxInfo::Weekday( LPTSTR lpBuffer )
{
	SYSTEMTIME st;

	GetLocalTime(
		&st   // システム日時
	);

	switch( st.wDayOfWeek ) {
		case 0:
			lstrcpy( lpBuffer, "日" );
			break;
		case 1:
			lstrcpy( lpBuffer, "月" );
			break;
		case 2:
			lstrcpy( lpBuffer, "火" );
			break;
		case 3:
			lstrcpy( lpBuffer, "水" );
			break;
		case 4:
			lstrcpy( lpBuffer, "木" );
			break;
		case 5:
			lstrcpy( lpBuffer, "金" );
			break;
		case 6:
			lstrcpy( lpBuffer, "土" );
			break;
	}

}
  







  特殊な情報




  

// *********************************************************
// ファイルに対する実行プログラムの取得
// 戻り値 : 無し
// *********************************************************
HINSTANCE LboxInfo::Executable( LPCTSTR lpTarget, LPTSTR lpBuffer )
{

	return FindExecutable(
		lpTarget,
		NULL,
		lpBuffer
	);

}

// *********************************************************
// ドライブのボリューム名
// lpDrive には、"C:\\" のようにセット
// 戻り値 : 失敗した場合は 0
// *********************************************************
BOOL LboxInfo::VolumeName( LPCTSTR lpDrive, LPTSTR lpBuffer, int nSize )
{
	DWORD MaximumComponentLength,FileSystemFlags;

	return GetVolumeInformation(
		lpDrive,
		lpBuffer,
		(DWORD)nSize,
		NULL,
		&MaximumComponentLength,
		&FileSystemFlags,
		NULL,
		NULL
	);

}

// *********************************************************
// テンポラリ用のディレクトリパスを取得
// 戻り値 : 失敗した場合は 0,成功すると取得した文字列の長さ
// *********************************************************
int LboxInfo::TempPath( LPTSTR lpBuffer, int nSize )
{
	DWORD nRet;

	nRet = GetTempPath( (DWORD)nSize, lpBuffer );
	if ( nRet > (DWORD)nSize ) {
		return 0;
	}

	return (int)nRet;

}
  

  メッセージボックス用メンバ関数

  

// *********************************************************
// メッセージボックス
// 戻り値 : 押されたボタンのID
// *********************************************************
int LboxInfo::MsgBox(
HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType )
{
	return LboxMsgBox( hWnd, lpText, lpCaption, uType );
}

// *********************************************************
// 確認メッセージボックス
// 戻り値 : 無し
// *********************************************************
void LboxInfo::MsgOk( HWND hWnd, LPCTSTR lpText )
{
	LboxMsgOk( hWnd, lpText );
}

// *********************************************************
// 確認メッセージボックス1
// 戻り値 : OK は true, Cancel は false
// *********************************************************
BOOL LboxInfo::MsgOkCancel( HWND hWnd, LPCTSTR lpText )
{
	return LboxMsgOkCancel( hWnd, lpText );
}

// *********************************************************
// 確認メッセージボックス2
// 戻り値 : YES は true, NO は false
// *********************************************************
BOOL LboxInfo::MsgYesNo( HWND hWnd, LPCTSTR lpText )
{
	return LboxMsgYesNo( hWnd, lpText );
}
  




yahoo  google  MSDN  MSDN(us)  WinFAQ  Win Howto  tohoho  ie_DHTML  vector  wdic  辞書  天気 


[cmstd]
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
24/04/20 21:23:24
InfoBoard Version 1.00 : Language=Perl

1 BatchHelper COMprog CommonSpec Cprog CprogBase CprogSAMPLE CprogSTD CprogSTD2 CprogWinsock Cygwin GameScript HTML HTMLcss InstallShield InstallShieldFunc JScript JScriptSAMPLE Jsfuncs LLINK OldProg OracleGold OracleSilver PRO PRObrowser PROc PROconePOINT PROcontrol PROftpclient PROjscript PROmailer PROperl PROperlCHAT PROphp PROphpLesson PROphpLesson2 PROphpLesson3 PROphpfunction PROphpfunctionArray PROphpfunctionMisc PROphpfunctionString PROsql PROvb PROvbFunction PROvbString PROvbdbmtn PROvbonepoint PROwebapp PROwin1POINT PROwinSYSTEM PROwinYOROZU PROwindows ProjectBoard RealPHP ScriptAPP ScriptMaster VBRealtime Vsfuncs a1root access accreq adsi ajax amazon argus asp aspSample aspVarious aspdotnet aw2kinst cappvariety centura ckeyword classStyle cmaterial cmbin cmdbapp cmenum cmlang cmlistbox cmstd cmstdseed cmtxt cs daz3d db dbCommon dbaccess dnettool dos download flex2 flex3 flex4 framemtn framereq freeWorld freesoft gimp ginpro giodownload google hdml home hta htmlDom ie9svg install java javaSwing javascript jetsql jquery jsp jspTest jspVarious lightbox listasp listmsapi listmsie listmsiis listmsnt listmspatch listmsscript listmsvb listmsvc memo ms msde mysql netbeans oraPlsql oracle oracleWiper oraclehelper orafunc other panoramio pear perl personal pgdojo pgdojo_cal pgdojo_holiday pgdojo_idx pgdojo_ref pgdojo_req php phpVarious phpguide plsql postgres ps r205 realC realwebapp regex rgaki ruby rule sboard sc scprint scquest sdb sdbquest seesaa setup sh_Imagick sh_canvas sh_dotnet sh_google sh_tool sh_web shadowbox shgm shjquery shvbs shweb sjscript skadai skywalker smalltech sperl sqlq src systemdoc tcpip tegaki three toolbox twitter typeface usb useXML vb vbdb vbsfunc vbsguide vbsrc vpc wcsignup webanymind webappgen webclass webparts webtool webwsh win8 winofsql wmi work wp youtube