🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #630

Shutting down

#630
From: Jos�
Date: Mon, 11 Feb 2008 17:26
34 lines
1919 bytes
Some time ago I asked how to shut down my computer. I thought it
worked, but after all it apears there is something wrong with
privileges. After reading help files and websites, I wrote this:

    TOKEN_PRIVILEGES tp;
    HANDLE hToken;
    LUID luid;
    tp.PrivilegeCount = 1;
    tp.Privileges[0].Luid = luid;
    tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    tp.Privileges[0].Attributes = 0;


    LookupPrivilegeValue(
            NULL,            // lookup privilege on local system
            "SE_SHUTDOWN_NAME",   // privilege to lookup
            &luid ) ;        // receives LUID of privilege

AdjustTokenPrivileges(
           hToken,
           FALSE, 
           &tp,
           sizeof(TOKEN_PRIVILEGES), 
           (PTOKEN_PRIVILEGES) NULL,
           (PDWORD) NULL);

      ExitWindowsEx(EWX_POWEROFF,0);

I think the trouble is the first parameter of AdjustTokenPrivileges,
which, according to the help file "TokenHandle identifies the access
token that contains the privileges to be modified". That's Greek to
me.
-- 
Jos�
Technical Details
Message-ID: <nr01r35bb4etpk28l2uf89a7f01bvlvsqk@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fa244e8cf53430f,start
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII
From: Jos� <jose@127.0.0.1>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Shutting down
Date: Mon, 11 Feb 2008 18:26:37 +0100
Message-ID: <nr01r35bb4etpk28l2uf89a7f01bvlvsqk@4ax.com>
X-Newsreader: Forte Agent 4.2/32.1117
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: 82.75.73.146
X-Trace: newsgroups.borland.com 1202750824 82.75.73.146 (11 Feb 2008 09:27:04 -0700)
Lines: 34
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail