Exemple #1
0
bool CFileAssoc::Register(CString ext, CString strLabel, bool bRegister, bool bRegisterContextMenuEntries, bool bAssociatedWithIcon)
{
    CRegKey key;
    CString strProgID = PROGID + ext;

    if (!bRegister) {
        // On Windows 8, an app can't set itself as the default handler for a format
        if (!SysVersion::Is8OrLater() && bRegister != IsRegistered(ext)) {
            SetFileAssociation(ext, strProgID, bRegister);
        }

        key.Attach(HKEY_CLASSES_ROOT);
        key.RecurseDeleteKey(strProgID);

        if (ERROR_SUCCESS == key.Open(HKEY_LOCAL_MACHINE, m_strRegAppFileAssocKey)) {
            key.DeleteValue(ext);
        }

        return true;
    } else {
        // Create ProgID for this file type
        if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID)
                || ERROR_SUCCESS != key.SetStringValue(nullptr, strLabel)) {
            return false;
        }

        if (m_bNoRecentDocs) {
            key.SetStringValue(_T("NoRecentDocs"), _T(""));
        } else {
            key.DeleteValue(_T("NoRecentDocs"));
        }

        CString appIcon = "\"" + GetProgramPath(true) + "\",0";

        // Add to playlist option
        if (bRegisterContextMenuEntries) {
            if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\enqueue"))
                    || ERROR_SUCCESS != key.SetStringValue(nullptr, ResStr(IDS_ADD_TO_PLAYLIST))
                    || ERROR_SUCCESS != key.SetStringValue(_T("Icon"), appIcon)
                    || ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\enqueue\\command"))
                    || ERROR_SUCCESS != key.SetStringValue(nullptr, m_strEnqueueCommand)) {
                return false;
            }
        } else {
            key.Close();
            key.Attach(HKEY_CLASSES_ROOT);
            key.RecurseDeleteKey(strProgID + _T("\\shell\\enqueue"));
        }

        // Play option
        if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open"))) {
            return false;
        }
        if (bRegisterContextMenuEntries) {
            if (ERROR_SUCCESS != key.SetStringValue(nullptr, ResStr(IDS_OPEN_WITH_MPC))
                    || ERROR_SUCCESS != key.SetStringValue(_T("Icon"), appIcon)) {
                return false;
            }
        } else {
            if (ERROR_SUCCESS != key.SetStringValue(nullptr, _T(""))
                    || ERROR_SUCCESS != key.SetStringValue(_T("Icon"), _T(""))) {
                return false;
            }
        }

        if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"))
                || ERROR_SUCCESS != key.SetStringValue(nullptr, m_strOpenCommand)) {
            return false;
        }

        if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE, m_strRegAppFileAssocKey)
                || key.SetStringValue(ext, strProgID)) {
            return false;
        }

        if (bAssociatedWithIcon) {
            if (auto iconLib = GetIconLib()) {
                int iconIndex = iconLib->GetIconIndex(ext);

                /* icon_index value -1 means no icon was found in the iconlib for the file extension */
                if (iconIndex >= 0 && ExtractIcon(AfxGetApp()->m_hInstance, m_iconLibPath, iconIndex)) {
                    appIcon.Format(_T("\"%s\",%d"), m_iconLibPath, iconIndex);
                }
            }

            if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon"))
                    || ERROR_SUCCESS != key.SetStringValue(nullptr, appIcon)) {
                return false;
            }
        } else {
            key.Close();
            key.Attach(HKEY_CLASSES_ROOT);
            key.RecurseDeleteKey(strProgID + _T("\\DefaultIcon"));
        }

        // On Windows 8, an app can't set itself as the default handler for a format
        if (!SysVersion::Is8OrLater() && bRegister != IsRegistered(ext)) {
            SetFileAssociation(ext, strProgID, bRegister);
        }

        return true;
    }
}
Exemple #2
0
bool ToolCollection::RegisterURLProtocal(const CAtlStringW protocalname,const CAtlStringW cmdline)
{
	CAtlStringW temp,cmd,icon;
	::GetModuleFileNameW(nullptr,temp.GetBuffer(MAX_PATH),MAX_PATH);
	temp.ReleaseBuffer();
	cmd.Format(L"\"%s\" %s",temp,cmdline);
	icon.Format(L"\"%s\",1",temp);

	CRegKey regroot;
	bool rebuild=true;
	if(ERROR_SUCCESS==regroot.Open(HKEY_CLASSES_ROOT,protocalname))
	{
		CRegKey checkcmd;
		if(ERROR_SUCCESS==checkcmd.Open(regroot,L"shell\\open\\command"))
		{
			ULONG count=MAX_PATH+20;
			if(ERROR_SUCCESS==checkcmd.QueryStringValue(nullptr,temp.GetBuffer(count),&count))
			{
				temp.ReleaseBuffer();
				if(temp.CompareNoCase(cmd)==0)
				{
					rebuild=false;
				}
			}
			else
				temp.ReleaseBuffer();
		}
		if(rebuild==false)
		{
			DWORD index=0;
			ULONG count=260;
			rebuild=true;
			while(ERROR_SUCCESS==regroot.EnumKey(index,temp.GetBuffer(count),&count))
			{
				temp.ReleaseBuffer();
				index++;
				if(temp.CompareNoCase(L"URL Protocol")==0)
				{
					rebuild=false;
					break;
				}
			}
		}
	}
	if(rebuild)
	{
		temp.Format(L"URL:%s Protocol",protocalname);
		regroot.Close();
		if(regroot.Create(HKEY_CLASSES_ROOT,protocalname)==ERROR_SUCCESS)
		{
			regroot.SetStringValue(nullptr,temp);
			regroot.SetStringValue(L"URL Protocol",L"");
			CRegKey subkey;
			if(ERROR_SUCCESS==subkey.Create(regroot,L"DefaultIcon"))
			{
				subkey.SetStringValue(nullptr,icon);
				subkey.Close();
			}
			if(ERROR_SUCCESS==subkey.Create(regroot,L"shell\\open\\command"))
			{
				subkey.SetStringValue(nullptr,cmd);
				subkey.Close();
			}
		}
	}
	return true;
}
CPagetestBase::CPagetestBase(void):
	available(false)
	, abm(1)
	, openRequests(0)
	, testUrl(_T(""))
	, timeout(240)
  , activityTimeout(ACTIVITY_TIMEOUT)
	, exitWhenDone(false)
	, interactive(false)
	, runningScript(false)
	, cached(-1)
	, script_ABM(-1)
	, haveBasePage(false)
	, processed(false)
	, basePageRedirects(0)
	, hMainWindow(NULL)
	, hBrowserWnd(NULL)
	, ieMajorVer(0)
	, ignoreSSL(0)
	, blockads(0)
  , imageQuality(JPEG_DEFAULT_QUALITY)
  , pngScreenShot(0)
  , bodies(0)
  , keepua(0)
  , minimumDuration(0)
  , clearShortTermCacheSecs(0)
  , _SetGDIWindow(NULL)
  , _SetGDIWindowUpdated(NULL)
  , _GDIWindowUpdated(NULL)
  , windowUpdated(false)
  , hGDINotifyWindow(NULL)
  , titleTime(0)
  , currentRun(0)
{
	QueryPerformanceFrequency((LARGE_INTEGER *)&freq);
	msFreq = freq / (__int64)1000;
	
	winInetRequests.InitHashTable(257);
	requestSocketIds.InitHashTable(257);
	threadWindows.InitHashTable(257);
	openSockets.InitHashTable(257);
  client_ports.InitHashTable(257);

	// create a NULL DACL we will re-use everywhere we do file access
	ZeroMemory(&nullDacl, sizeof(nullDacl));
	nullDacl.nLength = sizeof(nullDacl);
	nullDacl.bInheritHandle = FALSE;
	if( InitializeSecurityDescriptor(&SD, SECURITY_DESCRIPTOR_REVISION) )
		if( SetSecurityDescriptorDacl(&SD, TRUE,(PACL)NULL, FALSE) )
			nullDacl.lpSecurityDescriptor = &SD;

	InitializeCriticalSection(&cs);
	InitializeCriticalSection(&csBackground);

	// figure out what version of IE is installed
	CRegKey key;
	if( key.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Internet Explorer"), KEY_READ) == ERROR_SUCCESS )
	{
		TCHAR buff[1024];
		ULONG len = _countof(buff);
		if( key.QueryStringValue(_T("Version"), buff, &len ) == ERROR_SUCCESS )
			ieMajorVer = _ttoi(buff);

		key.Close();
	}

  // connect to the global GDI hook if it is present
	TCHAR hookDll[MAX_PATH];
	if( GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase), hookDll, _countof(hookDll)) )
  {
    lstrcpy(PathFindFileName(hookDll), _T("wptghook.dll"));
    HMODULE hHookDll = LoadLibrary(hookDll);
    if (hHookDll)
    {
      _SetGDIWindow = (SETGDIWINDOW)GetProcAddress(hHookDll, "_SetGDIWindow@12");
      _SetGDIWindowUpdated = (SETGDIWINDOWUPDATED)GetProcAddress(hHookDll, "_SetGDIWindowUpdated@4");
      _GDIWindowUpdated = (GDIWINDOWUPDATED)GetProcAddress(hHookDll, "_GDIWindowUpdated@0");
    }
  }

  // load some settings that we need before starting
  if( key.Open(HKEY_CURRENT_USER, _T("Software\\America Online\\SOM"), KEY_READ | KEY_WRITE) == ERROR_SUCCESS ) {
    key.QueryDWORDValue(_T("Run"), currentRun);
		key.QueryDWORDValue(_T("Cached"), cached);
    key.Close();
  }

  // Instantiate the DOM interface that we're going to attach to the DOM for script to interact
  #ifndef PAGETEST_EXE
  if( SUCCEEDED(CComObject<CWebPagetestDOM>::CreateInstance(&webpagetestDom)) )
    webpagetestDom->AddRef();
  #endif
}
void CFileTypesForm::OnBnClickedButtonReload()
{
    for (DWORD i=0; i<pageCount; i++)
    {
        if (pages[i])
        {
            pages[i]->info.Clear();
            pages[i]->UpdateTree();
        }
    }

    DSUtil::FilterTemplates filters;
    filters.EnumerateAllRegisteredFilters();

    // search for registered protocols
    if (page_protocols)
    {
        ATL::CRegKey rkRoot(HKEY_CLASSES_ROOT);
        // only real protocols => not something like "WMP11.AssocProtocol.MMS"
        // faster, because i don't need to search in every entry for "Source Filter"
        TCHAR szName[10] = {0};
        DWORD szNameLength = 10;
        DWORD i = 0;
        long ret = 0;
        while (ERROR_NO_MORE_ITEMS != (ret = rkRoot.EnumKey(i++, szName, &szNameLength)))
        {
            if (ret != ERROR_SUCCESS)
                continue;

            CRegKey rkKey;
            if(ERROR_SUCCESS == rkKey.Open(HKEY_CLASSES_ROOT, szName, KEY_READ))
            {
                TCHAR szSourceFilterGuid[40] = {0};
                DWORD szLength = 40;
                if (ERROR_SUCCESS == rkKey.QueryStringValue(_T("Source Filter"), szSourceFilterGuid, &szLength))
                {
                    GraphStudio::PropItem* group = new GraphStudio::PropItem(CString(szName));

                    CString strClsid = szSourceFilterGuid;
                    GUID clsid = {0};
                    CLSIDFromString((LPOLESTR)strClsid.GetBuffer(), &clsid);

                    group->AddItem(new GraphStudio::PropItem(_T("CLSID"), CString(szSourceFilterGuid), false));

                    DSUtil::FilterTemplate ft;
		            if (filters.FindTemplateByCLSID(clsid, &ft))
                    {
                        group->AddItem(new GraphStudio::PropItem(_T("Name"), CString(ft.name), false));
                        group->AddItem(new GraphStudio::PropItem(_T("File"), CString(ft.file), false));
                    }

                    // last Change of this key
                    FILETIME timeMod = {0};
                    if (ERROR_SUCCESS == RegQueryInfoKey(rkKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &timeMod))
                        group->AddItem(new GraphStudio::PropItem(_T("Modified"), CTime(timeMod)));

                    page_protocols->info.AddItem(group);
                }
            }
            rkKey.Close();
            szNameLength = 10;
        }
        page_protocols->UpdateTree();
        rkRoot.Close();
    }

    // search for registered extensions
    if (page_extensions)
    {
        ATL::CRegKey rkRoot;
        CString strRoot = _T("Media Type\\Extensions");
        if (ERROR_SUCCESS == rkRoot.Open(HKEY_CLASSES_ROOT, strRoot, KEY_READ))
        {
            // {7DF62B50-6843-11D2-9EEB-006008039E37}
            static const GUID CLSID_StillVideo = {0x7DF62B50, 0x6843, 0x11D2, { 0x9E, 0xEB, 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37} };

            TCHAR szName[50] = {0};
            DWORD szNameLength = 50;
            DWORD i = 0;
            while (ERROR_NO_MORE_ITEMS != rkRoot.EnumKey(i++, szName, &szNameLength))
            {
                CString strKey = strRoot;
                strKey.Append(_T("\\"));
                strKey.Append(szName);
                CRegKey rkKey;
                if(ERROR_SUCCESS == rkKey.Open(HKEY_CLASSES_ROOT, strKey, KEY_READ))
                {
                    GraphStudio::PropItem* group = new GraphStudio::PropItem(CString(szName));

                    TCHAR szGuid[40] = {0};
                    DWORD szLength = 40;
                    if (ERROR_SUCCESS == rkKey.QueryStringValue(_T("Source Filter"), szGuid, &szLength))
                    {
                        CString strClsid = szGuid;
                        GUID clsid = {0};
                        CLSIDFromString((LPOLESTR)strClsid.GetBuffer(), &clsid);
                        group->AddItem(new GraphStudio::PropItem(_T("CLSID"), CString(szGuid), false));

                        DSUtil::FilterTemplate ft;
		                if (filters.FindTemplateByCLSID(clsid, &ft))
                        {
                            group->AddItem(new GraphStudio::PropItem(_T("Name"), CString(ft.name), false));
                            group->AddItem(new GraphStudio::PropItem(_T("File"), CString(ft.file), false));
                        }
                        else if (clsid == CLSID_StillVideo)
                        {
                            group->AddItem(new GraphStudio::PropItem(_T("Name"), _T("Generate Still Video"), false));
                        }
                    }

                    szLength = 40;
                    if (ERROR_SUCCESS == rkKey.QueryStringValue(_T("Media Type"), szGuid, &szLength))
                    {
                        CString strMT;
                        GUID clsidMT = {0};
                        CLSIDFromString((LPOLESTR)strMT.GetBuffer(), &clsidMT);
                        GraphStudio::NameGuid(clsidMT,strMT,CgraphstudioApp::g_showGuidsOfKnownTypes);
                        group->AddItem(new GraphStudio::PropItem(_T("MediaType"), strMT, false));
                    }

                    szLength = 40;
                    if (ERROR_SUCCESS == rkKey.QueryStringValue(_T("SubType"), szGuid, &szLength))
                    {
                        CString strST = szGuid;
                        GUID clsidST = {0};
                        CLSIDFromString((LPOLESTR)strST.GetBuffer(), &clsidST);
                        GraphStudio::NameGuid(clsidST,strST,CgraphstudioApp::g_showGuidsOfKnownTypes);
                        group->AddItem(new GraphStudio::PropItem(_T("SubType"), strST, false));
                    }

                    // last Change of this key
                    FILETIME timeMod = {0};
                    if (ERROR_SUCCESS == RegQueryInfoKey(rkKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &timeMod))
                        group->AddItem(new GraphStudio::PropItem(_T("Modified"), CTime(timeMod)));

                    page_extensions->info.AddItem(group);
                }
                rkKey.Close();
                szNameLength = 50;
            }
            page_extensions->UpdateTree();
        }
        rkRoot.Close();
    }

    // search for registered byte pattern
    if (page_bytes)
    {
        ATL::CRegKey rkRoot;
        CString strRoot = _T("Media Type");
        if (ERROR_SUCCESS == rkRoot.Open(HKEY_CLASSES_ROOT, strRoot, KEY_READ))
        {
            TCHAR szMTName[40] = {0};
            DWORD szMTNameLength = 40;
            DWORD i = 0;
            while (ERROR_NO_MORE_ITEMS != rkRoot.EnumKey(i++, szMTName, &szMTNameLength))
            {
                CString strMT = szMTName;
                GUID clsidMT = {0};
                if(NOERROR == CLSIDFromString((LPOLESTR)strMT.GetBuffer(), &clsidMT))
                {
                    GraphStudio::NameGuid(clsidMT,strMT,false);

                    CString strKeyMT = strRoot;
                    strKeyMT.Append(_T("\\"));
                    strKeyMT.Append(szMTName);
                    CRegKey rkKeyMT;
                    if(ERROR_SUCCESS == rkKeyMT.Open(HKEY_CLASSES_ROOT, strKeyMT, KEY_READ))
                    {
                        TCHAR szSTName[40] = {0};
                        DWORD szSTNameLength = 40;
                        DWORD j = 0;
                        while (ERROR_NO_MORE_ITEMS != rkKeyMT.EnumKey(j++, szSTName, &szSTNameLength))
                        {
                            CString strST = szSTName;
                            GUID clsidST = {0};
                            if(NOERROR == CLSIDFromString((LPOLESTR)strST.GetBuffer(), &clsidST))
                            {
                                GraphStudio::NameGuid(clsidST,strST,false);

                                CString strKeyST = strKeyMT;
                                strKeyST.Append(_T("\\"));
                                strKeyST.Append(szSTName);
                                CRegKey rkKeyST;

                                if(ERROR_SUCCESS == rkKeyST.Open(HKEY_CLASSES_ROOT, strKeyST, KEY_READ))
                                {
                                    TCHAR szGuid[40] = {0};
                                    DWORD szLength = 40;
                                    if (ERROR_SUCCESS == rkKeyST.QueryStringValue(_T("Source Filter"), szGuid, &szLength))
                                    {
                                        CString groupName = strMT;
                                        groupName.Append(_T("\\"));
                                        groupName.Append(strST);
                                        GraphStudio::PropItem* group = new GraphStudio::PropItem(groupName);

                                        CString strClsid = szGuid;
                                        GUID clsid = {0};
                                        CLSIDFromString((LPOLESTR)strClsid.GetBuffer(), &clsid);
                                        group->AddItem(new GraphStudio::PropItem(_T("CLSID"), CString(szGuid), false));

                                        DSUtil::FilterTemplate ft;
		                                if (filters.FindTemplateByCLSID(clsid, &ft))
                                        {
                                            group->AddItem(new GraphStudio::PropItem(_T("Name"), CString(ft.name), false));
                                            group->AddItem(new GraphStudio::PropItem(_T("File"), CString(ft.file), false));
                                        }

                                        // Enumerate the values
                                        TCHAR szValueName[5] = {0};
                                        DWORD szValueNameLength = 5;
                                        DWORD dwRegType;
                                        DWORD k = 0;
                                        long ret = 0;
                                        while (ERROR_NO_MORE_ITEMS != (ret = RegEnumValue(rkKeyST, k++, szValueName, &szValueNameLength, NULL, &dwRegType, NULL, NULL)))
                                        {
                                            if (dwRegType == REG_SZ && ret == ERROR_SUCCESS)
                                            {
                                                TCHAR szValue[255] = {0};
                                                DWORD szValueLength = 255;
                                                if (ERROR_SUCCESS == rkKeyST.QueryStringValue(szValueName, szValue, &szValueLength))
                                                {
                                                    CString strValue = szValue;
                                                    CStringArray arValues;
                                                    DSUtil::Tokenizer(strValue, _T(","), arValues);
                                                    
                                                    CString strResultValue;
                                                    bool lastTokenWasEmpty = false;
                                                    for (int i=0; i<arValues.GetCount(); i++)
                                                    {
                                                        CString strToken = arValues.GetAt(i);
                                                        strToken = strToken.Trim();

                                                        switch (i % 4)
                                                        {
                                                            case 0:
                                                                if (i > 0) strResultValue.Append(_T(" && ["));
                                                                else strResultValue.Append(_T("["));
                                                                strResultValue.Append(strToken);
                                                                break;

                                                            case 1:
                                                                strResultValue.Append(_T(","));
                                                                strResultValue.Append(strToken);
                                                                break;

                                                            case 2:
                                                                strResultValue.Append(_T("] => ("));
                                                                strResultValue.Append(ByteFormatString(strToken));
                                                                break;

                                                            case 3:
                                                                if (!lastTokenWasEmpty) strResultValue.Append(_T(" = "));
                                                                strResultValue.Append(ByteFormatString(strToken));
                                                                strResultValue.Append(_T(")"));
                                                                break;
                                                        }

                                                        lastTokenWasEmpty = strToken.IsEmpty();
                                                    }

                                                    group->AddItem(new GraphStudio::PropItem(CString(szValueName), strResultValue, false));
                                                    // TODO maybe better format of the byte string
                                                }
                                            }
                                            szValueNameLength = 5;
                                        }

                                        // last Change of this key
                                        FILETIME timeMod = {0};
                                        if (ERROR_SUCCESS == RegQueryInfoKey(rkKeyST, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &timeMod))
                                            group->AddItem(new GraphStudio::PropItem(_T("Modified"), CTime(timeMod)));

                                        page_bytes->info.AddItem(group);
                                    }
                                }
                                rkKeyST.Close();
                            }
                            szSTNameLength = 40;
                        }
                    }
                    rkKeyMT.Close();
                }
                szMTNameLength = 40;
            }
            page_bytes->UpdateTree();
        }
        rkRoot.Close();
    }
}
int main(int /*argc*/, char ** /*argv*/)
{
	nVidiaWindows = false;
//	nVidiaWindows = true;

#ifdef WIN32
	/* Set a couple of settings in the registry for the nVidia detonator driver.
	 * So this is very specific...
	 */
	if (nVidiaWindows)
	{
		LONG lresult;
		HKEY hkey = 0;
		DWORD dwd = 0;
		//unsigned char buffer[128];

		CRegKey regkey;
		//DWORD keyValue;
//		lresult = regkey.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable");
		lresult = regkey.Open(HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable",
		                      KEY_ALL_ACCESS);

		if (lresult == ERROR_SUCCESS)
			printf("Succesfully opened key\n");
#if 0
		lresult = regkey.QueryValue(&keyValue, "StereoEnable");
		if (lresult == ERROR_SUCCESS)
			printf("Succesfully queried key\n");
#endif
		lresult = regkey.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\Stereo3D\\StereoEnable",
		                          "1");
		if (lresult == ERROR_SUCCESS)
			printf("Succesfully set value for key\n");
		regkey.Close();
		if (lresult == ERROR_SUCCESS)
			printf("Succesfully closed key\n");
//		regkey.Write("2");
	}
