Ejemplo n.º 1
0
void ALog::AddViewer(AViewer* viewer)
{
	ASSERT(viewer != NULL);
	BOOL bFirstTime = FALSE;
	if (m_pViewer == NULL)
	{
		bFirstTime = TRUE;
		m_pViewer = new MultiViewer;
	}
	m_pViewer->AddViewer(viewer);
	if (bFirstTime)
	{
		SYSTEMTIME t;
		::GetLocalTime(&t);
		TCHAR bf[300];
		_sntprintf(bf, 200, _T("@@ ------Start Logging: %d-%d-%d %0.2d:%0.2d:%0.2d .%0.3dms\r\n"),
			t.wDay, t.wMonth, t.wYear, t.wHour, t.wMinute, t.wSecond,  t.wMilliseconds);
		Log(bf);
		OSVERSIONINFO osVer;
		osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
		GetVersionEx(&osVer);
		_sntprintf(bf, 200, _T("@@ VersionInfo: %d.%d.%d\r\n"), osVer.dwMajorVersion, osVer.dwMinorVersion, osVer.dwBuildNumber);
		Log(bf);
		MEMORYSTATUS memStat;
		GlobalMemoryStatus (&memStat);
		Log(_T("@@ MemInfo: %d / %d (MB)\r\n"), memStat.dwAvailPhys/1024/1024, memStat.dwTotalPhys/1024/1024);
		GetWindowsDirectory(bf, MAX_PATH);
		Log(_T("@@ <WINDIR>: %s\r\n"), bf);
		Log(_T("@@ SysDefLangID: %d\r\n"), GetSystemDefaultLangID());
		Log(_T("@@ ---\r\n"));
	}
	else
		Log(_T("@@ New Viewer Added\r\n"));
}
Ejemplo n.º 2
0
int set_lang(void)
{
	unsigned int lang_usr,lang_sys,id;

	id=GetSystemDefaultLangID();
	lang_sys=PRIMARYLANGID(id);
	id=GetUserDefaultLangID();
	lang_usr=PRIMARYLANGID(id);
	if(lang_usr!=lang_sys) {
		printf("warning: user language differs from system language\r\n\r\n");
		printf("1. system : ");print_lang(lang_sys);
		printf("2. user   : "******"Select(1-2): ");
		id=getch();
	if(id!=49&&id!=50) {
		printf("wrong choice '%c', leaving.\r\n",id);
		exit(0);
		}
	if(id==49) {
		printf("system language\r\n");
		return lang_sys;
		}
	else
		printf("user language\r\n");
	}
	return lang_usr;
}
Ejemplo n.º 3
0
BOOL CFlashInterface::OnInitDialog()
{
	CurLangID = STANDARD_LANGID;
	HKEY hKey;
  	DWORD language;
    LONG returnStatus;
	DWORD Type=REG_DWORD;
    DWORD Size=sizeof(DWORD);
    returnStatus = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\CamStudioOpenSource for Nick\\vscap\\Language", 0L, KEY_ALL_ACCESS, &hKey);

	if (returnStatus == ERROR_SUCCESS)
    {

        returnStatus = RegQueryValueEx(hKey, "LanguageID", NULL, &Type,(LPBYTE)&language, &Size);

		if (returnStatus == ERROR_SUCCESS)
        {

        	if ( !LoadLangIDDLL((int) language) )
	         if ( !LoadLangIDDLL(GetUserDefaultLangID()) )
     			LoadLangIDDLL(GetSystemDefaultLangID());
        }
     }

    RegCloseKey(hKey);

	CPropertyPage::OnInitDialog();

	int valset = int(percentLoadedThreshold * 100.0);
	if (valset > 100) valset = 100;
	if (valset < 10) valset = 10;

	UDACCEL acc[2];
    acc[0].nSec = 1;
    acc[0].nInc = 5;

	acc[1].nSec = 3;
    acc[1].nInc = 10;

	((CSpinButtonCtrl *) GetDlgItem(IDC_SPIN1))->SetBuddy(GetDlgItem(IDC_PRELOADPERCENT));
	((CSpinButtonCtrl *) GetDlgItem(IDC_SPIN1))->SetRange(10,100);
	((CSpinButtonCtrl *) GetDlgItem(IDC_SPIN1))->SetPos(valset);
	((CSpinButtonCtrl *) GetDlgItem(IDC_SPIN1))->SetAccel(2,acc);

	// TODO: Add extra initialization here
	((CEdit *)GetDlgItem(IDC_PRELOADBITMAP))->SetWindowText(loadingPath);

	local_swfbk_red = swfbk_red;
	local_swfbk_green = swfbk_green;
	local_swfbk_blue = swfbk_blue;

	CString foxStr,foyStr;
	foxStr.Format("%d",FrameOffsetX);
	foyStr.Format("%d",FrameOffsetY);
	((CEdit *) GetDlgItem(IDC_FRAMEOFFSETX))->SetWindowText(foxStr);
	((CEdit *) GetDlgItem(IDC_FRAMEOFFSETY))->SetWindowText(foyStr);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 4
0
int GetSysLangLoadLang()
{
	LANGID SysLangID = GetSystemDefaultLangID();
	int iRet = LoadLanguageBaseID(SysLangID);
	
	
	return iRet;
}
Ejemplo n.º 5
0
	bool getCodePageInfo(int codepage, CodePageInfo *pCodePageInfo)
	{
		MIMECPINFO mcpi = {0};
		HRESULT hr = m_pmlang->GetCodePageInfo(codepage, GetSystemDefaultLangID(), &mcpi);
		if (FAILED(hr))
			return false;
		pCodePageInfo->fixedWidthFont = ucr::toTString(mcpi.wszFixedWidthFont);
		pCodePageInfo->bGDICharset = mcpi.bGDICharset;
		return true;
	}
Ejemplo n.º 6
0
	bool getCodepageDescription(int codepage, String& sDescription)
	{
		wchar_t szDescription[256];
		HRESULT hr = m_pmlang->GetCodePageDescription(codepage, GetSystemDefaultLangID(), szDescription, sizeof(szDescription)/sizeof(wchar_t));
		if (FAILED(hr))
			return false;

		sDescription = ucr::toTString(szDescription);
		return true;
	}
Ejemplo n.º 7
0
/*++
Function:
  GetUserDefaultLangID

See MSDN doc.
--*/
LANGID
PALAPI
GetUserDefaultLangID(
             void)
{
    LANGID langID = (LANGID)0; /* return value */
    ENTRY("GetUIserDefaultLangID()\n");
    langID = GetSystemDefaultLangID();
    LOGEXIT("GetSystemDefaultLangID returns LANGID %x\n", langID);
    return langID;
}
Ejemplo n.º 8
0
////////////////////////////////////////////////////////////////////////////////
// GetMesageDll -- find and load the message DLL. Returns 0 if the message
// DLL could not be located or loaded. The message DLL should be either in a 
// subdirectory whose name is a language id, or in the current directory. We have
// a complex set of rules to figure out which language ids to try.
HINSTANCE WINAPI GetALinkMessageDll ()
{
    LANGID langid;

    if (! hModuleMessages) {
        HINSTANCE hModuleMessagesLocal = 0;


        // Next try current locale.
        if (!hModuleMessagesLocal) {
            langid = LANGIDFROMLCID(GetThreadLocale());
            hModuleMessagesLocal = FindMessageDll(langid);
            if (!hModuleMessagesLocal)
                hModuleMessagesLocal = FindMessageDll(MAKELANGID(PRIMARYLANGID(langid), SUBLANG_DEFAULT));
        }

        // Next try user and system locale.
        if (!hModuleMessagesLocal) {
            langid = GetUserDefaultLangID();
            hModuleMessagesLocal = FindMessageDll(langid);
        }
        if (!hModuleMessagesLocal) {
            langid = GetSystemDefaultLangID();
            hModuleMessagesLocal = FindMessageDll(langid);
        }

        // Next try current directory.
        if (!hModuleMessagesLocal) 
            hModuleMessagesLocal = FindMessageDll((LANGID)-1);

        // Try a fall-back list of locales.
        if (!hModuleMessagesLocal) {
            for (unsigned int i = 0; i < lengthof(g_fallbackLangs); ++i) {
                langid = g_fallbackLangs[i];
                hModuleMessagesLocal = FindMessageDll(langid);
                if (hModuleMessagesLocal)
                    break;
            }
        }

        if (hModuleMessagesLocal)
        {
            if (InterlockedCompareExchangePointer( (void**)&hModuleMessages, hModuleMessagesLocal, NULL)) {
                ASSERT(hModuleMessages != hModuleMessagesLocal);
                PAL_FreeSatelliteResource(hModuleMessagesLocal);
            } else
                ASSERT(hModuleMessagesLocal == hModuleMessages);
        }

    }
    return hModuleMessages;
}
Ejemplo n.º 9
0
CMediaInfoDlg::CMediaInfoDlg()
{
	LANGID   _SysLangId   =   GetSystemDefaultLangID();

	if(PRIMARYLANGID(_SysLangId)   ==   LANG_CHINESE) {
		if(SUBLANGID(_SysLangId)   ==   SUBLANG_CHINESE_SIMPLIFIED)
			codepage = 936;		//Simplified Chinese GBK
		else if(SUBLANGID(_SysLangId)   ==   SUBLANG_CHINESE_TRADITIONAL)
			codepage = 950;		//Traditional Chinese Big5
		else if(SUBLANGID(_SysLangId)   ==   SUBLANG_CHINESE_HONGKONG)
			codepage = 950;		//Traditional Chinese Big5
	} else if(PRIMARYLANGID(_SysLangId)   ==   LANG_JAPANESE)
		codepage = 932;			//Japanese Shift-JIS
	else if(PRIMARYLANGID(_SysLangId)   ==   LANG_KOREAN)
		codepage = 949;			//Korean

	m_wndListCtrl.RegisterClass();
}
Ejemplo n.º 10
0
int __cdecl main(int argc, char *argv[])
{    

    LCID lcid;
    LANGID LangID;

    if (PAL_Initialize(argc, argv))
    {
        return FAIL;
    }

    LangID = GetSystemDefaultLangID();
    if (LangID == 0)
    {
        Fail("GetSystemDefaultLangID failed!\n");
    }

    /* Try using the langid (with default sort) as a locale */
    if (!SetThreadLocale(MAKELCID(LangID, SORT_DEFAULT)))
    {
        Fail("Unable to use GetSystemDefaultLangID as a locale!\n");
    }
    lcid = GetThreadLocale();
    if (!IsValidLocale(lcid, LCID_INSTALLED))
    {
        Fail("Unable to use GetSystemDefaultLangID as a locale!\n");
    }

    /* Make sure results consistent with using LOCALE_USER_DEFAULT */
    if (!SetThreadLocale(LOCALE_USER_DEFAULT))
    {
        Fail("Unexpected error testing GetSystemDefaultLangID!\n");
    }
    if (GetThreadLocale() != lcid)
    {
        Fail("Results from GetSystemDefaultLangID inconsistent with "
            "LOCALE_USER_DEFAULT!\n");
    }

    PAL_Terminate();

    return PASS;
}
Ejemplo n.º 11
0
LANGID CMultiLanguage::DetectLangID()
{
    LANGID langid = 0;
    int nPrimaryLang = 0;
    int nSubLang = 0;
    LCID lcid = 0;
    int nLocales = 0;

    langid = GetUserDefaultLangID();    // WinNT3.1/95 and later
    AddLangId( langid );
    TRACE(_T("CMultiLanguage::GetUserDefaultLangID() 1st/2nd = %0X\n"),
          langid );

    LANGID langSysid = GetSystemDefaultLangID();    // WinNT3.1/95 and later
    AddLangId( langSysid );
    TRACE(_T("CMultiLanguage::GetSystemDefaultLangID() 3rd/4th = %0X\n"),
          langid );

    return langid;
}
Ejemplo n.º 12
0
void procAutoLocale()
{
    LANGID currentUIL = GetSystemDefaultLangID();

    const char* convLoc = NULL;

    switch( currentUIL & 0xFF )
    {
        case LANG_KOREAN:
            convLoc = "korean";
            reffntshape = "Malgun Gothic";
            break;

        case LANG_JAPANESE:
            convLoc = "japanese";
            reffntshape = "Meiryo";
            break;

        case LANG_CHINESE_SIMPLIFIED:
            convLoc = "chinese-simplified";
            reffntshape = "Microsoft YaHei";
            break;

        case LANG_CHINESE_TRADITIONAL:
            convLoc = "chinese-traditional";
            reffntshape = "Microsoft JhengHei";
            break;

        default:
            convLoc = "C";
            reffntshape = "Tahoma";
            break;
    }

#ifdef DEBUG
    printf( "current LANG ID = %08X ( %d ), locale = %s\n",
            currentUIL, currentUIL, convLoc );
#endif // DEBUG

    setlocale( LC_ALL, convLoc );
}
Ejemplo n.º 13
0
// ----------------------------------------------------------------------------
// ---------- CChatViewerFont
// ----------------------------------------------------------------------------
CChatViewerFont::CChatViewerFont()
{
	name         = "Courier";
	size         = 10;
	codepage     = 0;
	characterSet = 1;
	if ( PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_RUSSIAN ) {
		characterSet = RUSSIAN_CHARSET;
	}

	HFONT hf = (HFONT)::GetStockObject( SYSTEM_FIXED_FONT );
	if ( hf ) {
		CFont* f = CFont::FromHandle( hf );
		if ( f ) {
			LOGFONT lf;
			f->GetLogFont( &lf );
			name         = lf.lfFaceName;
			characterSet = lf.lfCharSet;
		}
	}
}
Ejemplo n.º 14
0
int
PALAPI
GetDateFormatW(
           IN LCID Locale,
           IN DWORD dwFlags,
           IN CONST SYSTEMTIME *lpDate,
           IN LPCWSTR lpFormat,
           OUT LPWSTR lpDateStr,
           IN int cchDate)
{
    LCID localeID = (LCID)0;
    WCHAR GG_string[] = {'g','g','\0'};


    localeID = MAKELCID(GetSystemDefaultLangID(), SORT_DEFAULT);

    ENTRY("GetDateFormatW(Locale=%#x, dwFlags=%#x, lpDate=%p, lpFormat=%p (%S), "
          "lpDateStr=%p, cchDate=%d)\n",
          Locale, dwFlags, lpDate, lpFormat ? lpFormat : W16_NULLSTRING, lpFormat ? lpFormat : W16_NULLSTRING,
          lpDateStr, cchDate);

    /* The implementation of this function is not reqd as of now
     *as this is called only for CAL_TAIWAN Calendar and we are supporting
     *only CAL_GREGORIAN*/
    if(((Locale == localeID) || (Locale == 0x0404)) && (dwFlags & DATE_USE_ALT_CALENDAR) && (lpDate == NULL)
       && lpFormat ? (PAL_wcsncmp(lpFormat, GG_string, PAL_wcslen(lpFormat)) == 0) : FALSE)
    {
        /*Need to make a call to strftime() with appropriate params when functionality
          to use alternate calendars is implemented */
        ERROR("Not Implemented\n");
    }
    else
    {
        ASSERT("One of the input parameters is invalid\n");
        SetLastError(ERROR_INVALID_PARAMETER);
    }
    LOGEXIT ("GetDateFormatW returns int 0\n");

    return 0;
}
Ejemplo n.º 15
0
void GetLanguageID()
{
	LANGID   _SysLangId   =   GetSystemDefaultLangID();

	if(PRIMARYLANGID(_SysLangId)   ==   LANG_CHINESE)
	{
		if(SUBLANGID(_SysLangId)   ==   SUBLANG_CHINESE_SIMPLIFIED)
			sys_language_id = 936;		//Simplified Chinese GBK
		else if(SUBLANGID(_SysLangId)   ==   SUBLANG_CHINESE_TRADITIONAL)
			sys_language_id = 950;		//Traditional Chinese Big5
		else if(SUBLANGID(_SysLangId)   ==   SUBLANG_CHINESE_HONGKONG)
			sys_language_id = 950;		//Traditional Chinese Big5
		else
			sys_language_id = CP_ACP;		//ANSI
	}
	else if(PRIMARYLANGID(_SysLangId)   ==   LANG_JAPANESE)
		sys_language_id = 932;			//Japanese Shift-JIS
	else if(PRIMARYLANGID(_SysLangId)   ==   LANG_KOREAN)
		sys_language_id = 949;			//Korean
	else
		sys_language_id = CP_ACP;			//ANSI
}
Ejemplo n.º 16
0
void log_system_data(void)
{
	char buf[256];
	unsigned int langid,lcid,size=80;
	char systemdir[256],windir[256],cdir[256],user[256],computer[256];

	langid=GetSystemDefaultLangID();
	lcid=GetSystemDefaultLCID();

	GetSystemDirectory(systemdir,80);
        GetWindowsDirectory(windir,80);
	GetCurrentDirectory(80,cdir);
	GetUserName((void*)user,&size); size=80;
	GetComputerName((void*)computer,&size);

	sprintf(buf,"|langid=%u, lcid=%u",langid,lcid); say(buf);
	sprintf(buf,"|systemdir=\"%s\"",systemdir); say(buf);
	sprintf(buf,"|windowsdir=\"%s\"",windir); say(buf);
	sprintf(buf,"|currentdir=\"%s\"",cdir); say(buf);
	sprintf(buf,"|username=\"%s\"",user); say(buf);
	sprintf(buf,"|computername=\"%s\"",computer); say(buf);
}
Ejemplo n.º 17
0
BOOL CMEditor2App::InitInstance()
{
	// 如果一个运行在 Windows XP 上的应用程序清单指定要
	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
	//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// 将它设置为包括所有要在应用程序中使用的
	// 公共控件类。
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	AfxEnableControlContainer();

	SetRegistryKey(_T("MEditor2 - MPlayer 首选项"));

	CString   sCmdLine(this->m_lpCmdLine);
	int OpenType = 0;
	CString ProgramName;
	CString program_dir;
	TCHAR szFilePath[MAX_PATH + 1];
	GetModuleFileName(NULL, szFilePath, MAX_PATH);
	ProgramName.Format(_T("%s"),szFilePath);
	ProgramName = ProgramName.Right(15);
	ProgramName.MakeLower();
	(_tcsrchr(szFilePath, _T('\\')))[1] = 0;
	program_dir.Format(_T("%s"),szFilePath);

	if(sCmdLine.Find(_T("Open Editor")) >= 0 ||
		sCmdLine.Find(_T("--open-ontop")) >= 0)
		OpenType = 3;

	CString langfile_tc;
	CString langfile_en;

	if(IsFileExist(program_dir + _T("tools\\meditor2.tc.dll")))
		langfile_tc = program_dir + _T("tools\\meditor2.tc.dll");
	if(IsFileExist(program_dir + _T("tools\\meditor2.en.dll")))
		langfile_en = program_dir + _T("tools\\meditor2.en.dll");
	if(IsFileExist(program_dir + _T("codecs\\meditor2.tc.dll")))
		langfile_tc = program_dir + _T("codecs\\meditor2.tc.dll");
	if(IsFileExist(program_dir + _T("codecs\\meditor2.en.dll")))
		langfile_en = program_dir + _T("codecs\\meditor2.en.dll");
	if(IsFileExist(program_dir + _T("meditor2.tc.dll")))
		langfile_tc = program_dir + _T("meditor2.tc.dll");
	if(IsFileExist(program_dir + _T("meditor2.en.dll")))
		langfile_en = program_dir + _T("meditor2.en.dll");

	if(langfile_tc.GetLength()>1 || langfile_en.GetLength()> 1) {
		AppLanguage = GetPrivateProfileInt(_T("Option"),_T("Language"), 0, program_dir + _T("kk.ini"));
		if(AppLanguage == 0) {
			LANGID   _SysLangId = GetSystemDefaultLangID();
			if(PRIMARYLANGID(_SysLangId)   ==   LANG_CHINESE) {
				if(SUBLANGID(_SysLangId)   ==   SUBLANG_CHINESE_SIMPLIFIED)
					AppLanguage = 1;		//Simplified Chinese GBK
				else if(SUBLANGID(_SysLangId)   ==   SUBLANG_CHINESE_TRADITIONAL)
					AppLanguage = 4;		//Traditional Chinese Big5
				else
					AppLanguage = 3;		//ANSI
			} else
				AppLanguage = 2;			//ANSI
		}
	}

	CString strSatellite = _T("");
	if(AppLanguage == 2 && langfile_en.GetLength() > 1)
		strSatellite = langfile_en;
	else if((AppLanguage == 3 || AppLanguage == 4) && langfile_tc.GetLength() > 1)
		strSatellite = langfile_tc;

	hResourceHandleOld = NULL;
	hResourceHandleMod = NULL;
	if (strSatellite.GetLength() > 2) {
		hResourceHandleOld = AfxGetResourceHandle();
		hResourceHandleMod = LoadLibrary(strSatellite);
		if (hResourceHandleMod)
			AfxSetResourceHandle(hResourceHandleMod);
	}

	CMEditor2Dlg dlg;
	m_pMainWnd = &dlg;
	dlg.m_OpenType = OpenType;
	INT_PTR nResponse = dlg.DoModal();

	if (hResourceHandleMod)
		FreeLibrary(hResourceHandleMod);

	if (nResponse == IDOK)
	{
		//  “确定”来关闭对话框的代码
	}
	else if (nResponse == IDCANCEL)
	{
		//  “取消”来关闭对话框的代码
	}
	return FALSE;
}
BOOL SSTP_Aviutl( HWND hWnd, LPCTSTR lpTitle )
{
#define SSTP_AVIUTL_BUF_SIZE 1024

	if( lstrlen( lpTitle ) > SSTP_AVIUTL_BUF_SIZE / 2 ) return FALSE;

	if( LANG_JAPANESE != PRIMARYLANGID( GetSystemDefaultLangID() ) ) return FALSE;

	SYSTEMTIME st;
	GetSystemTime( &st );
	if( (int) st.wMilliseconds > 350 ) return FALSE;


	char lpSjisStr[ SSTP_AVIUTL_BUF_SIZE ] = "";
	char lpSjisSakuraScript[ SSTP_AVIUTL_BUF_SIZE ] = "";

#ifdef _UNICODE
	BOOL bError = FALSE;
	WideCharToMultiByte(
		CP_SJIS,
		WC_NO_BEST_FIT_CHARS,
		lpTitle,
		-1,
		lpSjisStr,
		SSTP_AVIUTL_BUF_SIZE,
		"",
		&bError
	);
	if( bError ) return FALSE;
#else
	lstrcpyA( lpSjisStr, lpTitle );
#endif


	char * p = strchr( lpSjisStr, '%' );
	char * q = NULL;
	if( p == NULL )
	{
		int len = strlen( lpSjisStr );
		p = strstr( lpSjisStr, " (" );
		if( p == NULL ) return FALSE;
		*p = '\0';
		if( lstrlenA( lpSjisStr ) == len ) return FALSE;
		q = strchr( p + 1 , '/' );
		if( q == NULL ) return FALSE;

		int iFrames = atoi( q + 1 );
		if( iFrames == 0 ) return FALSE;
		int s1 = (int) floor( iFrames * 1001.0 / 30000.0 );
		int m1 = s1 / 60;
		s1 -= ( m1 * 60 );
		int s2 = (int) floor( iFrames * 1001.0 / 24000.0 );
		int m2 = s2 / 60;
		s2 -= ( m2 * 60 );
		sprintf( lpSjisSakuraScript, SSTP_AVIUTL_0, lpSjisStr, iFrames,
			m1, s1, m2, s2
		);
	}
	else
	{
		p = strstr( lpSjisStr, "] " );
		if( p == NULL ) return FALSE;
		q = strchr( lpSjisStr, '/' );
		if( q == NULL )	return FALSE;

		int iFrames = atoi( q + 1 );
		if( iFrames == 0 ) return FALSE;
		sprintf( lpSjisSakuraScript, SSTP_AVIUTL_1, p + 2, iFrames );
	}
	
	return DirectSSTP( hWnd, lpSjisSakuraScript );
}
BOOL ReadIni()
{
	TCHAR lpszPath[ MAX_PATH * 2 ];
	GetIniPath( lpszPath );

	g_bLogging = !! GetPrivateProfileInt( TEXT( "Options" ), TEXT( "Logging" ), FALSE, lpszPath );
	EnableLoggingIni( g_bLogging );


	g_bSelChange = !! GetPrivateProfileInt( TEXT( "Options" ), TEXT( "SelChange" ), FALSE, lpszPath );

//0x04 	LANG_CHINESE
//0x01 	SUBLANG_CHINESE_TRADITIONAL 	Chinese (Traditional)
//0x02 	SUBLANG_CHINESE_SIMPLIFIED 	Chinese (Simplified)
//	WORD wDefLanguage = (WORD) PRIMARYLANGID( GetSystemDefaultLangID() );
	WORD wDefLanguage = (WORD) PRIMARYLANGID( GetUserDefaultLangID() );
	

	if( wDefLanguage == LANG_CHINESE )
	{
		WORD wSubLangId = (WORD) SUBLANGID( GetSystemDefaultLangID() );
		wDefLanguage = ( wSubLangId == SUBLANG_CHINESE_TRADITIONAL )? LANG_CHINESE_T : LANG_CHINESE_S ;
	}
	else if( wDefLanguage != LANG_ENGLISH && wDefLanguage != LANG_FINNISH && wDefLanguage != LANG_JAPANESE
		&& wDefLanguage != LANG_SPANISH )
	{
		wDefLanguage = LANG_ENGLISH;
	}

	WORD wLanguage = (WORD) GetPrivateProfileInt( TEXT( "Options" ), TEXT( "Language" ), (int) wDefLanguage, lpszPath );

	if( wLanguage != LANG_ENGLISH && wLanguage != LANG_FINNISH && wLanguage != LANG_JAPANESE && wLanguage != LANG_JAPANESEo
		&& wLanguage != LANG_CHINESE_T && wLanguage != LANG_CHINESE_S && wDefLanguage != LANG_SPANISH
		&& wLanguage != LANG_FRENCH )
	{
		wLanguage = wDefLanguage;
	}
	
	SetLanguage( wLanguage );

	g_Slider[ 0 ] = (BYTE) 33;
	g_Slider[ 1 ] = (BYTE) 33;
	g_Slider[ 2 ] = (BYTE) 33;
	g_Slider[ 3 ] = (BYTE) 0;

	int i, j;
	TCHAR lpszKey[ 100 ];
	g_iEnemyIndex = 0;
	for( i = 0; i < MAX_PROCESS_CNT; i++ )
	{
		wsprintf( lpszKey, TEXT( "Enemy%d" ), i );
		GetPrivateProfileString(
			TEXT( "Enemy" ),
			lpszKey,
			TEXT( "" ),
			g_lpszEnemy[ g_iEnemyIndex ],
			MAX_PATH + 1,
			lpszPath
		);
		if( lstrlen( g_lpszEnemy[ g_iEnemyIndex ] ) == 0 ) break;
		else if( IsAbsFoe( g_lpszEnemy[ g_iEnemyIndex ] ) ) continue;
		else if( _tcschr( g_lpszEnemy[ g_iEnemyIndex ], TEXT( '\\' ) ) != NULL ) continue;

		PathToExeEx( g_lpszEnemy[ g_iEnemyIndex ], MAX_PATH + 1 );

		for( j = 0; j < g_iEnemyIndex; j++ )
		{
			if( lstrcmpi( g_lpszEnemy[ j ], g_lpszEnemy[ g_iEnemyIndex ] ) == 0 ) goto NEXT_FOE;
		}

		g_iEnemyIndex++;

		NEXT_FOE:
		{
			;
		}
	}

	g_iFriendIndex = 0;
	for( i = 0; i < MAX_PROCESS_CNT; i++ )
	{
		wsprintf( lpszKey, TEXT( "Friend%d" ), i );
		GetPrivateProfileString(
			TEXT( "Friend" ),
			lpszKey,
			TEXT( "" ),
			g_lpszFriend[ g_iFriendIndex ],
			MAX_PATH + 1,
			lpszPath
		);
	
		if( lstrlen( g_lpszFriend[ g_iFriendIndex ] ) == 0 ) break;
		else if( IsAbsFoe( g_lpszEnemy[ g_iFriendIndex ] ) ) continue;
		else if( _tcschr( g_lpszEnemy[ g_iFriendIndex ], TEXT( '\\' ) ) != NULL ) continue;

		PathToExeEx( g_lpszFriend[ g_iFriendIndex ], MAX_PATH + 1 );

		for( j = 0; j < g_iFriendIndex; j++ )
		{
			if( lstrcmpi( g_lpszFriend[ j ], g_lpszFriend[ g_iFriendIndex ] ) == 0 ) goto NEXT_FRIEND;
		}
		for( j = 0; j < g_iEnemyIndex; j++ )
		{
			if( lstrcmpi( g_lpszEnemy[ j ], g_lpszFriend[ g_iFriendIndex ] ) == 0 ) goto NEXT_FRIEND;
		}

		g_iFriendIndex++;

		NEXT_FRIEND:
		{
			;
		}
	}
	return TRUE;
}
Ejemplo n.º 20
0
khm_int32
kmmint_read_module_info(kmm_module_i * m) {
    /* the only fields we can count on at this point are m->name and
       m->path */
    DWORD t;
    size_t cb;
    WORD lang;
    khm_int32 rv = KHM_ERROR_SUCCESS;
    struct lang_code *languages;
    int n_languages;
    int i;
    wchar_t resname[256];       /* the resource names are a lot shorter */
    wchar_t * r;
    VS_FIXEDFILEINFO *vff;
    UINT c;

    assert(m->name);
    assert(m->path);

    t = TRUE;
    cb = GetFileVersionInfoSize(m->path,
                                &t);
    /* if successful, cb gets the size in bytes of the version info
       structure and sets t to zero */
    if (t) {
        return KHM_ERROR_NOT_FOUND;
    } else if (cb == 0) {
        _report_mr1(KHERR_WARNING, MSG_RMI_NOT_FOUND, _dupstr(m->path));
        return KHM_ERROR_INVALID_PARAM;
    }

    if (m->version_info) {
        PFREE(m->version_info);
        m->version_info = NULL;
    }

    m->version_info = PMALLOC(cb);
#ifdef DEBUG
    assert(m->version_info);
#endif

    if(!GetFileVersionInfo(m->path,
                           t, (DWORD) cb, m->version_info)) {
        rv = KHM_ERROR_NOT_FOUND;
        _report_mr1(KHERR_WARNING, MSG_RMI_NOT_FOUND, _dupstr(m->path));
        _location(L"GetFileVersionInfo");
        goto _cleanup;
    }

    if(!VerQueryValue(m->version_info,
                     L"\\VarFileInfo\\Translation",
                     (LPVOID*) &languages,
                     &c)) {
        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr1(KHERR_WARNING, MSG_RMI_NO_TRANS, _dupstr(m->path));
        _location(L"VerQueryValue");
        goto _cleanup;
    }

    n_languages = (int) (c / sizeof(*languages));

    /* Try searching for the user's default language first */
    lang = GetUserDefaultLangID();
    for (i = 0; i < n_languages; i++) {
        if(languages[i].language == lang)
            break;
    }

    /* If not, try the system default */
    if (i >= n_languages) {
        lang = GetSystemDefaultLangID();
        for (i=0; i<n_languages; i++)
            if (languages[i].language == lang)
                break;
    }

    /* Then try EN_US */
    if (i >= n_languages) {
        lang = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);
        for (i=0; i<n_languages; i++)
            if (languages[i].language == lang)
                break;
    }

    /* Language neutral? */
    if (i >= n_languages) {
        lang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
        for (i=0; i<n_languages; i++)
            if (languages[i].language == lang)
                break;
    }

    /* Just use the first one? */
    if (i >= n_languages) {
        i = 0;
    }

    if (i >= n_languages) {
        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr0(KHERR_WARNING, MSG_RMI_NO_LOCAL);
        goto _cleanup;
    }

    /* check module name */
    StringCbPrintf(resname, sizeof(resname),
                   L"\\StringFileInfo\\%04x%04x\\" TEXT(NIMV_MODULE),
                   languages[i].language,
                   languages[i].codepage);

    if (!VerQueryValue(m->version_info,
                       resname, (LPVOID *) &r, &c)) {
        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, 
                    _cstr(TEXT(NIMV_MODULE)));
        goto _cleanup;
    }

    if (c > KMM_MAXCB_NAME ||
        FAILED(StringCbLength(r, KMM_MAXCB_NAME, &cb))) {
        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,
                    _cstr(TEXT(NIMV_MODULE)));
        goto _cleanup;
    }

    if (wcscmp(r, m->name)) {
        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr2(KHERR_WARNING, MSG_RMI_MOD_MISMATCH,
                    _dupstr(r), _dupstr(m->name));
        goto _cleanup;
    }

    /* check API version */
    StringCbPrintf(resname, sizeof(resname),
                   L"\\StringFileInfo\\%04x%04x\\" TEXT(NIMV_APIVER),
                   languages[i].language,
                   languages[i].codepage);

    if (!VerQueryValue(m->version_info,
                       resname, (LPVOID *) &r, &c)) {
        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, 
                    _cstr(TEXT(NIMV_APIVER)));
        goto _cleanup;
    }

    if (c > KMM_MAXCB_NAME ||
        FAILED(StringCbLength(r, KMM_MAXCB_NAME, &cb))) {
        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,
                    _cstr(TEXT(NIMV_APIVER)));
        goto _cleanup;
    }

    t = wcstol(r, NULL, 10);

    rv = kmmint_check_api_version(t);

    if (KHM_FAILED(rv)) {
        _report_mr2(KHERR_WARNING, MSG_RMI_API_MISMATCH,
                    _int32(t), _int32(KH_VERSION_API));
        goto _cleanup;
    }

    /* Looks good.  Now load the description, copyright, support URI
       and file versions */
    if (m->description) {
        PFREE(m->description);
        m->description = NULL;
    }

    StringCbPrintf(resname, sizeof(resname),
                   L"\\StringFileInfo\\%04x%04x\\FileDescription",
                   languages[i].language,
                   languages[i].codepage);

    if (!VerQueryValue(m->version_info,
                       resname, (LPVOID *) &r, &c)) {
        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, 
                    _cstr(L"FileDescription"));
        goto _cleanup;
    }

    if (c > KMM_MAXCB_DESC ||
        FAILED(StringCbLength(r, KMM_MAXCB_DESC, &cb))) {
        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,
                    _cstr(L"FileDescription"));
        goto _cleanup;
    }

    cb += sizeof(wchar_t);

    m->description = PMALLOC(cb);
