わびさびサンプルソース

WindowsやHTML5などのプログラムのサンプルコードやフリーソフトを提供します。

Windowsのインストールフォルダを取得する

Windowsのインストールフォルダを取得するには、GetWindowsDirectory関数 を呼び出します。

#include <tchar.h>
#include <iostream>
#include <windows.h>



/*
	Windowsのインストールフォルダを取得する
*/
int _tmain
(
	  int argc
	, _TCHAR* argv[]
)
{
	// 標準出力にユニコード出力する
	setlocale( LC_ALL, "Japanese" );

	TCHAR waBuf[ MAX_PATH ];

	// Windowsインストールフォルダの取得
	::GetWindowsDirectory( waBuf, _countof( waBuf ) );

	std::wcout << L"■Windowsインストールフォルダ" << std::endl;
	std::wcout << waBuf << std::endl;

	// 正常終了
	return( 0 );
}



実行結果

■Windowsインストールフォルダ
C:\WINDOWS






わびさびサンプルソース

WindowsやHTML5などのプログラムのサンプルコードやフリーソフトを提供します。