Example #1
0
// "GotoURL" function by Stuart Patterson
// As seen in the August, 1997 Windows Developer's Journal.
HINSTANCE CHyperLink::GotoURL(LPCTSTR url, int showcmd)
{
    TCHAR key[ 4096 ];	

	HINSTANCE result=0;

	memset( &key, 0, sizeof( key ) );
    // First try ShellExecute()
//    HINSTANCE result = ShellExecute(NULL, _T("open"), url, NULL,NULL, showcmd);

    // If it failed, get the .htm regkey and lookup the program
    if ((UINT)result <= HINSTANCE_ERROR) {		
		
        if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS)
		{
            lstrcat(key, _T("\\shell\\open\\command"));

            if (GetRegKey(HKEY_CLASSES_ROOT, key, key ) == ERROR_SUCCESS)
			{
                TCHAR *pos;
                pos = _tcsstr(key, _T("\"%1\""));
                if (pos == NULL) {                     // No quotes found
                    pos = _tcsstr( key, _T("%1"));       // Check for %1, without quotes
                    if (pos == NULL)                   // No parameter at all...
                        pos = key+lstrlen(key)-1;
                    else
                        *pos = '\0';                   // Remove the parameter
                }
                else
                    *pos = '\0';                       // Remove the parameter

                lstrcat(pos, _T(" "));
                lstrcat(pos, url);
                
                CUStringConvert strCnv;
                
                result = (HINSTANCE) WinExec( strCnv.ToACP( CUString(  key )), showcmd );
            }
        }
	}
	  
    return result;
}
Example #2
0
UINT CAutoDetect::OnStartDetection(void *lpParam)
{
	bThreadActive=TRUE;
	int nInsertItem=0;
	int Endian=0;
	CUString strTmp;
	CUString strOk;
	CUString strRead;
	CUString strEbl;
	CUString strEnd;
	CUString strDens;
	CUString strAtapi;

	g_pThread->BeginWaitCursor();

	CAutoDetect* pDlg=(CAutoDetect*)lpParam;

	CDROMPARAMS cdTest;
	CR_GetCDROMParameters(&cdTest);


	CUString ReadMethodDescr[]={	_W("MMC     "),
								_W("Standard"),
								_W("Nec     "),
								_W("Sony    "),
								_W("MMC1    "),
								_W("MMC2    "),
								_W("MMC3    "),
								_W("Read C1 "),
								_W("Read C2 "),
								_W("Read C3 "),
								_W("MMC4    "),
								_W("????????")};

	CUString EnableDescr[]={		g_language.GetString( IDS_NONE ),
								g_language.GetString( IDS_STANDARD ),
								_W( "????" )};

	// Write header to Log file
	dbgFile.printf( "ATAPI\tREAD\t\tENABLE\t\t%DENS\tENDIAN\tRESULT\n" );

	for (int atapi = 0; atapi < NUMATAPI; atapi++ )
	{
		if ( 0 == atapi )
		{
			cdTest.DriveTable.bAtapi = FALSE;
			strAtapi = g_language.GetString( IDNO );
		}
		else
		{
			cdTest.DriveTable.bAtapi = TRUE;
			strAtapi = g_language.GetString( IDYES );
		}


		for (int rm = 0; rm < NUMREADMETHODS; rm++ )
		{
			strRead=ReadMethodDescr[ rm ];

			for (int en=0;en<NUMENABLEMODES;en++)
			{
				strEbl = EnableDescr[ en ];

				for (int ds=0;ds<NUMDENSITIES;ds++)
				{
					cdTest.DriveTable.nDensity = CheckDensities[ds];

					strDens.Format( _W( "%2x" ), cdTest.DriveTable.nDensity );

                    CUStringConvert strCnv;
                    CUStringConvert strCnv1;
                    CUStringConvert strCnv2;
                    CUStringConvert strCnv3;

					// Log what we are doing to file
					dbgFile.printf("%s\t%s\t%s\t%s\t",
                        strCnv.ToACP( strAtapi ),
                        strCnv1.ToACP( strRead ),
                        strCnv2.ToACP( strEbl ),
                        strCnv3.ToACP( strDens ) );

					cdTest.DriveTable.ReadMethod= READMETHOD( rm );

					switch ( cdTest.DriveTable.ReadMethod )  
					{
						case READMMC:
						case READMMC2:
						case READMMC3:
						case READMMC4:
							cdTest.DriveTable.SetSpeed= SPEEDMMC;
						break;
						case READSONY:
							cdTest.DriveTable.SetSpeed= SPEEDSONY;
						break;
						case READ10:
						case READNEC:
						case READC1:
						case READC2:
						case READC3:
						default:
							cdTest.DriveTable.SetSpeed= SPEEDNONE;
						break;
					}

					cdTest.DriveTable.EnableMode= ENABLEMODE(en);
					cdTest.DriveTable.Endian = ENDIAN_LITTLE;

					CDEX_ERR err = TestDrive( cdTest );

					strEnd = _T( "-" );

					if (err==CDEX_OK)
					{
						strOk = g_language.GetString( IDS_PASS );

						if ( ENDIAN_LITTLE == cdTest.DriveTable.Endian )
						{
							strEnd = g_language.GetString( IDS_LITTLEENDIAN );
						}
						else
						{
							strEnd = g_language.GetString( IDS_BIGENDIAN );
						}
					}
					else
					{
						strOk = g_language.GetString( IDS_FAIL );
					}


 					pDlg->m_List.InsertItem( nInsertItem, strCnv.ToT( strRead ) );
					pDlg->m_List.SetItemText( nInsertItem,1,strCnv.ToT( strAtapi ) );
					pDlg->m_List.SetItemText( nInsertItem,2,strCnv.ToT( strEbl ) );
					pDlg->m_List.SetItemText( nInsertItem,3,strCnv.ToT( strDens ) );
					pDlg->m_List.SetItemText( nInsertItem,4,strCnv.ToT( strEnd ) );
					pDlg->m_List.SetItemText( nInsertItem,5,strCnv.ToT( strOk ) );
					
					myDriveTable[nCurrentDrive++]=cdTest.DriveTable;

					ASSERT(nCurrentDrive<=nNumTableEntries);

					// Log success
					dbgFile.printf("%s\t%s\n",strEnd,strOk);

					nInsertItem++;

					::Sleep(0);

					if (pDlg->m_bAbort)
					{
						pDlg->	GetDlgItem(IDC_ABORT)->EnableWindow(FALSE);
						pDlg->GetDlgItem(IDOK)->EnableWindow(TRUE);
						g_pThread->EndWaitCursor();
						return 0;
					}
				}
			}
		}
	}

	pDlg->	GetDlgItem(IDC_ABORT)->EnableWindow(FALSE);
	pDlg->GetDlgItem(IDOK)->EnableWindow(TRUE);
	g_pThread->EndWaitCursor();

	return 0;
}