#ifdef DEBUG
    assert(m->description);
#endif
    StringCbCopy(m->description, cb, r);

    /* on to the support URI */
    if (m->support) {
        PFREE(m->support);
        m->support = NULL;
    }

    StringCbPrintf(resname, sizeof(resname),
                   L"\\StringFileInfo\\%04x%04x\\" TEXT(NIMV_SUPPORT),
                   languages[i].language,
                   languages[i].codepage);

    if (!VerQueryValue(m->version_info,
                       resname, (LPVOID *) &r, &c)) {
        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,
                    _cstr(TEXT(NIMV_SUPPORT)));
        goto _cleanup;
    }

    if (c > KMM_MAXCB_SUPPORT ||
        FAILED(StringCbLength(r, KMM_MAXCB_SUPPORT, &cb))) {
        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,
                    _cstr(TEXT(NIMV_SUPPORT)));
        goto _cleanup;
    }

    cb += sizeof(wchar_t);

    m->support = PMALLOC(cb);
#ifdef DEBUG
    assert(m->support);
#endif
    StringCbCopy(m->support, cb, r);

    /* the vendor/copyright */
    if (m->vendor) {
        PFREE(m->vendor);
        m->vendor = NULL;
    }

    StringCbPrintf(resname, sizeof(resname),
                   L"\\StringFileInfo\\%04x%04x\\LegalCopyright",
                   languages[i].language,
                   languages[i].codepage);

    if (!VerQueryValue(m->version_info,
                       resname, (LPVOID *) &r, &c)) {
        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, 
                    _cstr(L"LegalCopyright"));
        goto _cleanup;
    }

    if (c > KMM_MAXCB_SUPPORT ||
        FAILED(StringCbLength(r, KMM_MAXCB_SUPPORT, &cb))) {
        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,
                    _cstr(L"LegalCopyright"));
        goto _cleanup;
    }

    cb += sizeof(wchar_t);

    m->vendor = PMALLOC(cb);
