Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Jul : Tokens : Not anymore?

www.cryer.info
Managed Newsgroup Archive

Tokens : Not anymore?

Subject:Tokens : Not anymore?
Posted by:"Tom Peters" (tom_vip..@msn.com)
Date:Mon, 18 Jul 2005 05:14:11 -0500

I've started using D8.  I cut and pasted the WindowsExit function I use into
an app, I'm writing.  It doesn't seem to recognize the following anymore
(use to be in Windows.pas):

OpenProcessToken
AdjustTokenPrivileges

Where are they defined now?????

Here's the whole function:

function WindowsExit(RebootParam: Longword): Boolean;
var
   TTokenHd: THandle;
   TTokenPvg: TTokenPrivileges;
   cbtpPrevious: DWORD;
   rTTokenPvg: TTokenPrivileges;
   pcbtpPreviousRequired: DWORD;
   tpResult: Boolean;
const
   SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';
begin
   if Win32Platform = VER_PLATFORM_WIN32_NT then
   begin
     tpResult := OpenProcessToken(GetCurrentProcess(),
       TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,
       TTokenHd) ;
     if tpResult then
     begin
       tpResult := LookupPrivilegeValue(nil,
                                        SE_SHUTDOWN_NAME,
                                        TTokenPvg.Privileges[0].Luid) ;
       TTokenPvg.PrivilegeCount := 1;
       TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
       cbtpPrevious := SizeOf(rTTokenPvg) ;
       pcbtpPreviousRequired := 0;
       if tpResult then
         Windows.AdjustTokenPrivileges(TTokenHd,
                                       False,
                                       TTokenPvg,
                                       cbtpPrevious,
                                       rTTokenPvg,
                                       pcbtpPreviousRequired) ;
     end;
   end;
   Result := ExitWindowsEx(RebootParam, 0) ;
end;

Glossary

File Types

Replies:

www.cryer.info
Managed Newsgroup Archive