#endif  // WIN32

	// Create the system
	GHOST_ISystem::createSystem();
	fSystem = GHOST_ISystem::getSystem();

	if (fSystem) {
		// Create an application object
		Application app(fSystem);

		// Add the application as event consumer
		fSystem->addEventConsumer(&app);
                
		// Enter main loop
		while (!app.m_exitRequested) {
			//printf("main: loop\n");
			fSystem->processEvents(true);
			fSystem->dispatchEvents();
		}
	}

	// Dispose the system
	GHOST_ISystem::disposeSystem();

	return 0;
}
/*
	GetPlatformInfo()
*/
void CWindowsVersion::GetPlatformInfo(LPSTR pBuffer,int cbBuffer)
{
	CRegKey regkey;
	char key[REGKEY_MAX_KEY_NAME+1];
	char value[REGKEY_MAX_KEY_VALUE+1];
	int n = 0;

	n += _snprintf(pBuffer+n,cbBuffer-1-n,"%s - %s\r\n",m_szWindowsPlatform,m_szOsType);
	
	// NT
	if(m_OsVersionType==WINDOWS_NT || m_OsVersionType==WINDOWS_2000 || m_OsVersionType==WINDOWS_XP || m_OsVersionType==WINDOWS_VISTA || m_OsVersionType==WINDOWS_SEVEN)
	{
		regkey.Attach(HKEY_LOCAL_MACHINE);
		
		strcpyn(key,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",sizeof(key));
		if(regkey.Open(HKEY_LOCAL_MACHINE,key)==ERROR_SUCCESS)
		{
			DWORD dwSize;

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"CurrentBuildNumber",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"build: %s\r\n",value);

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"CurrentType",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"type: %s\r\n",value);

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"ProductId",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"product id: %s\r\n",value);

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"RegisteredOrganization",&dwSize)==ERROR_SUCCESS)
				if(value[0]!='\0')
					n += _snprintf(pBuffer+n,cbBuffer-1-n,"registered to: %s\r\n",value);

			regkey.Close();
		}
		
		regkey.Detach();

		regkey.Attach(HKEY_LOCAL_MACHINE);
		
		strcpyn(key,"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",sizeof(key));
		if(regkey.Open(HKEY_LOCAL_MACHINE,key)==ERROR_SUCCESS)
		{
			DWORD dwSize;

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"VendorIdentifier",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"\r\nMain CPU:\r\n%s\r\n",value);

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"Identifier",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"%s\r\n",value);

			DWORD dwValue = 0L;
			if(regkey.QueryValue(dwValue,"~MHz")==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"%ld Mhz\r\n",dwValue);

			regkey.Close();
		}
		
		regkey.Detach();
	}
	else // Cartoons
	{
		regkey.Attach(HKEY_LOCAL_MACHINE);
		
		strcpyn(key,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion",sizeof(key));
		if(regkey.Open(HKEY_LOCAL_MACHINE,key)==ERROR_SUCCESS)
		{
			DWORD dwSize;

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"VersionNumber",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"version number: %s\r\n",value);

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"ProductId",&dwSize)==ERROR_SUCCESS)
				n += _snprintf(pBuffer+n,cbBuffer-1-n,"product id: %s\r\n",value);

			dwSize = sizeof(value);
			memset(value,'\0',sizeof(value));
			if(regkey.QueryValue(value,"RegisteredOrganization",&dwSize)==ERROR_SUCCESS)
				if(value[0]!='\0')
					n += _snprintf(pBuffer+n,cbBuffer-1-n,"registered to: %s\r\n",value);

			regkey.Close();
		}
		
		regkey.Detach();
	}
}
Exemple #7
0
LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	// center the dialog on the screen
	//DlgResize_Init();
	
	//InitResizing(TRUE, TRUE, WS_THICKFRAME | WS_CLIPCHILDREN);
	CenterWindow();
	// set icons
	HICON hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_TRIEXPORTER), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);
	SetIcon(hIcon, TRUE);
	HICON hIconSmall = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_SMALL), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
	SetIcon(hIconSmall, FALSE);
	file = new TriFile;
	// register object for message filtering and idle updates
	loaded = false;
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);
	//UIAddChildWindowContainer(m_hWnd);
	menu.Attach(GetMenu());
	m_Tree = GetDlgItem(IDC_TREE);
	il.Create(16,16, ILC_COLOR32,0,0);
	HANDLE bmp = LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_ICONS),IMAGE_BITMAP,0,0,LR_LOADTRANSPARENT);
	il.Add((HBITMAP)bmp);
	DeleteObject(bmp);
	m_Tree.SetImageList(il, TVSIL_NORMAL);
	m_p3d.SubclassWindow(GetDlgItem(IDC_PREVIEW));
	m_Scale.Attach(GetDlgItem(IDC_SCALE));
	m_Light.Attach(GetDlgItem(IDC_LIGHT));
	m_Fps.Attach(GetDlgItem(IDC_FPS));
	m_eScale.Attach(GetDlgItem(IDC_ESCALE));
	m_Texture.Attach(GetDlgItem(IDC_TEXTURE));
	m_VSize.Attach(GetDlgItem(IDC_VSIZE));
	m_TriVersion.Attach(GetDlgItem(IDC_TRIVERSION));
	m_VCount.Attach(GetDlgItem(IDC_VCOUNT));
	m_BoxMax.Attach(GetDlgItem(IDC_BOXMAX));
	m_BoxMin.Attach(GetDlgItem(IDC_BOXMIN));
	m_SurType.Attach(GetDlgItem(IDC_SURTYPE));
	m_SurCount.Attach(GetDlgItem(IDC_SURCOUNT));
	m_Textures.Attach(GetDlgItem(IDC_TEXTURES));
	m_Add.Attach(GetDlgItem(IDC_ADD));
	m_Remove.Attach(GetDlgItem(IDC_REMOVE));
	m_Select.Attach(GetDlgItem(IDC_SELECT));
	// Attach all 10 Checkboxes
	for(int i=0; i<10; i++)
		m_ChkSurfaces[i].Attach(GetDlgItem(IDC_SURFACE1+i));
	m_Scale.SetRange(0, 19);
	m_Scale.SetPageSize(5);
	m_UpDown.Attach(GetDlgItem(IDC_UPDOWN));
	m_Light.SetRange(0, 360);
	m_Light.SetPageSize(1);
	m_Light.SetPos(100);
	m_p3d.alight = 100/(180/D3DX_PI);
	CRegKey rk;
	if(rk.Open(HKEY_CURRENT_USER, "Software\\TriExporter") == ERROR_SUCCESS)
	{
		ULONG g=256;
		TCHAR path[256];
		rk.QueryStringValue("EVE", path, &g);
		rk.Close();
		if (sc.LoadDir(path))
			FillTree();
	}
	m_p3d.Render();
	EnableAll(FALSE);
	return TRUE;
}