开发者

Launch an application from a windows 7 service

We are currently using a report printing application launched by a user-defined function located in a Firebird database which runs as a service.

The UDF consists of a simple DLL that launches the reporting application and pass the report ID to be printed through "CreateProcessAsUser" API.

In details, we are impersonating a particular windows account in order to have access to the user's printer. The computer on which the software is run is n开发者_如何学运维ever attended. No one actually open a session on it.

So here's how we're doing it:

LogonUser( sUser, nil, sPass, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, hToken );

...

LoadUserProfile(hToken, ProfileInfo);

...

ImpersonateLoggedOnUser(hToken);

...

StartupInfo.lpDesktop := Pchar('Winsta0\Default');

CreateProcessAsUser(hToken,nil, Pchar(sCommand), nil, nil, False, 0, nil, nil, StartupInfo, ProcessInfo);

...

UnloadUserProfile(hToken,ProfileInfo.hProfile);

Now we have moved to windows 7 platform and obviously, it doesn't work anymore.

Is it still possible to impersonate a user account and use his printer from a service under windows vista/7 even if the user is not logged on ? (Otherwise I'd use the user's currently active session ID)

Thanks for your help

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