提升运行程序的运行权限

w5263 2007-02-26 06:10:01
我想提升我的运行程序的运行权限,现在不知道该怎么写,请问有谁写过,帮帮忙给个实例。
...全文
360 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
w5263 2007-02-28
  • 打赏
  • 举报
回复
不是举别的程序,是自己举自己,举别的程序我有完整的代码,现在我是想通过自己举起自己。谢谢
withcsharp 2007-02-28
  • 打赏
  • 举报
回复
advapi32
CreateProcessWithLogonW
withcsharp 2007-02-28
  • 打赏
  • 举报
回复
如果是 用administrator 举起新的程序 好办
在本进程 提升 也可以 有点麻烦
我是 写了一个exe 再用这个 exe 以administrator 运行 我的主程序的
  • 打赏
  • 举报
回复
zcsor(偶业余的斗胆写点blog(IE表单自动填写相关内容更新ing) ( ) 信誉:100 Blog

你就说说嘛 大哥
w5263 2007-02-28
  • 打赏
  • 举报
回复
你好,我正在做一个关于公司共用查询计算机平台的软件,就是用低权限用户运行计算机,这个程序在运行时涉及到要添加信息,所以要提升程序的自身的用户权限,这不是来干坏事,呵呵呵.....谢谢,请帮帮忙。
w5263 2007-02-27
  • 打赏
  • 举报
回复
谢谢你的例子,这个关于优先级的例子很好,但我的意思是例如在xp下能够把程序本身的运行权限改变,例如:我在user用户权限下运行程序,程序运行时自动提升为administrator用户的权限。
laviewpbt 2007-02-27
  • 打赏
  • 举报
回复
'Example Name:Application Priority
Const THREAD_BASE_PRIORITY_IDLE = -15
Const THREAD_BASE_PRIORITY_LOWRT = 15
Const THREAD_BASE_PRIORITY_MIN = -2
Const THREAD_BASE_PRIORITY_MAX = 2
Const THREAD_PRIORITY_LOWEST = THREAD_BASE_PRIORITY_MIN
Const THREAD_PRIORITY_HIGHEST = THREAD_BASE_PRIORITY_MAX
Const THREAD_PRIORITY_BELOW_NORMAL = (THREAD_PRIORITY_LOWEST + 1)
Const THREAD_PRIORITY_ABOVE_NORMAL = (THREAD_PRIORITY_HIGHEST - 1)
Const THREAD_PRIORITY_IDLE = THREAD_BASE_PRIORITY_IDLE
Const THREAD_PRIORITY_NORMAL = 0
Const THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT
Const HIGH_PRIORITY_CLASS = &H80
Const IDLE_PRIORITY_CLASS = &H40
Const NORMAL_PRIORITY_CLASS = &H20
Const REALTIME_PRIORITY_CLASS = &H100
Private Declare Function SetThreadPriority Lib "kernel32" (ByVal hThread As Long, ByVal nPriority As Long) As Long
Private Declare Function SetPriorityClass Lib "kernel32" (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long
Private Declare Function GetThreadPriority Lib "kernel32" (ByVal hThread As Long) As Long
Private Declare Function GetPriorityClass Lib "kernel32" (ByVal hProcess As Long) As Long
Private Declare Function GetCurrentThread Lib "kernel32" () As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim hThread As Long, hProcess As Long
'retrieve the current thread and process
hThread = GetCurrentThread
hProcess = GetCurrentProcess
'set the new thread priority to "lowest"
SetThreadPriority hThread, THREAD_PRIORITY_LOWEST
'set the new priority class to "idle"
SetPriorityClass hProcess, IDLE_PRIORITY_CLASS
'print some results
Me.AutoRedraw = True
Me.Print "Current Thread Priority:" + Str$(GetThreadPriority(hThread))
Me.Print "Current Priority Class:" + Str$(GetPriorityClass(hProcess))
End Sub

生成EXE文件,然后在任务管理器中就可以看到该进程的优先级为低了
w5263 2007-02-27
  • 打赏
  • 举报
回复
请问有没有例子?谢谢
清晨曦月 2007-02-27
  • 打赏
  • 举报
回复
...你很过分....
这个是可以实现的.虽然我研究了比较长时间..嘿嘿....不过打死也不能说....明显不是拿来干好事的!
  • 打赏
  • 举报
回复
我在user用户权限下运行程序,程序运行时自动提升为administrator用户的权限。

我感觉不可能。
laviewpbt 2007-02-26
  • 打赏
  • 举报
回复
SetThreadPriority
SetPriorityClass
GetCurrentProcess
GetCurrentThread
这几个函数
其他参考函数
GetThreadPriority
GetPriorityClass

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