푸른나무그늘

마음이 쉬는 곳...

포토로그 마이가든


QR CODE

이글루스 구글 검색엔진


Twitter


OS Version 얻어오기 프로그래밍

OS Version 얻어오는 코드 구현 할 때마다 찾아서 하려니 귀찮아서 블로그에 올려둡니다.
이 코드는 Windows 2000 부터 Windows 7 까지의 버전 정보를 구분합니다.

코드를 가져와 실행 해보니 Windows 7을 구분 못하길래
살펴보니 Windows 7 이 빠져 있어서 추가 하였습니다.

=============================================================
#include <windows.h>
#include <strsafe.h>

#define BUFSIZE 256

typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);

BOOL GetOSDisplayString( LPSTR pszOS)
{
OSVERSIONINFOEX osvi;
SYSTEM_INFO si;
PGNSI pGNSI;
PGPI pGPI;
BOOL bOsVersionInfoEx;
DWORD dwType;
LPFN_ISWOW64PROCESS fnIsWow64Process;
BOOL bIsWow64 = FALSE;

ZeroMemory(&si, sizeof(SYSTEM_INFO));
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));

osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
{
return 1;
}

// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.

pGNSI = (PGNSI) GetProcAddress(GetModuleHandle("kernel32.dll"), "GetNativeSystemInfo");

if(NULL != pGNSI)
pGNSI(&si);
else GetSystemInfo(&si);

if ( VER_PLATFORM_WIN32_NT == osvi.dwPlatformId && osvi.dwMajorVersion > 4 )
{
StringCchCopy(pszOS, BUFSIZE, "Microsoft ");

// Test for the specific product.

if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1 )
{
if( osvi.wProductType == VER_NT_WORKSTATION )
StringCchCat(pszOS, BUFSIZE, "Windows 7 ");
else StringCchCat(pszOS, BUFSIZE, "Windows Server 2008 R2 " );

pGPI = (PGPI) GetProcAddress(GetModuleHandle("kernel32.dll"), "GetProductInfo");

pGPI( 6, 0, 0, 0, &dwType);

switch( dwType )
{
case PRODUCT_ULTIMATE:
StringCchCat(pszOS, BUFSIZE, "Ultimate Edition" );
break;
case PRODUCT_HOME_PREMIUM:
StringCchCat(pszOS, BUFSIZE, "Home Premium Edition" );
break;
case PRODUCT_HOME_BASIC:
StringCchCat(pszOS, BUFSIZE, "Home Basic Edition" );
break;
case PRODUCT_ENTERPRISE:
StringCchCat(pszOS, BUFSIZE, "Enterprise Edition" );
break;
case PRODUCT_BUSINESS:
StringCchCat(pszOS, BUFSIZE, "Business Edition" );
break;
case PRODUCT_STARTER:
StringCchCat(pszOS, BUFSIZE, "Starter Edition" );
break;
case PRODUCT_CLUSTER_SERVER:
StringCchCat(pszOS, BUFSIZE, "Cluster Server Edition" );
break;
case PRODUCT_DATACENTER_SERVER:
StringCchCat(pszOS, BUFSIZE, "Datacenter Edition" );
break;
case PRODUCT_DATACENTER_SERVER_CORE:
StringCchCat(pszOS, BUFSIZE, "Datacenter Edition (core installation)" );
break;
case PRODUCT_ENTERPRISE_SERVER:
StringCchCat(pszOS, BUFSIZE, "Enterprise Edition" );
break;
case PRODUCT_ENTERPRISE_SERVER_CORE:
StringCchCat(pszOS, BUFSIZE, "Enterprise Edition (core installation)" );
break;
case PRODUCT_ENTERPRISE_SERVER_IA64:
StringCchCat(pszOS, BUFSIZE, "Enterprise Edition for Itanium-based Systems" );
break;
case PRODUCT_SMALLBUSINESS_SERVER:
StringCchCat(pszOS, BUFSIZE, "Small Business Server" );
break;
case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
StringCchCat(pszOS, BUFSIZE, "Small Business Server Premium Edition" );
break;
case PRODUCT_STANDARD_SERVER:
StringCchCat(pszOS, BUFSIZE, "Standard Edition" );
break;
case PRODUCT_STANDARD_SERVER_CORE:
StringCchCat(pszOS, BUFSIZE, "Standard Edition (core installation)" );
break;
case PRODUCT_WEB_SERVER:
StringCchCat(pszOS, BUFSIZE, "Web Server Edition" );
break;
}
if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
StringCchCat(pszOS, BUFSIZE,  ", 64-bit" );
else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL )
StringCchCat(pszOS, BUFSIZE, ", 32-bit");
}

