none
怎麼知道電腦裡裝了什麼office RRS feed

  • 問題

  • 或是說

    如何證明已安裝了word ,而且知道其版本

    簡單的說

    想寫一個能偵測該電腦裝了那些office 各是什麼application及version是那一版

    我知道要抓reg key,但是我不知道如何證明

    2006年12月4日 上午 08:23

解答

所有回覆

  • 2006年12月4日 下午 12:39
    版主
  •  

    謝謝你

    那裡的方法是使用者去確認

    我的問題是如何由程式判讀????

     

    2006年12月7日 上午 12:36
  • 1.  如果連路徑都不知道,就算告訴你用哪個類別也沒用啊?

    2. 讀寫登錄資料庫,可用 Microsoft.Win32.RegistryKey 來做,而判斷檔案則可以用 FileVersionInfo.GetVersionInfo() 來取得檔案版本來判讀:

    Sub GetFileVersion()
        ' Get the file version for the notepad.
        Dim myFileVersionInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo("%systemroot%\Notepad.exe")
        
        ' Print the file name and version number.
        textBox1.Text = "File: " & myFileVersionInfo.FileDescription & ControlChars.Cr & _
            "Version number: " & myFileVersionInfo.FileVersion
    End Sub 'GetFileVersion
    ' 以下為 RegistryKey 的範例:
    Imports Microsoft.VisualBasic
    Imports System
    Imports System.Security.Permissions
    Imports Microsoft.Win32
    
    <Assembly: RegistryPermissionAttribute( _
        SecurityAction.RequestMinimum, ViewAndModify := "HKEY_CURRENT_USER")>
    
    Public Class RegKey
        Shared Sub Main()
        
            ' Create a subkey named Test9999 under HKEY_CURRENT_USER.
            Dim test9999 As RegistryKey = _
                Registry.CurrentUser.CreateSubKey("Test9999")
    
            ' Create two subkeys under HKEY_CURRENT_USER\Test9999.
            test9999.CreateSubKey("TestName").Close()
            Dim testSettings As RegistryKey = _
                test9999.CreateSubKey("TestSettings")
    
            ' Create data for the TestSettings subkey.
            testSettings.SetValue("Language", "French")
            testSettings.SetValue("Level", "Intermediate")
            testSettings.SetValue("ID", 123)
            testSettings.Close()
    
            ' Print the information from the Test9999 subkey.
            Console.WriteLine("There are {0} subkeys under Test9999.", _
                test9999.SubKeyCount.ToString())
            For Each subKeyName As String In test9999.GetSubKeyNames()
                Dim tempKey As RegistryKey = _
                    test9999.OpenSubKey(subKeyName)
                Console.WriteLine(vbCrLf & "There are {0} values for " & _
                    "{1}.", tempKey.ValueCount.ToString(), tempKey.Name)
                For Each valueName As String In tempKey.GetValueNames()
                    Console.WriteLine("{0,-8}: {1}", valueName, _
                        tempKey.GetValue(valueName).ToString())
                Next
            Next
    
            ' Delete the ID value.
            testSettings = test9999.OpenSubKey("TestSettings", True)
            testSettings.DeleteValue("id")
    
            ' Verify the deletion.
            Console.WriteLine(CType(testSettings.GetValue( _
                "id", "ID not found."), String))
            testSettings.Close()
    
            ' Delete or close the new subkey.
            Console.Write(vbCrLf & "Delete newly created " & _
                "registry key? (Y/N) ")
            If Char.ToUpper(Convert.ToChar(Console.Read())) = "Y"C Then
                Registry.CurrentUser.DeleteSubKeyTree("Test9999")
                Console.WriteLine(vbCrLf & "Registry key {0} deleted.", _
                    test9999.Name)
            Else
                Console.WriteLine(vbCrLf & "Registry key {0} closed.", _
                    test9999.ToString())
                test9999.Close()
            End If
       
        End Sub
    End Class
    
    2006年12月7日 上午 02:11
    版主
  •  

    謝謝你熱心的回應

    也許是我題目寫的不清楚

    還是很謝謝你

    2006年12月14日 上午 07:53