#ifdef DEBUG
    assert(m->vendor);
#endif
    StringCbCopy(m->vendor, cb, r);

    if (!VerQueryValue(m->version_info,
                       L"\\",
                       (LPVOID *) &vff, &c) ||
        c != sizeof(*vff)) {

        rv = KHM_ERROR_INVALID_PARAM;
        _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, 
                    _cstr(L"Fixed Version Info"));
        goto _cleanup;
    }

    m->file_version.major = HIWORD(vff->dwFileVersionMS);
    m->file_version.minor = LOWORD(vff->dwFileVersionMS);
    m->file_version.patch = HIWORD(vff->dwFileVersionLS);
    m->file_version.aux   = LOWORD(vff->dwFileVersionLS);

    m->prod_version.major = HIWORD(vff->dwProductVersionMS);
    m->prod_version.minor = LOWORD(vff->dwProductVersionMS);
    m->prod_version.patch = HIWORD(vff->dwProductVersionLS);
    m->prod_version.aux   = LOWORD(vff->dwProductVersionLS);

    rv = KHM_ERROR_SUCCESS;

 _cleanup:
    if (KHM_FAILED(rv)) {
        if (m->version_info) {
            PFREE(m->version_info);
            m->version_info = NULL;
        }
    }

    return rv;
}
Ejemplo n.º 21
0
BOOL CUpdaterDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	CSVPToolBox svpTool;
	CString szLangDefault = svpTool.GetPlayerPath(  _T("lang\\default") );
	CString szLangSeting;
	m_nLanguage = 0;
		BOOL langSeted = false;
		//get default lang setting

		if(svpTool.ifFileExist(szLangDefault)){
			szLangSeting = svpTool.fileGetContent(szLangDefault);
			if(!szLangSeting.IsEmpty()){
				m_nLanguage = _wtoi( szLangSeting );
				langSeted = true;
			}
		}
		if(!langSeted){
			
			switch(GetSystemDefaultLangID()){ //http://www.science.co.il/Language/Locale-Codes.asp?s=codepage
					case 0x0804:
					case 0x1004:
					case 0x1404:
					case 0x0c04:
					case 0x0404: //Chinese 
						m_nLanguage = 0;
						break;
					default:
						m_nLanguage = 1;
						break;
			}
			
		}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	prg_total.SetRange(0, 1000);
	
	HDC hdc = ::GetDC(NULL);
	double dDefaultSize = 22;
	double dIntroSize = 14;
	m_scale = (double)GetDeviceCaps(hdc, LOGPIXELSY) / 96.0;
	double scale = 1.0;
	::ReleaseDC(0, hdc);

	m_hBigFont.m_hObject = NULL;
	

	if(!(::GetVersion()&0x80000000)){
		m_hBigFont.CreateFont(int(dDefaultSize * scale), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET,
		OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, 
		_T("Microsoft Sans Serif"));

		m_hIntroFont.CreateFont(int(dIntroSize * scale), 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET,
			OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, 
			_T("Microsoft Sans Serif"));
	}
	if(!m_hBigFont.m_hObject){
		m_hBigFont.CreateFont(int(dDefaultSize * scale), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, 
		OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, 
		_T("MS Sans Serif"));


		m_hIntroFont.CreateFont(int(dIntroSize * scale), 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, 
			OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, 
			_T("MS Sans Serif"));

	}
	tnid.cbSize = sizeof(NOTIFYICONDATA); 
	tnid.hWnd = this->m_hWnd; 
	tnid.uID = IDR_MAINFRAME; 
	tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; 
	tnid.uCallbackMessage = WM_NOTIFYICON; 
	tnid.hIcon = this->m_hIcon; 

	if(m_nLanguage ){
		SetWindowText(L"SPlayer Updater");
		csCurTask.SetWindowText(L"Current Task:");
		csTotalProgress.SetWindowText(L"Total:");
		szSpeed.SetWindowText(L"Speed:");
		cb_stop.SetWindowText(L"Cancel");
		cslink.SetWindowText(L"<a href=\"http://blog.splayer.org\">ChangeLog...</a>");
		cszSizeTotal.SetWindowText(L"Size:");
		
		cs_stat.SetWindowText(_T("This program will update lastest SPlayer, will exit automaticly after finished."));
		csCurTask.SetWindowText(_T("Current Task: Calc..."));
		wcscpy_s(tnid.szTip, _T("SPlayer Auto Updater"));

		szaIntro.Add(L"SPlayer support DXVA、DXVA2、EVR");

		szaIntro.Add(_T("SPlayer optimization of a variety of creative techniques, smooth playback. Maximize the efficiency are always our mission "));
		szaIntro.Add(_T("SPlayer mainly focused on user experience"));
		szaIntro.Add(_T("SPlayer is an open source software "));
		szaIntro.Add(_T("Designer Raven from Milan created a set of interfaces. Beautiful skin can let you feel more comfortable while playing"));
		szaIntro.Add(_T("SPlayer is world's smallest and most sophisticated players, complete installation package only 5M, still as powerful as ever ..."));
		szaIntro.Add(_T("SPlayer origin from MPCHC ffmpeg and thanks everyone with them"));
		szaIntro.Add(_T("SPlayer can download subtitle aotomaticely, you can disable it in setting panel if you want"));

	}else{
		cs_stat.SetWindowText(_T("本程序下载最新版的射手播放器,将在更新完成后5分钟内退出"));
		csCurTask.SetWindowText(_T("当前任务:正在计算下载量"));
		wcscpy_s(tnid.szTip, _T("射手影音播放器自动更新程序"));

		szaIntro.Add(_T("只要在设置中启用“智能拖拽”,鼠标拖住画面就可以方便的改变画面比例"));
		szaIntro.Add(_T("在界面设置中可以设置自定义的背景界面"));
		szaIntro.Add(_T("射手播放器无需安装额外解码包即可全能解码"));

		szaIntro.Add(_T("免配置智能启用硬件高清加速:DXVA、DXVA2、EVR和CUDA"));
		szaIntro.Add(_T("十余种画面效果功能组合,全新的视频观赏体验。"));
		szaIntro.Add(_T("全自动网络字幕匹配。抛弃浏览器,也不必再收集。只要一人播放过且同意共享,全球华人都可在播放时得到恰好匹配影片的字幕。"));
		szaIntro.Add(_T("双字幕显示,同时显示中英双语,共同学习提高。"));
		szaIntro.Add(_T("绿色版免安装,同时支持海量视频格式,永不流氓!"));
		szaIntro.Add(_T("与众不同的字幕默认字体与颜色,对抗视觉疲劳。"));
		szaIntro.Add(_T("智能识别简体或繁体字幕。告别乱码,也不用再手动转码。"));
		szaIntro.Add(_T("自动减小英文字码,双语字幕更美观优雅。"));
		szaIntro.Add(_T("根据使用习惯优化右键菜单,方便快速切换字幕和显示模式。"));
		szaIntro.Add(_T("更加易用、精简的控制面板,更方便且易于理解的设置选项。"));
		szaIntro.Add(_T("自动升级随时更新最新版本、体验最新功能。"));
		szaIntro.Add(_T("射手播放器拥护GPL授权协议,是开源软件。"));

	}

	SetTimer(IDT_START_CHECK, 1000, NULL);



	
	Shell_NotifyIcon(NIM_ADD, &tnid); 



	
	if(bHide){
		ShowWindow(SW_MINIMIZE);
		ShowWindow(SW_HIDE);

	}else{
		notYetShow = false;
		ShowWindow(SW_SHOW);
		ShowWindow(SW_RESTORE);
	}
	
	return FALSE;  // return TRUE  unless you set the focus to a control
}
Ejemplo n.º 22
0
void XmlReport::createOSNode( ER_OPERATINGSYSTEM& outOS )
{
	OSVERSIONINFOA  oi = {};
	oi.dwOSVersionInfoSize = sizeof(oi);
	GetVersionExA(&oi);

	// 设置 MajorVersion 属性。
	outOS.MajorVersion = (int)oi.dwMajorVersion;

	// 设置 MinorVersion 属性。
	outOS.MinorVersion = (int)oi.dwMinorVersion;

	// 设置 BuildNumber  属性。
	outOS.BuildNumber  = (int)oi.dwBuildNumber;

	// 设置 CSDVersion   属性。
	outOS.CSDVersion   = oi.szCSDVersion;

	// 设置 OSLanguage   属性。
	LANGID localID = GetSystemDefaultLangID();
	switch (localID)
	{
	case 0x0404:
		outOS.OSLanguage = "Chinese (Taiwan)";
		break;
	case 0x0804:
		outOS.OSLanguage = "Chinese (PRC)";
		break;
	case 0x0c04:
		outOS.OSLanguage = "Chinese (Hong Kong SAR, PRC)";
		break;
	case 0x1004:
		outOS.OSLanguage = "Chinese (Singapore)";
		break;
	case 0x0411:
		outOS.OSLanguage = "Japanese";
		break;
	case 0x0409:
		outOS.OSLanguage = "English (United States)";
		break;
	case 0x0809:
		outOS.OSLanguage = "English (United Kingdom)";
		break;
	case 0x0c09:
		outOS.OSLanguage = "English (Australian)";
		break;
	case 0x1009:
		outOS.OSLanguage = "English (Canadian)";
		break;
	case 0x1409:
		outOS.OSLanguage = "English (New Zealand)";
		break;
	case 0x1809:
		outOS.OSLanguage = "English (Ireland)";
		break;
	case 0x1c09:
		outOS.OSLanguage = "English (South Africa)";
		break;
	case 0x2009:
		outOS.OSLanguage = "English (Jamaica)";
		break;
	case 0x2409:
		outOS.OSLanguage = "English (Caribbean)";
		break;
	case 0x2809:
		outOS.OSLanguage = "English (Belize)";
		break;
	case 0x2c09:
		outOS.OSLanguage = "English (Trinidad)";
		break;

	default:
		outOS.OSLanguage  = "Unknown";
	}
}
Ejemplo n.º 23
0
static int init_playlist()
{
	WNDCLASS wc;
	HINSTANCE user32;
	LANGID _SysLangId;
	HINSTANCE hInstance = GetModuleHandle(NULL);

	if(hPlaylistWnd) {
		updatetracklist(hPlaylistWnd);
		ShowWindow(hPlaylistWnd, SW_SHOW);
		return 0;
	}

	if(sys_Language == 1) {
		LoadString(hInstance, IDS_PLAYLIST_SC, TitalPlaylist, 20);
		LoadString(hInstance, IDS_BT_PLAY_SC, BottonPlayAll, 20);
		LoadString(hInstance, IDS_BT_UP_SC, BottonUp, 20);
		LoadString(hInstance, IDS_BT_DOWN_SC, BottonDown, 20);
		LoadString(hInstance, IDS_BT_ADD_SC, BottonAdd, 20);
		LoadString(hInstance, IDS_BT_REMOVE_SC, BottonRemove, 20);
		LoadString(hInstance, IDS_BT_SAVE_SC, BottonSave, 20);
		LoadString(hInstance, IDS_BT_CLOSE_SC, BottonClose, 20);
		LoadString(hInstance, IDS_MU_ADD_SC, MenuAdd, 20);
		LoadString(hInstance, IDS_MU_REMOVE_SC, MenuRemove, 20);
		LoadString(hInstance, IDS_MU_CLEAR_SC, MenuClear, 20);
		LoadString(hInstance, IDS_MU_CLOSE_SC, MenuClose, 20);
	} else if(sys_Language == 3 || sys_Language == 4) {
		LoadString(hInstance, IDS_PLAYLIST_TC, TitalPlaylist, 20);
		LoadString(hInstance, IDS_BT_PLAY_TC, BottonPlayAll, 20);
		LoadString(hInstance, IDS_BT_UP_TC, BottonUp, 20);
		LoadString(hInstance, IDS_BT_DOWN_TC, BottonDown, 20);
		LoadString(hInstance, IDS_BT_ADD_TC, BottonAdd, 20);
		LoadString(hInstance, IDS_BT_REMOVE_TC, BottonRemove, 20);
		LoadString(hInstance, IDS_BT_SAVE_TC, BottonSave, 20);
		LoadString(hInstance, IDS_BT_CLOSE_TC, BottonClose, 20);
		LoadString(hInstance, IDS_MU_ADD_TC, MenuAdd, 20);
		LoadString(hInstance, IDS_MU_REMOVE_TC, MenuRemove, 20);
		LoadString(hInstance, IDS_MU_CLEAR_TC, MenuClear, 20);
		LoadString(hInstance, IDS_MU_CLOSE_TC, MenuClose, 20);
	} else {
		LoadString(hInstance, IDS_PLAYLIST_EN, TitalPlaylist, 20);
		LoadString(hInstance, IDS_BT_PLAY_EN, BottonPlayAll, 20);
		LoadString(hInstance, IDS_BT_UP_EN, BottonUp, 20);
		LoadString(hInstance, IDS_BT_DOWN_EN, BottonDown, 20);
		LoadString(hInstance, IDS_BT_ADD_EN, BottonAdd, 20);
		LoadString(hInstance, IDS_BT_REMOVE_EN, BottonRemove, 20);
		LoadString(hInstance, IDS_BT_SAVE_EN, BottonSave, 20);
		LoadString(hInstance, IDS_BT_CLOSE_EN, BottonClose, 20);
		LoadString(hInstance, IDS_MU_ADD_EN, MenuAdd, 20);
		LoadString(hInstance, IDS_MU_REMOVE_EN, MenuRemove, 20);
		LoadString(hInstance, IDS_MU_CLEAR_EN, MenuClear, 20);
		LoadString(hInstance, IDS_MU_CLOSE_EN, MenuClose, 20);
	}

	code_page = CP_ACP;
	_SysLangId = GetSystemDefaultLangID();
	if(PRIMARYLANGID(_SysLangId) == LANG_CHINESE) {
		if(SUBLANGID(_SysLangId) == SUBLANG_CHINESE_SIMPLIFIED)
			code_page = 936;
		else
			code_page = 950;
	}

	wc.style		 = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc   = PlayListWndProc;
	wc.cbClsExtra	= 0;
	wc.cbWndExtra	= 0;
	wc.hInstance	 = hInstance;
	wc.hCursor	   = LoadCursor(NULL,IDC_ARROW);
	mplayericon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPICON));
	wc.hIcon		 = mplayericon;
	wc.hbrBackground = SOLID_GREY;
	wc.lpszClassName = "MPlayer - Playlist";
	wc.lpszMenuName  = NULL;
	RegisterClass(&wc);
	create_playlistmenu();
	bkgndbrush = CreateSolidBrush(RGB(236,236,236));
	if(playlist_x < 0)
		playlist_x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (WinWidth / 2);   /* Erik: center popup window on screen */
	if(playlist_y < 0)
		playlist_y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (WinHeight / 2);
	hPlaylistWnd = CreateWindow("MPlayer - Playlist",
						TitalPlaylist, WS_OVERLAPPEDWINDOW | WS_SIZEBOX,
						playlist_x, playlist_y, WinWidth, WinHeight,
						playlist_parent, NULL, hInstance, NULL);

	if((vo_dirver != VO_DIRV_OPENGL || is_vista) && controlbar_alpha > 0) {
		user32 = GetModuleHandle("user32.dll");
		if (user32) {
			SetLayeredWinAttributes = GetProcAddress(user32, "SetLayeredWindowAttributes");
			if(SetLayeredWinAttributes) {
				SetWindowLong(hPlaylistWnd, GWL_EXSTYLE, GetWindowLong(hPlaylistWnd ,GWL_EXSTYLE) | WS_EX_LAYERED );
				SetLayeredWinAttributes(hPlaylistWnd, 0, 255, 2);
			}
		}
	}

	DragAcceptFiles(hPlaylistWnd, TRUE);

	if(!playlist)
		playlist = create_playlist();
	if(!need_update_playtree) {
		playlist->clear_playlist(playlist);
		import_playtree_into_playlist(mpctx->playtree, mconfig);
	}
	updatetracklist(hPlaylistWnd);
	SetWindowPos(hPlaylistWnd, playlist_layer,playlist_x,playlist_y,WinWidth,WinHeight,SWP_SHOWWINDOW);

	return 1;
}
Ejemplo n.º 24
0
LCID _getLocale(LPWIN32LOCALE _locale, LPSTR LocaleName)
{
    BOOL  found = FALSE;
    LCID  locale;
    int   res;
    int   langID = 1;
    int   subID = 1;
    int   lcid = 0;
    char  Language[64] = "none";
    char  ISO3166[4] = "000";
    char  *token;
    char  *savetoken;
    char  codepage[7];

    strlwr(LocaleName);
    while (!found && langID <= MAX_LANGID)
    {
        locale = MAKELCID(MAKELANGID(langID, SUBLANG_DEFAULT), SORT_DEFAULT);
        GetLocaleInfoA(locale, LOCALE_SENGLANGUAGE, Language, 64);
        GetLocaleInfoA(locale, LOCALE_SABBREVLANGNAME, ISO3166, 4);

        strlwr(Language);
        strlwr(ISO3166);

        if (strstr(LocaleName, Language) != NULL)
            found = TRUE;
        else
            if (strstr(LocaleName, ISO3166) == LocaleName)
            {
                found = TRUE;
            }
            else
                langID++;
    }

    // No language specified and no codepage
    if (!found && strchr(LocaleName, '_') == NULL && strchr(LocaleName, '.') == NULL)
    {
        SetLastError(ERROR_LOCALE_INVALID);
        return 0;
    }

    if (!found)
    {
        if (_locale->handle == 0)
            langID = GetSystemDefaultLangID();
        else langID = _locale->handle & 0x3FF;
    }
    // if not just a codepage lcid is now the selected language

    // get the sublanguage if any specified
    if ((token = strchr(LocaleName, '_')) != NULL)
    {
        token++;
        if ((savetoken = strchr(token, '.')) != NULL)
            *savetoken = 0x0;
        found = FALSE;
        res = 1;
        while (!found && res != 0)
        {
            res = GetLocaleInfoA(MAKELCID(MAKELANGID(langID, subID), SORT_DEFAULT),
                LOCALE_SENGCOUNTRY, Language, 64);
            strlwr(Language);
            if (strcmp(Language, token) == 0)
            {
                lcid = MAKELCID(MAKELANGID(langID, subID), SORT_DEFAULT);
                found = TRUE;
            }
            else
                subID++;
        }

        if (!found)
        {
            SetLastError(ERROR_LOCALE_INVALID);
            return 0;
        }

        if (savetoken)
            *savetoken = '.';
    }
    else
    {
        lcid = MAKELCID(MAKELANGID(langID, SUBLANG_DEFAULT), SORT_DEFAULT);
    }


    // get the codepage if any specified
    if ((token = strchr(LocaleName, '.')) == NULL)
    {
        GetLocaleInfoA(lcid, LOCALE_IDEFAULTCODEPAGE, codepage, 7);
        _locale->codepage = atol(codepage);
    }
    else {
        token++;
        _locale->codepage = atol(token);
    }
    //isValidLocale()
    return lcid;
}
Ejemplo n.º 25
0
/******************************************************************************
 *		GetSystemDefaultLangID	[OLE2NLS.4]
 */