if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
{
if( osvi.wProductType == VER_NT_WORKSTATION )
StringCchCat(pszOS, BUFSIZE, "Windows Vista ");
else StringCchCat(pszOS, BUFSIZE, "Windows Server 2008 " );

pGPI = (PGPI) GetProcAddress(GetModuleHandle("kernel32.dll"), "GetProductInfo");

pGPI( 6, 0, 0, 0, &dwType);

switch( dwType )
{
case PRODUCT_ULTIMATE:
StringCchCat(pszOS, BUFSIZE, "Ultimate Edition" );
break;
case PRODUCT_HOME_PREMIUM:
StringCchCat(pszOS, BUFSIZE, "Home Premium Edition" );
break;
case PRODUCT_HOME_BASIC:
StringCchCat(pszOS, BUFSIZE, "Home Basic Edition" );
break;
case PRODUCT_ENTERPRISE:
StringCchCat(pszOS, BUFSIZE, "Enterprise Edition" );
break;
case PRODUCT_BUSINESS:
StringCchCat(pszOS, BUFSIZE, "Business Edition" );
break;
case PRODUCT_STARTER:
StringCchCat(pszOS, BUFSIZE, "Starter Edition" );
break;
case PRODUCT_CLUSTER_SERVER:
StringCchCat(pszOS, BUFSIZE, "Cluster Server Edition" );
break;
case PRODUCT_DATACENTER_SERVER:
StringCchCat(pszOS, BUFSIZE, "Datacenter Edition" );
break;
case PRODUCT_DATACENTER_SERVER_CORE:
StringCchCat(pszOS, BUFSIZE, "Datacenter Edition (core installation)" );
break;
case PRODUCT_ENTERPRISE_SERVER:
StringCchCat(pszOS, BUFSIZE, "Enterprise Edition" );
break;
case PRODUCT_ENTERPRISE_SERVER_CORE:
StringCchCat(pszOS, BUFSIZE, "Enterprise Edition (core installation)" );
break;
case PRODUCT_ENTERPRISE_SERVER_IA64:
StringCchCat(pszOS, BUFSIZE, "Enterprise Edition for Itanium-based Systems" );
break;
case PRODUCT_SMALLBUSINESS_SERVER:
StringCchCat(pszOS, BUFSIZE, "Small Business Server" );
break;
case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
StringCchCat(pszOS, BUFSIZE, "Small Business Server Premium Edition" );
break;
case PRODUCT_STANDARD_SERVER:
StringCchCat(pszOS, BUFSIZE, "Standard Edition" );
break;
case PRODUCT_STANDARD_SERVER_CORE:
StringCchCat(pszOS, BUFSIZE, "Standard Edition (core installation)" );
break;
case PRODUCT_WEB_SERVER:
StringCchCat(pszOS, BUFSIZE, "Web Server Edition" );
break;
}
if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
StringCchCat(pszOS, BUFSIZE,  ", 64-bit" );
else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL )
StringCchCat(pszOS, BUFSIZE, ", 32-bit");
}

if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
{
if( GetSystemMetrics(SM_SERVERR2) )
StringCchCat(pszOS, BUFSIZE,  "Windows Server 2003 R2, ");
else if ( osvi.wSuiteMask==VER_SUITE_STORAGE_SERVER )
StringCchCat(pszOS, BUFSIZE,  "Windows Storage Server 2003");
else if( osvi.wProductType == VER_NT_WORKSTATION &&
si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
{
StringCchCat(pszOS, BUFSIZE,  "Windows XP Professional x64 Edition");
}
else StringCchCat(pszOS, BUFSIZE, "Windows Server 2003, ");

// Test for the server type.
if ( osvi.wProductType != VER_NT_WORKSTATION )
{
if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 )
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
StringCchCat(pszOS, BUFSIZE,  "Datacenter Edition for Itanium-based Systems" );
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
StringCchCat(pszOS, BUFSIZE,  "Enterprise Edition for Itanium-based Systems" );
}

else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
StringCchCat(pszOS, BUFSIZE,  "Datacenter x64 Edition" );
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
StringCchCat(pszOS, BUFSIZE,  "Enterprise x64 Edition" );
else StringCchCat(pszOS, BUFSIZE,  "Standard x64 Edition" );
}

else
{
if ( osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER )
StringCchCat(pszOS, BUFSIZE,  "Compute Cluster Edition" );
else if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
StringCchCat(pszOS, BUFSIZE,  "Datacenter Edition" );
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
StringCchCat(pszOS, BUFSIZE,  "Enterprise Edition" );
else if ( osvi.wSuiteMask & VER_SUITE_BLADE )
StringCchCat(pszOS, BUFSIZE,  "Web Edition" );
else StringCchCat(pszOS, BUFSIZE,  "Standard Edition" );
}
}
}

if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
{
StringCchCat(pszOS, BUFSIZE, "Windows XP ");
if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
StringCchCat(pszOS, BUFSIZE,  "Home Edition" );
else StringCchCat(pszOS, BUFSIZE,  "Professional" );
}

if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
{
StringCchCat(pszOS, BUFSIZE, "Windows 2000 ");

if ( osvi.wProductType == VER_NT_WORKSTATION )
{
StringCchCat(pszOS, BUFSIZE,  "Professional" );
}
else 
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
StringCchCat(pszOS, BUFSIZE,  "Datacenter Server" );
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
StringCchCat(pszOS, BUFSIZE,  "Advanced Server" );
else StringCchCat(pszOS, BUFSIZE,  "Server" );
}
}

