我的一个2k Service 中需要启动一个进程A,用的是CreateProcess,进程A创建起来后显示为是System用户,并不能读注册表HKEY_Current_User,也不能完整执行一个dos 的bat文件。我想应该是创建的用户有关。直接执行进程A则没有任何问题。
解决方案 »
- 图像特效
- 关于文件监控的API
- 使用SQL语句是,程序提示无效的游标怎么解决?
- missing ';' before identifier 'PVOID64'+vc6.0+platform2003+directx9问题
- 在设计工具栏按钮时候,我想让按钮之间有点间隔,咋弄?
- 内存泄露!
- 算牌器问题。。。急。。
- 指定了Lib文件,仍然出现unresolved external symbol
- 紧急求救:求生成RSA密钥对,RSA签名,验证签名的源码,最好能输出字符串型(在线等)
- 快帮帮我
- 一个巨难的问题,解决后给300分,不够再给.
- CPropertySheet总是调用系统字体,怎么设置其他字体?谢谢。
2000下提供了一个Api,CreateProcessWithLogonW可以以一个用户身份启动一个进程,但是还是需要用户名,密码。除了Hook密码外,就没有别的办法?
用OpenProcessToken
if hExplor = 0 then begin
showMessage( 'get hExplore failed.');
result := false;
exit;
end; if not OpenProcessToken( hExplor, TOKEN_ADJUST_PRIVILEGES, TokenHandle) then
begin
showMessage( 'get OpenProcessToken faild');
result:= false;
exit;
end; //Enable SeTcbPrivilege: lookup, adjust token privs
if ( not LookupPrivilegeValue( nil, 'SE_SECURITY_NAME', setcbnameValue)) then
begin
ShowMessage('LookUp:'+ IntTosTr( GetLastError()));
end; ttp.PrivilegeCount := 1;
ttp.Privileges[0].Luid := setcbnameValue;
ttp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; if ( not AdjustTokenPrivileges(TokenHandle, FALSE, ttp, sizeof(ttp), nil, ReturnLength)) then;
begin
ShowMessage( 'Adjust:'+IntTosTr( GetLastError()));
end; ZeroMemory( @startup_info, Sizeof( TStartupinfo));
startup_info.cb := sizeof( TStartupinfo);
ZeroMemory( @pi, sizeof(PROCESS_INFORMATION)); startup_info.lpDesktop := pchar('WinSta0\Default');
startup_info.dwFlags := STARTF_USESHOWWINDOW;
startup_info.wShowWindow := SW_SHOW; if( CreateProcessAsUser( TokenHandle,
nil, // No module name (use command line).
'F:\Delphi\Service\DemoClient.exe', // Command line.
nil, // Process handle not inheritable.
nil, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
nil, // Use parent's environment block.
pchar('F:\Delphi\Service\'), // Use parent's starting directory.
startup_info, // Pointer to STARTUPINFO structure.
pi )) then // Pointer to PROCESS_INFORMATION structure. begin
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
end else
begin
ShowMessage( IntTosTr( GetLastError()));
end;