vista下如何从System的帐户获得当前登录的是帐号

chinahuman 2008-04-28 05:34:53
因为需要从服务那里弹出一个窗体,所以在vista下面用CreateProcessAsUser把这个窗体所在的程序B弹出来,经过大量的查证,Vista下,虽然以CreateProcessAsUser创建了用户进程,比如说当前的登录帐户是A,进程管理器里面的用户也是A,但是事实上这个程序B所用的用户还是System.
但是我想在我的程序里面可以很快地让用户找到当前用户的桌面文件夹等。发现用 SHGetSpecialFolderLocation(0, CSIDL_APPDATA, pidl);
SHGetPathFromIDList(pidl, appPath);
获取到路径是空,所以只好用拼字串的方式来实现。
现在我的问题是如何在这个程序B里面获取到当前便当的帐户名?
...全文
257 6 打赏 收藏 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
chinahuman 2008-05-04
  • 打赏
  • 举报
回复
结贴,自己搞定了,加一个CreateEnvironmentBlock就可以了
meiZiNick 2008-05-01
  • 打赏
  • 举报
回复
好像没那么简单,呵呵.
knowledge_Is_Life 2008-04-30
  • 打赏
  • 举报
回复
有问题请先GOOGLE,BAIDU
蒋晟 2008-04-30
  • 打赏
  • 举报
回复
In Vista, the session 0 is not the "console session" anymore. Session 0 is reserved for services and the first console user gets session 1.

WTSGetActiveConsoleSessionId should always give you the correct console
session id at the time of the call. On win2k and nt4 tse, you can safely
assume that 0 is always the active console session id, otherwise you should
use WTSGetActiveConsoleSessionId.

CreateProcessAsUser will work in XP or later if you duplicate the token
returned by WTSQueryUserToken into another primary token via
DuplicateTokenEx(...TokenPrimary...) (only one process can be assigned to a
particular token as its primary token). Remember that you need to have
SeTcbPrivilege enabled to use WTSQueryUserToken.

The defining factor in determining which session a process appears in is the
session id in the primary token for the process. This can be accessed and
set via Get/SetTokenInformation(...TokenSessionId...). The token returned
by WTSQueryUserToken should have the same session id and authentication id
as the `interactive user' associated with the session in question. In other
words, it should relate to the token created by the winlogon instance in the
remote session when that user was logged on (and should be associated with
the same LSA logon session, i.e. it will have the same authentication id as
well).

You could also theoretically craft your own token (perhaps from LogonUser)
and set the right session id into it via
SetTokenInformation(...TokenSessionId..) (requires SeTcbPrivilege), and that
token would work for CreateProcessAsUser as well. If you just call
LogonUser, though, it will have a different associated LSA logon session -
authentication id - as the token for the `interactive user' associated with
the target session, which means that it will behave like a process started
via runas on that session. In other words, going that route would probably
break access to the remote user's network shares created under the original
LSA logon session that was created by winlogon.

--
Ken Johnson (Skywing)
Windows SDK MVP
蒋晟 2008-04-29
  • 打赏
  • 举报
回复
http://blogs.msdn.com/ts/archive/2006/11/27/console-behavior-differences-in-longhorn-server-terminal-services.aspx
chinahuman 2008-04-29
  • 打赏
  • 举报
回复
楼上的,只是解说了问题的根源,但是并有提出解决办法呀?
内容概要:本文系统研究了基于雅可比伪逆迭代的双臂协同轨迹规划与跟踪误差收敛性问题,结合机械臂正向与逆向运动学建模、蒙特卡洛法分析工作空间、笛卡尔空间内的圆弧轨迹生成等关键技术,利用Matlab实现了双臂系统的协同控制与轨迹跟踪仿真。重点探讨了雅可比矩阵伪逆法在解决冗余自由度机械臂逆运动学问题中的应用,深入分析了轨迹跟踪过程中误差的收敛特性,并通过仿真实验验证了该方法在复杂任务场景下的有效性、稳定性与鲁棒性,为多臂机器人在工业自动化、精密操作等领域的协同作业提供了理论依据与技术支持。; 适合人群:具备机器人学、自动控制理论基础及Matlab编程能力的科研人员与工程技术人员,特别适合从事机械臂控制、轨迹规划、多机器人协同等方向的硕士、博士研究生及相关领域研究人员。; 使用场景及目标:①掌握基于雅可比伪逆法的机械臂逆运动学求解原理与实现方法;②理解双臂系统在笛卡尔空间中协同轨迹规划的机制;③分析并优化轨迹跟踪过程中的误差收敛性能;④为多机器人系统在复杂动态环境下的高精度协同控制提供算法设计与仿真验证支持。; 阅读建议:建议读者结合文中提供的Matlab代码进行实践操作,按照文档目录循序渐进地学习,重点关注算法实现细节、仿真参数设置与结果分析部分,同时可进一步探索将智能优化算法或深度学习方法引入轨迹规划与误差补偿的研究方向。

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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