我遇到了一些問題,我寫了一個VB程序,還有一個setup.exe訪問64位操作系統中的Windows註冊表,如Win2k8或Win2k3。VB2010和訪問Windows註冊表
第一部分:SETUP.EXE和Windows註冊表問題 首先,我將用setup.exe解釋問題。在安裝過程中,我有一個自定義操作在安裝過程中關閉,以便將註冊表更改爲:
HKLM/Software/Microsoft/Windows NT/CurrentVersion/WinLogin/Userinit。
在32位操作系統,它工作正常,但在64位操作系統它寫到:
HKLM /軟件/ WOW6432Node /微軟/的Windows NT/CURRENTVERSION/Winlogon中/ USERINIT這裏
我的問題是,當用戶登錄時,登錄過程不會從此位置讀取。我明白爲什麼它訪問64位註冊表的32位部分。這是因爲setup.exe是一個32位的進程。我無法找到任何地方,我可以將其設置爲64位。也許所有的setup.exe都是32位的,我不知道我是創建安裝程序的新手。有關如何克服這個問題的想法?
第二部分:問題與64位進程訪問Windows註冊表 我的程序運行時,第二個問題是在用戶登錄之後它的假設來設置防止用戶運行「任務管理器」註冊表值。並能夠殺死該應用程序。我知道這可能是一種糟糕的編碼習慣來規避Windows的安全性,但這是我爲公司編寫的內部應用程序。
下面的代碼是觸發執行任務管理器鎖定和解鎖的功能。在32位系統上它工作得很好,它是64位的,它不起作用。當啓用UAC時也有一些問題。我不希望提示用戶以管理員身份運行,也不知道如何執行此操作。有任何想法嗎?
Private Sub taskMgrState(ByVal state As String)
Dim hive As String = "HKEY_CURRENT_USER\"
Dim systemSubKey As String = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
If state = "enabled" Then
'enable task manager use
'create the subkey for later use
If My.Computer.Registry.GetValue(hive & systemSubKey, "DisableTaskMgr", Nothing) Is Nothing Then
My.Computer.Registry.LocalMachine.CreateSubKey(systemSubKey)
End If
'set DisableTaskMgr valuename to 0 which disables blocking the running of task manager
My.Computer.Registry.SetValue(hive & systemSubKey, "DisableTaskMgr", 0)
ElseIf state = "disabled" Then
'disable the use of the task manager while this app is running
If My.Computer.Registry.GetValue(hive & systemSubKey, "DisableTaskMgr", Nothing) Is Nothing Then
My.Computer.Registry.LocalMachine.CreateSubKey(systemSubKey)
End If
'set DisableTaskMgr valuename to 0 which disables blocking the running of task manager
My.Computer.Registry.SetValue(hive & systemSubKey, "DisableTaskMgr", 1)
End If
End Sub
爲什麼你不使用組策略呢?爲什麼你的程序需要使用註冊表? – 2012-07-26 11:23:35
是的,它似乎很奇怪,非常*黑客*這樣做,但應用程序必須確認一些內部許可證信息,才能登錄。所以我試圖防止登錄用戶只是按Shift + ESC運行任務管理器並殺死應用程序或僅運行userinit並繞過應用程序licese檢查功能。所以我不希望taskMgr一直禁用,因爲用戶可能需要使用它,我只需要在應用程序運行時禁用它。 – todd1215 2012-07-26 19:02:50