你先在注册表中找到ie的科执行文件的位置,然后在程序中可以用RegOpenKeyEx(),RegQueryValueEx()等函数从注册表中读数,具体用法查MSDN

解决方案 »

  1.   

    HKEY hKey;
        LPCTSTR lpPath="Software\\CSCW\\TmVconf\\TmStar\\"; 
        
        DWORD dwDisposition=REG_CREATED_NEW_KEY;
        long ret0 = RegCreateKeyEx( HKEY_LOCAL_MACHINE, lpPath, 0, 
            NULL,REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 
            NULL, &hKey, &dwDisposition);
        TRACE("go\n");
        if(ret0!=ERROR_SUCCESS)  
        {
            TRACE0(_T("第一步:打开或者创建就失败了。\n"));
            return ;
        }
        
       if ( dwDisposition == REG_CREATED_NEW_KEY)
        {
            LPBYTE    lpKeyValue;    
            DWORD    cbBufferSize=80;  
            lpKeyValue = (unsigned char *)"1";
            
            long ret1 = RegSetValueEx(hKey, TEXT("name"), 0, 
                REG_SZ, lpKeyValue, cbBufferSize);
            if (ret1 != ERROR_SUCCESS) {
                TRACE0(_T("不行呀,我创建不了name这个键值。\n"));
                RegCloseKey(hKey);
                return ;  }
            
            long ret2 = RegSetValueEx(hKey, TEXT("address"), 0, 
                REG_SZ, lpKeyValue, cbBufferSize);
            if (ret2 != ERROR_SUCCESS) {
                TRACE0(_T("不行呀,我创建不了address这个键值。\n"));
                RegCloseKey(hKey);
                return ;  }        RegCloseKey(hKey);
            return ;
       }
        else 
        {  
    TRACE("else\n");
            LPBYTE    lpKeyValue1;
    lpKeyValue1=new BYTE[80];

            DWORD    datatype=REG_SZ ; 
            DWORD    cbBufferSize=80;  
            
            long ret1 =::RegQueryValueEx( hKey, TEXT("name"), NULL,  
                &datatype, lpKeyValue1,  &cbBufferSize);            
            
            if(ret1 != ERROR_SUCCESS) 
            { 
                MessageBox("错误: 无法查询有关注册表name信息!\n"); 
                ::RegCloseKey(hKey);
                return ; 
            } 
            
            LPBYTE    lpKeyValue2;
    lpKeyValue2=new BYTE[80];

            
            long ret2=::RegQueryValueEx( hKey, TEXT("address"), NULL,  
                &datatype, lpKeyValue2,  &cbBufferSize);            
            
            if(ret2!=ERROR_SUCCESS) 
            { 
                MessageBox("错误: 无法查询有关注册表address信息!\n"); 
                ::RegCloseKey(hKey);
                return ; 
            } 
            TRACE("%s",lpKeyValue2);
            m_strName = CString(lpKeyValue1);
            m_strCompany   = CString(lpKeyValue2);    
            UpdateData(FALSE);
            
            ::RegCloseKey(hKey);
    delete []lpKeyValue1;
    delete []lpKeyValue2;
            return ;
        }
      

  2.   

    HINSTANCE GotoURL(LPCTSTR url, int showcmd)
    {
        TCHAR key[MAX_PATH + MAX_PATH];
        // 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 = strstr(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);
                    result = (HINSTANCE) WinExec(key,showcmd);
                }
            }
    }   
        return result;
    }
      

  3.   

    直接ShellExecute打开IE,何必那么麻烦!