LANGID WINAPI GetSystemDefaultLangID16(void)
{
    return GetSystemDefaultLangID();
}
Ejemplo n.º 26
0
// http://blogs.msdn.com/b/michkap/archive/2004/12/05/275231.aspx
static const char* get_kb(void)
{
	unsigned int kbid;
	char kbid_str[KL_NAMELENGTH];
	int pass;

	// Count on Microsoft to add convolution to a simple operation.
	// We use GetKeyboardLayout() because it returns an HKL, which for instance
	// doesn't tell us if the *LAYOUT* is Dvorak or something else. For that we
	// need an KLID which GetKeyboardLayoutNameA() does return ...but only as a
	// string of an hex value...
	GetKeyboardLayoutNameA(kbid_str);
	if (sscanf(kbid_str, "%x", &kbid) == 0) {
		uprintf("Could not scan keyboard layout name - falling back to US as default\n");
		kbid = 0x00000409;
	}
	uprintf("Windows KBID 0x%08x\n", kbid);

	for (pass=0; pass<3; pass++) {
		// Some of these return values are defined in
		// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout\DosKeybCodes
		// Others are picked up in FreeDOS official keyboard layouts, v3.0
		// Note: keyboard values are meant to start at 0x400. The cases below 0x400 are added
		// to attempt to figure out a "best match" in case we couldn't find a supported keyboard
		// by using the one most relevant to the language being spoken. Also we intentionally
		// group keyboards that shouldn't be together

		// Note: these cases are mostly organized first by (kbid & 0x3ff) and then by
		// ascending order for same (kbid & 0x3ff)
		switch(kbid) {
		case 0x00000001:
		case 0x00010401: // Arabic (102)
		case 0x00020401: // Arabic (102) AZERTY
			return "ar";
		case 0x00000002:
		case 0x00000402: // Bulgarian (Typewriter)
		case 0x00010402: // Bulgarian (Latin)
		case 0x00020402: // Bulgarian (Phonetic)
		case 0x00030402: // Bulgarian
		case 0x00040402: // Bulgarian (Phonetic Traditional)
			return "bg";
		case 0x00000004:
		case 0x00000404: // Chinese (Traditional) - US Keyboard
		case 0x00000804: // Chinese (Simplified) - US Keyboard
		case 0x00000c04: // Chinese (Traditional, Hong Kong) - US Keyboard
		case 0x00001004: // Chinese (Simplified, Singapore) - US Keyboard
		case 0x00001404: // Chinese (Traditional, Macao) - US Keyboard
			return "ch";
		case 0x00000005:
		case 0x00000405: // Czech
		case 0x00010405: // Czech (QWERTY)
		case 0x00020405: // Czech Programmers
			return "cz";
		case 0x00000006:
		case 0x00000406: // Danish
			return "dk";
		case 0x00000007:
		case 0x00000407: // German
		case 0x00010407: // German (IBM)
			return "gr";
		case 0x00000807: // Swiss German
			return "sg";
		case 0x00000008:
		case 0x00000408: // Greek
		case 0x00010408: // Greek (220)
		case 0x00020408: // Greek (319)
		case 0x00030408: // Greek (220) Latin
		case 0x00040408: // Greek (319) Latin
		case 0x00050408: // Greek Latin
		case 0x00060408: // Greek Polytonic
			return "gk";
		case 0x00000009:
		case 0x00000409: // US
		case 0x00020409: // United States-International
		case 0x00050409: // US English Table for IBM Arabic 238_L
			return "us";
		case 0x00000809: // United Kingdom
		case 0x00000452: // United Kingdom Extended (Welsh)
		case 0x00001809: // Irish
		case 0x00011809: // Gaelic
			return "uk";
		case 0x00000c0c: // Canadian French (Legacy)
		case 0x00001009: // Canadian French
		case 0x00011009: // Canadian Multilingual Standard
			return "cf";
		case 0x00010409: // United States-Dvorak
			return "dv";
		case 0x00030409: // United States-Dvorak for left hand
			return "lh";
		case 0x00040409: // United States-Dvorak for right hand
			return "rh";
		case 0x0000000a:
		case 0x0000040a: // Spanish
		case 0x0001040a: // Spanish Variation
			return "sp";
		case 0x0000080a: // Latin American
			return "la";
		case 0x0000000b:
		case 0x0000040b: // Finnish
		case 0x0001083b: // Finnish with Sami
			return "su";
		case 0x0000000c:
		case 0x0000040c: // French
		case 0x0000046e: // Luxembourgish
			return "fr";
		case 0x0000080c: // Belgian French
		case 0x0001080c: // Belgian (Comma)
			return "be";
		case 0x0000100c: // Swiss French
			return "sf";
		case 0x0000000d:
		case 0x0000040d: // Hebrew
			return "il";
		case 0x0000000e:
		case 0x0000040e: // Hungarian
		case 0x0001040e: // Hungarian 101-key
			return "hu";
		case 0x0000000f:
		case 0x0000040f: // Icelandic
			return "is";
		case 0x00000010:
		case 0x00000410: // Italian
		case 0x00010410: // Italian (142)
			return "it";
		case 0x00000011:
		case 0x00000411: // Japanese
			return "jp";
	//	case 0x00000012:
	//	case 0x00000412: // Korean
	//		return "ko";	// NOT IMPLEMENTED IN FREEDOS?
		case 0x00000013:
		case 0x00000413: // Dutch
		case 0x00000813: // Belgian (Period)
			return "nl";
		case 0x00000014:
		case 0x00000414: // Norwegian
		case 0x0000043b: // Norwegian with Sami
		case 0x0001043b: // Sami Extended Norway
			return "no";
		case 0x00000015:
		case 0x00010415: // Polish (214)
		case 0x00000415: // Polish (Programmers)
			return "pl";
		case 0x00000016:
		case 0x00000416: // Portuguese (Brazilian ABNT)
		case 0x00010416: // Portuguese (Brazilian ABNT2)
			return "br";
		case 0x00000816: // Portuguese (Portugal)
			return "po";
		case 0x00000018:
		case 0x00000418: // Romanian (Legacy)
		case 0x00010418: // Romanian (Standard)
		case 0x00020418: // Romanian (Programmers)
			return "ro";
		case 0x00000019:
		case 0x00000419: // Russian
		case 0x00010419: // Russian (Typewriter)
			return "ru";
		case 0x0000001a:
		case 0x0000041a: // Croatian
		case 0x0000081a: // Serbian (Latin)
		case 0x00000024:
		case 0x00000424: // Slovenian
			return "yu";
		case 0x00000c1a: // Serbian (Cyrillic)
		case 0x0000201a: // Bosnian (Cyrillic)
			return "yc";
		case 0x0000001b:
		case 0x0000041b: // Slovak
		case 0x0001041b: // Slovak (QWERTY)
			return "sl";
		case 0x0000001c:
		case 0x0000041c: // Albanian
			return "sq";
		case 0x0000001d:
		case 0x0000041d: // Swedish
		case 0x0000083b: // Swedish with Sami
			return "sv";
		case 0x0000001f:
		case 0x0000041f: // Turkish Q
		case 0x0001041f: // Turkish F
			return "tr";
		case 0x00000022:
		case 0x00000422: // Ukrainian
		case 0x00020422: // Ukrainian (Enhanced)
			return "ur";
		case 0x00000023:
		case 0x00000423: // Belarusian
			return "bl";
		case 0x00000025:
		case 0x00000425: // Estonian
			return "et";
		case 0x00000026:
		case 0x00000426: // Latvian
		case 0x00010426: // Latvian (QWERTY)
			return "lv";
		case 0x00000027:
		case 0x00000427: // Lithuanian IBM
		case 0x00010427: // Lithuanian
		case 0x00020427: // Lithuanian Standard
			return "lt";
		case 0x00000028:
		case 0x00000428: // Tajik
			return "tj";
	//	case 0x00000029:
	//	case 0x00000429: // Persian
	//		return "fa";	// NOT IMPLEMENTED IN FREEDOS?
		case 0x0000002a:
		case 0x0000042a: // Vietnamese
			return "vi";
		case 0x0000002b:
		case 0x0000042b: // Armenian Eastern
		case 0x0001042b: // Armenian Western
			return "hy";
		case 0x0000002c:
		case 0x0000042c: // Azeri Latin
		case 0x0000082c: // Azeri Cyrillic
			return "az";
		case 0x0000002f:
		case 0x0000042f: // Macedonian (FYROM)
		case 0x0001042f: // Macedonian (FYROM) - Standard
			return "mk";
		case 0x00000037:
		case 0x00000437: // Georgian
		case 0x00010437: // Georgian (QWERTY)
		case 0x00020437: // Georgian (Ergonomic)
			return "ka";
		case 0x00000038:
		case 0x00000438: // Faeroese
			return "fo";
		case 0x0000003a:
		case 0x0000043a: // Maltese 47-Key
		case 0x0001043a: // Maltese 48-Key
			return "mt";
		case 0x0000003f:
		case 0x0000043f: // Kazakh
			return "kk";
		case 0x00000040:
		case 0x00000440: // Kyrgyz Cyrillic
			return "ky";
		case 0x00000043:
		case 0x00000843: // Uzbek Crillic
			return "uz";
		case 0x00000042:
		case 0x00000442: // Turkmen
			return "tm";
		case 0x00000044:
		case 0x00000444: // Tatar
			return "tt";

	// Below are more Windows 7 listed keyboards that were left out
	#if 0
		case 0x0000041e: // Thai Kedmanee
		case 0x0001041e: // Thai Pattachote
		case 0x0002041e: // Thai Kedmanee (non-ShiftLock)
		case 0x0003041e: // Thai Pattachote (non-ShiftLock)
		case 0x00000420: // Urdu
		case 0x0000042e: // Sorbian Standard (Legacy)
		case 0x0001042e: // Sorbian Extended
		case 0x0002042e: // Sorbian Standard
		case 0x00000432: // Setswana
		case 0x00000439: // Devanagari - INSCRIPT#
		case 0x00010439: // Hindi Traditional
		case 0x0002083b: // Sami Extended Finland-Sweden
		case 0x00000445: // Bengali
		case 0x00010445: // Bengali - INSCRIPT (Legacy)
		case 0x00020445: // Bengali - INSCRIPT
		case 0x00000446: // Punjabi
		case 0x00000447: // Gujarati
		case 0x00000448: // Oriya
		case 0x00000449: // Tamil
		case 0x0000044a: // Telugu
		case 0x0000044b: // Kannada
		case 0x0000044c: // Malayalam
		case 0x0000044d: // Assamese - INSCRIPT
		case 0x0000044e: // Marathi
		case 0x00000450: // Mongolian Cyrillic
		case 0x00000451: // Tibetan
		case 0x00000850: // Mongolian (Mongolian Script)
		case 0x0000085d: // Inuktitut - Latin
		case 0x0001045d: // Inuktitut - Naqittaut
		case 0x00000453: // Khmer
		case 0x00000454: // Lao
		case 0x0000045a: // Syriac
		case 0x0001045a: // Syriac Phonetic
		case 0x0000045b: // Sinhala
		case 0x0001045b: // Sinhala - Wij 9
		case 0x00000461: // Nepali
		case 0x00000463: // Pashto (Afghanistan)
		case 0x00000465: // Divehi Phonetic
		case 0x00010465: // Divehi Typewriter
		case 0x00000468: // Hausa
		case 0x0000046a: // Yoruba
		case 0x0000046c: // Sesotho sa Leboa
		case 0x0000046d: // Bashkir
		case 0x0000046f: // Greenlandic
		case 0x00000470: // Igbo
		case 0x00000480: // Uyghur (Legacy)
		case 0x00010480: // Uyghur
		case 0x00000481: // Maori
		case 0x00000485: // Yakut
		case 0x00000488: // Wolof
	#endif
		default:
			if (pass == 0) {
				// If we didn't get a match 1st time around, try to match
				// the primary language of the keyboard
				kbid = PRIMARYLANGID(kbid);
			} else if (pass == 1) {
				// If we still didn't get a match, use the system's primary language
				kbid = PRIMARYLANGID(GetSystemDefaultLangID());
				uprintf("Unable to match KBID, trying LangID 0x%04x\n", kbid);
			}
			break;
		}
	}
	uprintf("Unable to match KBID and LangID - defaulting to US\n");
	return "us";
}
Ejemplo n.º 27
0
void VBA::winSetLanguageOption(int option, bool force)
{
  if(((option == languageOption) && option != 2) && !force)
    return;
  switch(option) {
  case 0:
    {
      char lbuffer[10];

      if(GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVLANGNAME,
                       lbuffer, 10)) {
        HINSTANCE l = winLoadLanguage(lbuffer);
        if(l == NULL) {
          LCID locIdBase = MAKELCID( MAKELANGID( PRIMARYLANGID( GetSystemDefaultLangID() ), SUBLANG_NEUTRAL ), SORT_DEFAULT );
          if(GetLocaleInfo(locIdBase, LOCALE_SABBREVLANGNAME,
                           lbuffer, 10)) {
            l = winLoadLanguage(lbuffer);
            if(l == NULL) {
              //printErrorMessage(IDS_FAILED_TO_LOAD_LIBRARY,
                            //"Failed to load library %s",
                            //lbuffer);
              return;
            }
          }
        }
        AfxSetResourceHandle(l);
        if(languageModule != NULL)
#ifdef _AFXDLL
          AfxFreeLibrary( languageModule );
#else
          FreeLibrary( languageModule );
#endif
        languageModule = l;
      } else {
        //printErrorMessage(IDS_FAILED_TO_GET_LOCINFO,
                      //"Failed to get locale information");
        return;
      }
    }
    break;
  case 1:
    if(languageModule != NULL)
#ifdef _AFXDLL
      AfxFreeLibrary( languageModule );
#else
      FreeLibrary( languageModule );
#endif
    languageModule = NULL;
    AfxSetResourceHandle(AfxGetInstanceHandle());
    break;
  case 2:
    {
      if(!force) {
        LangSelect dlg;
        if(dlg.DoModal()) {
          HINSTANCE l = winLoadLanguage(languageName);
          if(l == NULL) {
            //printErrorMessage(IDS_FAILED_TO_LOAD_LIBRARY,
                          //"Failed to load library %s",
                          //languageName);
            return;
          }
          AfxSetResourceHandle(l);
          if(languageModule != NULL)
		  {
#ifdef _AFXDLL
            AfxFreeLibrary( languageModule );
#else
            FreeLibrary( languageModule );
#endif
		  }
          languageModule = l;
        }
      } else {
        if(languageName.IsEmpty())
          return;
        HINSTANCE l = winLoadLanguage(languageName);
        if(l == NULL) {
          //printErrorMessage(IDS_FAILED_TO_LOAD_LIBRARY,
                        //"Failed to load library %s",
                        //languageName);
          return;
        }
        AfxSetResourceHandle(l);
        if(languageModule != NULL)
          FreeLibrary(languageModule);
        languageModule = l;
      }
    }
    break;
  }
  languageOption = option;
  updateMenuBar();
}
BOOL PrintFileHeader( FILE * fp )
{
	TCHAR str[ 1024 ];
	_fputts( APP_NAME, fp );

#ifdef _UNICODE
	_fputts( TEXT( " (Unicode)\r\n" ), fp );
#else
	_fputts( TEXT( " (ANSI)\r\n" ), fp );
#endif

	SYSTEMTIME st;
	GetLocalTime( &st );

	TIME_ZONE_INFORMATION tzi;
	GetTimeZoneInformation( &tzi );
	int tz = abs( (int) tzi.Bias );
	int tz_sign = ( tzi.Bias < 0 ) ? ( +1 ) : ( -1 ) ; // if Bias is negative, TZ is positive
	int tz_h = tz / 60;
	int tz_m = tz - tz_h * 60;

	wsprintf( str, TEXT( "  %4d-%02d-%02d %02d:%02d:%02d.%03d%s%02d:%02d\r\n\r\n" ),
		st.wYear, st.wMonth, st.wDay,
		st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
		tz_sign > 0 ? TEXT( "+" ) : TEXT( "-" ), tz_h, tz_m );
	_fputts( str, fp );

	OSVERSIONINFO osvi;
	osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
	GetVersionEx( &osvi );
	TCHAR tmpstr[ 256 ] = TEXT( "Unknown OS" );

	if( osvi.dwMajorVersion == 4UL )
	{
		if( osvi.dwMinorVersion == 0UL )
			lstrcpy( tmpstr, TEXT( "Windows NT 4.0" ) );
		else if( osvi.dwMinorVersion == 90UL )
			lstrcpy( tmpstr, TEXT( "Windows Me" ) );
	}
	else if( osvi.dwMajorVersion == 5UL )
	{
		if( osvi.dwMinorVersion == 0UL )
			lstrcpy( tmpstr, TEXT( "Windows 2000" ) );
		else if( osvi.dwMinorVersion == 1UL )
			lstrcpy( tmpstr, TEXT( "Windows XP" ) );
		else if( osvi.dwMinorVersion == 2UL )
			lstrcpy( tmpstr, TEXT( "Windows Server 2003 R2, Windows Server 2003, or Windows XP Professional x64 Edition" ) );
	}
	else if( osvi.dwMajorVersion == 6UL )
	{
		if( osvi.dwMinorVersion == 0UL )
			lstrcpy( tmpstr, _T( "Windows Vista or Windows Server \"Longhorn\"" ) );
	}


	wsprintf( str, TEXT( "%s ( OS Version: %lu.%lu Build %lu, %s )\r\n" ),
		tmpstr,
		osvi.dwMajorVersion,
		osvi.dwMinorVersion,
		osvi.dwBuildNumber,
		osvi.szCSDVersion
	);
	_fputts( str, fp );

	LANGID lang = GetSystemDefaultLangID();
	VerLanguageName( (DWORD) lang, tmpstr, 255UL );
	wsprintf( str, TEXT( "  System Language: %u (%s)\r\n" ), lang, tmpstr );
	_fputts( str, fp );
	LCID lcid = GetSystemDefaultLCID();
	GetLocaleInfo( lcid, LOCALE_SNATIVELANGNAME, tmpstr, 255UL );
	wsprintf( str, TEXT( "  System Locale:   %lu (%s)\r\n" ), lcid, tmpstr );
	_fputts( str, fp );

	lang = GetUserDefaultLangID();
	VerLanguageName( (DWORD) lang, tmpstr, 255UL );
	wsprintf( str, TEXT( "  User Language:   %u (%s)\r\n" ), lang, tmpstr );
	_fputts( str, fp );

	lcid = GetUserDefaultLCID();
	GetLocaleInfo( lcid, LOCALE_SNATIVELANGNAME, tmpstr, 255UL );
	wsprintf( str, TEXT( "  User Locale:     %lu (%s)\r\n" ), lcid, tmpstr );
	_fputts( str, fp );
	_fputts( TEXT( "\r\n" ), fp );

	return TRUE;
}
Ejemplo n.º 29
0
/*===========================================================================
* ReadContinuousLogData
*---------------------------------------------------------------------------
* Description: Puts the node in continuous mode, reads the sensor data and
*              prints to the screen and logs data to user file until the user 
*              interrupts.
*
* Return: HANDLE - handle to the opened comport
*===========================================================================*/
void ReadContinuousLogData(int portNum)
{
	int iCount = 0;
	BOOL bStopContinuous = FALSE;
	DWORD dwcharsRead = 0;
	I3dmgx3Set Record;
	BYTE cmd_return;
	int Curs_posY = 0;
	int Curs_posX = 0;
	int status    = 0;
	int error_record = 0;
	int valid_check = 0;
	int valid_count = 0;
	char consoleBuff[60] = {0};
	long valid_rec = 0;
	unsigned char error_cmd;
	char ComLogFile[256]; 
	FILE *m_logFile;
	int LogFlag = 0;
	int error_count = 0;
	int errorCode =0, i=0;
	char fw[20] = {0};
    char sn[20] = {0};
	char mListSep[4];
    char mDecSep[4];
	LANGID langId;
	char szLanguage[256]; /*MAX_PATH]; */
	char idchar[] = {'\x02', '\x00', '\x01', '\x03', '\x04'};
    int m_timerconst = 62500; 
	unsigned long AA_Time_Stamp=0;
	unsigned long AA_s_prev =0;
	float AA_convert = 0.0;
	float AA_prev = 0.0;

	struct __timeb64 timebuffer;
    char *timeline;
    
        _ftime64( &timebuffer );
        timeline = _ctime64( & ( timebuffer.time ) );

	while (LogFlag != 1){
	    printf("Enter Name of LogFile to use:");
		scanf("%s", &ComLogFile); // 255);
		printf("logFile %s\n", ComLogFile);
        if ( ( m_logFile= fopen( ComLogFile, "w")) == NULL){
			printf("File: %s not opened\n", ComLogFile);
			if(++error_count > 2)
				return;
		}else LogFlag = 1;	
	}
	
	fprintf(m_logFile, "[SESSION START TAG]\n");
	fprintf(m_logFile, "Session Start Time:%.19s.%hu \n", timeline, timebuffer.millitm );
	fprintf(m_logFile, "Time Source: HOST\n");
	GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SLIST,mListSep,4);
	fprintf(m_logFile, "List Separator: %s\n", mListSep);
	GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SDECIMAL,mDecSep,4);
        fprintf(m_logFile, "Decimal Separator: %s\n", mDecSep);
	langId = GetSystemDefaultLangID (); 
	i = VerLanguageName (langId, szLanguage, 256); //dwSize = MAX_PATH; 
        fprintf(m_logFile, "Language: %s\n", szLanguage);

    while(valid_check == 0)
	{
       errorCode = i3dmgx3_getFirmwareVersion(portNum, &fw[0]);
	   if (errorCode < 0){
		   purge_port(portNum);
               printf("Firmware Error %d\n",errorCode);
		   if (valid_count++ > 6) {
               printf("Please Halt Current Data Display and Retry, count %d\n", valid_count);
		       return;
		   }
	   }else if (errorCode >= 0){
		   valid_check = 1;
	   }
	} 
	
   /*------------------------------------------------------------------
    * 0xEA  get serial information number, model and options (as string) 
    *-----------------------------------------------------------------*/
	valid_count =0;
    for ( i=0; i<4; i++){   //cycles through the valid device options
	
	   errorCode = i3dmgx3_getDeviceIdentiy(portNum, idchar[i], &sn[0]);
	   if (errorCode < 0){
		    purge_port(portNum);
			i--;
			if (valid_count++ >6){
			    printf("Error Read Device Identity: %s\n", explainError(errorCode));
			}
	   } else{
			 switch( i ) {
			       case 0:
					   fprintf(m_logFile, "Device Name: %s\n",sn);
					   break;
				   case 1:
					   fprintf(m_logFile, "Device Model: %s\n",sn);
					   break;
				   case 2:
					   fprintf(m_logFile, "Device FirmWare Version: %s\n", fw);
					   fprintf(m_logFile, "Device Serial Number: %s\n", sn);
					   break;
				   case 3:
					   fprintf(m_logFile, "Device Options: %s\n", sn);
					   break;
				   case 4:
				   default:
					   break;
            }
		 }
	
	} 

	fprintf(m_logFile, "Command C2\n[DATA START TAG]\n\t Time%s Accel X%s Accel Y%s Accel Z%s AngRate X%s AngRate Y%s AngRate Z%s Ticks\n", mListSep, mListSep, mListSep, mListSep, mListSep, mListSep, mListSep);

	//put the node in continuous mode
	status =SetContinuousMode(portNum, 0xC2);
	printf("setcontinuous is %d", status);
	//set up the output for the data
	printf("\n\n");
	printf("Reading streaming data (hit s to Stop streaming).\n");
	printf("C2___________________________Acceleration_______________________________\n");
	printf("            X                       Y                      Z            \n");
	/*  acceleration values go here */
	printf("\n\n\n"); 
	printf("C2____________________________Angular_Rate______________________________\n");
	printf("            X                       Y                      Z            \n");
	/* angle rate values go here  */
	getConXY(&Curs_posX, &Curs_posY); 
	printf("\n\n\n\n");
	
	//continue until the user hits the <s>top key
	while(!bStopContinuous)
	{

		if(ReadNextRecord(portNum, &Record, &cmd_return) != SUCCESS)
			error_record++;
	        if (cmd_return == 0xC2){
                if (AA_s_prev == 0){
	               fprintf(m_logFile, "\t  0.00");
				    AA_s_prev = Record.timer; //AA_Time_Stamp;
		         }
                  else
                {
				  AA_convert = ((float)(Record.timer - AA_s_prev)/m_timerconst); //19660800);
			      AA_s_prev = Record.timer; //AA_Time_Stamp;
				  AA_prev = AA_prev + AA_convert;
			      fprintf(m_logFile, "\t%6.2f", AA_prev);
			    }
			//move to the acceleration position and print the data
            sprintf(consoleBuff, "\t%2.6f\t\t%2.6f\t\t%2.6f", Record.setA[0], Record.setA[1], Record.setA[2]);               
			fprintf(m_logFile, "%s %2.6f%s %2.6f%s %2.6f%s ", mListSep, Record.setA[0],mListSep, Record.setA[1], mListSep, Record.setA[2], mListSep);
            setConXY(Curs_posX, Curs_posY -5, &consoleBuff[0]);
            sprintf(consoleBuff, "\t%2.6f\t\t%2.6f\t\t%2.6f", Record.setB[0], Record.setB[1], Record.setB[2]);
		    fprintf(m_logFile, "%2.6f%s %2.6f%s %2.6f%s %u\n", Record.setB[0], mListSep, Record.setB[1], mListSep, Record.setB[2], mListSep, Record.timer);
			setConXY(Curs_posX, Curs_posY, &consoleBuff[0]);
			valid_rec++;
			}else if (cmd_return != 0xc4){
				if((cmd_return == 0xCB || cmd_return == 0xD3) && error_record == 0)
				    error_cmd = cmd_return;
				else
					error_record++;
			}
			
		
		//check for a key every 50 iterations
		if(iCount++ > 50)	{
			int ch = 0;
			if(ReadCharNoReturn(&ch)){
				bStopContinuous = (ch == 's' || ch == 'S');
			}
			//reset the counter
			iCount = 0;
		}
	}
	printf("\n\n\nStopping Continuous Mode...");
	StopContinuousMode(portNum);
	printf("stopped.\n");
	fclose(m_logFile);
	if (error_record > 0)
	    printf("Number of records received in error were %d and received successfully %d\n", error_record, valid_rec);
	else
		printf("All %d records read successfully.\n", valid_rec);
}
LRESULT CALLBACK About( HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam )
{
#define TIMER_ID_ABOUT (UINT) 'A'
	const RECT urlrect = { 90, 140, 320, 170 };

	static HCURSOR hCursor[ 3 ];
	static int iCursor = 0;
	static int iMouseDown = 0;
	static HWND hWnd = NULL;

	static HFONT hBold;
	static TCHAR lpszWindowText[ 1024 ];
	switch ( uMessage )
	{
		case WM_INITDIALOG:
		{
			hWnd = (HWND) lParam;

			
			HDC hDC = GetDC( hDlg );
			hBold = MyCreateFont( hDC, TEXT( "Georgia" ), 14, TRUE, TRUE );
			if( !hBold ) hBold = MyCreateFont( hDC, TEXT( "Times New Roman" ), 16, TRUE, TRUE );
			ReleaseDC( hDlg, hDC );

			SetDlgItemText( hDlg, IDC_APP_NAME , APP_NAME );
			SendDlgItemMessage( hDlg, IDC_APP_NAME, WM_SETFONT, ( WPARAM ) hBold, 0L );
			SendDlgItemMessage( hDlg, IDC_DESCRIPTION, WM_SETFONT, ( WPARAM ) hFont, 0L );
			TCHAR str[ 1024 ];
			wsprintf( str, TEXT( "Compiled on: %hs, %hs UTC" ), __TIME__, __DATE__ );
			SetDlgItemText( hDlg, IDC_DATETIME , str );
			SetDlgItemText( hDlg, IDC_COPYRIGHT , APP_COPYRIGHT );

			SendDlgItemMessage( hDlg, IDC_EDITBOX_GPL, EM_SETMARGINS,
				(WPARAM) ( EC_LEFTMARGIN | EC_RIGHTMARGIN ),
				MAKELPARAM( 5 , 10 )
			);


#ifdef _UNICODE
			SetDlgItemText( hDlg, IDC_DESCRIPTION2 , TEXT( "Unicode Build" ) );
#else
			SetDlgItemText( hDlg, IDC_DESCRIPTION2 , TEXT( "ANSI (Non-unicode) Build" ) );
#endif
			
#ifdef _UNICODE
			if( IS_JAPANESE )
			{
				lpszWindowText[ 0 ] = TEXT( '\0' ); // just in case
				MultiByteToWideChar( CP_UTF8, MB_CUTE, S_JPN_9000, -1, lpszWindowText, 1023 );
				SetWindowText( hDlg, lpszWindowText );

				str[ 0 ] = TEXT( '\0' );
				MultiByteToWideChar( CP_UTF8, MB_CUTE, S_JPN_DESC, -1, str, 1023 );
				SetDlgItemText( hDlg, IDC_DESCRIPTION, str );

				SendDlgItemMessage( hDlg, IDC_EDITBOX_GPL, WM_SETFONT, ( WPARAM ) hFont, 0L );
				str[ 0 ] = TEXT( '\0' );
				MultiByteToWideChar( CP_UTF8, MB_CUTE, S_JPN_GPL, -1, str, 1023 );
				SetDlgItemText( hDlg, IDC_EDITBOX_GPL, str );
			}
			else if( IS_FINNISH )
			{
				lpszWindowText[ 0 ] = TEXT( '\0' ); // just in case
				MultiByteToWideChar( CP_UTF8, MB_CUTE, S_FIN_9000, -1, lpszWindowText, 1023 );
				SetWindowText( hDlg, lpszWindowText );

				str[ 0 ] = TEXT( '\0' );
				MultiByteToWideChar( CP_UTF8, MB_CUTE, S_FIN_DESC, -1, str, 1023 );
				SetDlgItemText( hDlg, IDC_DESCRIPTION, str );
				SetDlgItemText( hDlg, IDC_EDITBOX_GPL, TEXT_GPL );
			}
			else if( IS_SPANISH )
			{
				lpszWindowText[ 0 ] = TEXT( '\0' ); // just in case
				MultiByteToWideChar( CP_UTF8, MB_CUTE, S_SPA_9000, -1, lpszWindowText, 1023 );
				SetWindowText( hDlg, lpszWindowText );

				str[ 0 ] = TEXT( '\0' );
				MultiByteToWideChar( CP_UTF8, MB_CUTE, S_SPA_DESC, -1, str, 1023 );
				SetDlgItemText( hDlg, IDC_DESCRIPTION, str );
				SetDlgItemText( hDlg, IDC_EDITBOX_GPL, TEXT_GPL );
			}
			else if( IS_CHINESE_T )
			{
				lpszWindowText[ 0 ] = TEXT( '\0' ); // just in case
				MultiByteToWideChar( CP_UTF8, MB_CUTE, S_CHI_9000T, -1, lpszWindowText, 1023 );
				SetWindowText( hDlg, lpszWindowText );

				str[ 0 ] = TEXT( '\0' );
				MultiByteToWideChar( CP_UTF8, MB_CUTE, S_CHI_DESC_T, -1, str, 1023 );
				SetDlgItemText( hDlg, IDC_DESCRIPTION, str );
				SetDlgItemText( hDlg, IDC_EDITBOX_GPL, TEXT_GPL );
			}
			else if( IS_CHINESE_S )
			{
				lpszWindowText[ 0 ] = TEXT( '\0' ); // just in case
				MultiByteToWideChar( CP_UTF8, MB_CUTE, S_CHI_9000S, -1, lpszWindowText, 1023 );
				SetWindowText( hDlg, lpszWindowText );

				str[ 0 ] = TEXT( '\0' );
				MultiByteToWideChar( CP_UTF8, MB_CUTE, S_CHI_DESC_S, -1, str, 1023 );
				SetDlgItemText( hDlg, IDC_DESCRIPTION, str );
				SetDlgItemText( hDlg, IDC_EDITBOX_GPL, TEXT_GPL );
			}
			else if( IS_FRENCH )
			{
				lpszWindowText[ 0 ] = TEXT( '\0' ); // just in case
				MultiByteToWideChar( CP_UTF8, MB_CUTE, S_FRE_9000, -1, lpszWindowText, 1023 );
				SetWindowText( hDlg, lpszWindowText );

				str[ 0 ] = TEXT( '\0' );
				MultiByteToWideChar( CP_UTF8, MB_CUTE, S_FRE_DESC, -1, str, 1023 );
				SetDlgItemText( hDlg, IDC_DESCRIPTION, str );
				SetDlgItemText( hDlg, IDC_EDITBOX_GPL, TEXT_GPL );
			}
			else
#endif
			{
				SetDlgItemText( hDlg, IDC_DESCRIPTION, S_ENG_DESC );
				SetDlgItemText( hDlg, IDC_EDITBOX_GPL, TEXT_GPL );
				lstrcpy( lpszWindowText, TEXT( "About..." ) );
				SetWindowText( hDlg, lpszWindowText );
			}

			char hcSstpVersion[ 1024 ] = "";

#ifdef _UNICODE
			WideCharToMultiByte(
					CP_ACP,
					0,
					APP_NAME,
					-1,
					hcSstpVersion,
					1023,
					NULL,
					NULL
			);
#else
			lstrcpyA( hcSstpVersion, APP_NAME );
#endif
			lstrcatA( hcSstpVersion, "\\nCompiled on: " );
			lstrcatA( hcSstpVersion, __TIME__ );
			lstrcatA( hcSstpVersion, "+00:00, " );
			lstrcatA( hcSstpVersion, __DATE__ );

#ifdef _UNICODE
			if( IS_JAPANESE && ( LANG_JAPANESE == PRIMARYLANGID( GetSystemDefaultLangID() ) ) )
#else
			if( LANG_JAPANESE == PRIMARYLANGID( GetSystemDefaultLangID() ) )
#endif
			{
				DirectSSTP( (HWND) lParam, S_ABOUT_SJIS, hcSstpVersion, "Shift_JIS" );
			}
			else
			{
				DirectSSTP( (HWND) lParam, "About 'Battle Encoder Shirase'...", hcSstpVersion, "ASCII" );
			}


			hCursor[ 0 ] = LoadCursor( ( HINSTANCE ) NULL, IDC_ARROW );
			hCursor[ 1 ] = LoadCursor( ( HINSTANCE ) NULL, IDC_HAND );
			hCursor[ 2 ] = hCursor[ 1 ];
			SetCursor( hCursor[ 0 ] );

			// Anti-Ukagaka
			SetTimer( hDlg, TIMER_ID_ABOUT, 500U, (TIMERPROC) NULL );
			break;
		}
		case WM_COMMAND:
		{
			if( LOWORD( wParam ) == IDOK || LOWORD( wParam ) == IDCANCEL ) 
			{
				EndDialog( hDlg, -1 );
				return TRUE;
			}
			break;
		}
		case WM_TIMER:
		{
			SetWindowText( hDlg, lpszWindowText );
			break;
		}
		case WM_MOUSEMOVE:
		{
			if( iMouseDown == -1 ) break;

			int iPrevCursor = iCursor;
			iCursor = AboutBoxUrlHit( lParam );

			// Reset Cursor for each WM_MOUSEMOVE, silly but...
			SetCursor( hCursor[ iCursor ] );

			if( iCursor == 1 && iMouseDown == 1 ) iCursor = 2;

			
			if( iPrevCursor != iCursor )
			{
/*
				// In theory, we have to change Cursor only when Prev!=Now, but
				// something is wrong here and that doesn't work.
				SetCursor( hCursor[ iCursor ] );
*/
				InvalidateRect( hDlg, &urlrect, TRUE );
			}
			break;
		}

		case WM_LBUTTONDOWN:
		{
			SetCapture( hDlg );
			
			if( AboutBoxUrlHit( lParam ) )
			{
				iMouseDown = 1;
				SetCursor( hCursor[ 1 ] );
				iCursor = 2;
				InvalidateRect( hDlg, &urlrect, TRUE );
			}
			else
			{
				iMouseDown = -1;
			}
			break;
		}

		case WM_LBUTTONUP:
		{
			ReleaseCapture();
			
			if( iMouseDown == 1 && AboutBoxUrlHit( lParam ) )
			{
				OpenBrowser( APP_HOME_URL );
			}

			iCursor = 0;
			SetCursor( hCursor[ 0 ] );
			iMouseDown = 0;
			break;
		}


		case WM_ACTIVATE:
		{
			if( wParam == WA_INACTIVE )
			{
				iMouseDown = -1;
				iCursor = 0;
				SetCursor( hCursor[ 0 ] );
				InvalidateRect( hDlg, &urlrect, TRUE );
			}
			else
			{
				iMouseDown = 0;
			}
			break;
		}
		case WM_PAINT:
		{
			PAINTSTRUCT ps;
			HDC hdc = BeginPaint( hDlg, &ps );
			HFONT hMyFont = GetFontForURL( hdc );
			HFONT hOldFont = (HFONT) SelectObject( hdc, hMyFont );

			SetBkMode( hdc, TRANSPARENT );
			SetTextColor( hdc,
				iCursor == 2 ? RGB( 0xff, 0x00, 0x00 ) :
				iCursor == 1 ? RGB( 0x00, 0x80, 0x00 ) : RGB( 0x00, 0x00, 0xff ) );
			TextOut( hdc, 100, 148, APP_HOME_URL, lstrlen( APP_HOME_URL ) );
			SelectObject( hdc, hOldFont );
			DeleteFont( hMyFont );
			EndPaint( hDlg, &ps );
			break;
		}

		case WM_CTLCOLORSTATIC:
		{
			if( (HWND) lParam == GetDlgItem( hDlg, IDC_APP_NAME ) )
			{
				HDC hDC = (HDC) wParam;
				SetBkMode( hDC, TRANSPARENT );
				SetBkColor( hDC, GetSysColor( COLOR_3DFACE ) );
				SetTextColor( hDC, RGB( 0,0,0xa0 ) );
				return (BOOL) (HBRUSH) GetSysColorBrush( COLOR_3DFACE );
			}
			else return FALSE;
			break;
		}
		case WM_DESTROY:
		{
			DeleteFont( hBold );
			hBold = NULL;
			KillTimer( hDlg, TIMER_ID_ABOUT );
			break;
		}
		default:
		{
			return 0L;
		}
	}
    return 1L;
}