// 32-bit, 64-bit 출력
fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandle("kernel32"),"IsWow64Process");

if(NULL != fnIsWow64Process)
{
fnIsWow64Process(GetCurrentProcess(),&bIsWow64);

if (bIsWow64)
StringCchCat(pszOS, BUFSIZE,  " 64-bit" );
else
StringCchCat(pszOS, BUFSIZE,  " 32-bit" );
}

return TRUE; 
}
else
{
return FALSE;
}
}
=============================================================

Windows 버전 정보 참조:



2011.11.11 11:11 렛츠태그~! 나무그늘~*


현재 시간은 2011년 11월 11일 11시 18분
촬영 시간은 2011년 11월 11일 11시 11분

렛츠태그!!!!!!!!!! >ㅁ <

밖에는 비가 내리고 있는 듯 한데 잘 보이진 않네요.
아침을 못 먹고 와서 다이제와 함께 하고 있습니다. ㅠㅠ
뒤에는 제가 기르고 있는 선인장 황금사.
가운데 녀석이 죽어가고 가에 녀석들이 성장하고 있어요. ㄷㄷ
오늘도 좋은 하루 되기를. 내일은 주말 입니다. 얏호~!! >ㅁ <

64bit 환경에서 system32 -> syswow64 Redirection diable 하기 프로그래밍

32비트 환경에서 만든 프로그램을 64비트 환경에서 실행시킬 때

32비트 프로그램이 system32 폴더로 파일을 복사하게 되면 Windows는 자동으로

syswow64로 redirect 하여 파일을 복사하게 된다.

이를 피하기 위하여 아래와 같은 코드로 redirection을 disable 할 수 있다.

==================================================================

PVOID OldValue;

Wow64DisableWow64FsRedirection(&OldValue);

CopyFile(szSourcePath, szTargetPath, false);

Wow64RevertWow64FsRedirection(OldValue);

==================================================================

system32와 syswow64 폴더에 대한 자세한 내용은 아래 '참조1'을 참조할 것

참조2 : http://www.codeproject.com/tips/55290/Disabling-Windows-file-system-redirection-on-a-CFi.aspx



덧붙여 InstallShield 개발 시에는

OnSetTARGETDIR 부분에 Disable(WOW64FSREDIRECTION); 을 추가하면 된다.




ps. 오랜만에 프로그래밍 카테고리에 글을 올렸더니...... 민망하다 크으... -_-;;;

이제야 쓰는 수영 이야기 $$ 도전 $$

작년 가을 쯤 운동할 거리를 찾다가 수영을 시작했다.
처음에 집 근처 수영장을 찾아보고 가격을 알아봤는데.. 헉!! 1개월에 8~9만원씩 이었다.
그러다 하숙집 주인분을 통해 알게된 마포평생학습관 수영장은 무려 3개월에 6만원 후반대였다. +_+)!
그래서 작년 10월부터 수영을 처음 배우기 시작하여 어느 덧 6개월을 넘겼다.
화, 목, 토요일 아침 6시 20분부터 7시 20분까지였는데, 미리 샤워할 것을 생각해서 6시 쯤 도착하려면
적어도 집에서 5시 50분에는 출발해야 했고, 그럼 일어나는 시각은... 뭐 그렇다. ㅠㅠ


이어지는 내용

2010년 내 이글루 결산 나무그늘~*

포스트 (23개)

 914220311000 
 1월2월3월4월5월6월7월8월9월10월11월12월 

덧글 (0개)

한 해 동안 작성한 덧글이 없습니다.

트랙백 (0개)

한 해 동안 받은 트랙백이 없습니다.

핑백 (5개)

 500000000000 
 1월2월3월4월5월6월7월8월9월10월11월12월 

2009-2010 포스트 수 비교 (2009년 포스트: 37개)2009 2009  2010 2010

 1094174121210132161301000 
 1월2월3월4월5월6월7월8월9월10월11월12월 

내가 보낸 글 통계 (94개)

 8740255 
 테마태그가든보낸트랙백보낸핑백블로거뉴스 

명예의 전당

1년 동안 작성한 글

200자 원고지 기준으로 1,050장 분량이며, 원고 두께는 약 7cm 입니다.
1년 동안의 글을 문고판 시리즈로 낸다면 5권까지 낼 수 있겠네요.
푸른나무 님은 올 한해 이글루스에서 35,433 번째로 게시물을
가장 많이 작성하셨네요

자주 등록한 태그 & 대표 글 TOP3

 드래곤케이브 (6회) | 
 보이스블로깅 (6회) | 

자주 발행한 밸리 & 대표 글 TOP 3

내 이글루 인기 글



이것 참... 올해는 SNS에 빠져 지내느라 블로그는 신경을 많이 못썼네요.
내년엔 좀 더 알찬(?) 블로그가 되도록 노력해야겠습니다.
올 한 해도 이 누추한 얼음집을 방문해 주신 분들께 감사드립니다. ^^

1 2 3 4 5 6 7 8 9 10 다음



영어단어

YES24