Option Explicit
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const REG_DWORD As Long = 4
Private Const REG_SZ As Long = 1
'本子程序主要是将程序与ABC关联
Sub GLabc()
Dim hKey As Long, ret1 As Long
搜了一下MSDN,这个链接可能对你也有用:
http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/21907f09-69e7-459e-82ba-287a3f075848
//------------------------------------
I think that the self-elevation solution and the launch of a separate process to do adminitrative tasks are the best practices here.
Another solution is to install a Windows Service with your application. The Windows Service is configured to run as admin or as SYSTEM. The service is responsible for all administrative tasks. You application that is run as a restricted admin inter-process-communicate with the Windows Service. In this way, you even will not see the elevation UI.
//-------------------------------------
或者,用:
COM out of process or process restart.