From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,53bd52031670929a,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-12 10:44:40 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed.gamma.ru!Gamma.RU!newsfeed1.bredband.com!bredband!newsspool1.bredband.com!news1.bredband.com.POSTED!not-for-mail From: Bj�rn Holmberg Newsgroups: comp.lang.ada Subject: Problem with Win32Ada - Shutdown NT/Win2k Reply-To: bjornholmberg@bredband.net Message-ID: X-Newsreader: Forte Agent 1.91/32.564 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Fri, 12 Jul 2002 19:32:11 +0200 NNTP-Posting-Host: 213.114.81.54 X-Complaints-To: news-abuse@bredband.com X-Trace: news1.bredband.com 1026495131 213.114.81.54 (Fri, 12 Jul 2002 19:32:11 CEST) NNTP-Posting-Date: Fri, 12 Jul 2002 19:32:11 CEST Organization: A customer of B2 Bredbandsbolaget (www.bredband.com) Xref: archiver1.google.com comp.lang.ada:27020 Date: 2002-07-12T19:32:11+02:00 List-Id: I need to shut down a Win NT machine, but I can't seem to get it right. The function Lookupprivilegevalue returns me zero. I'm not familiar with the API and I'm having a hard time figure out how to handle the pointers. This is what I have so far: with Win32.Winbase; with Win32.Winnt; with System; with Ada.Unchecked_Conversion; with Text_Io; procedure Shut_Down is Returned_Ok : Win32.Bool; Luid : Win32.Winnt.Luid := (Which => Win32.Winnt.U_Kind, U => (Lowpart => 0, Highpart => 0)); PLuid : Win32.Winnt.Pluid; -- ???? TP : Win32.Winnt.Ptoken_Privileges; Htoken : Win32.Winnt.Phandle := new Win32.Winnt.Handle; function CP(C_Str : Win32.CHAR_Array) return Win32.LPCSTR is function UC is new Ada.Unchecked_Conversion (System.Address,Win32.LPCSTR); begin return UC(C_Str(C_Str'First)'Address); end Cp; begin TP := new Win32.Winnt.Token_Privileges; TP.Privilegecount := 1; TP.Privileges(0).Luid := Luid; TP.Privileges(0).Attributes := 4; Returned_Ok := Win32.Winbase.Openprocesstoken(Win32.Winbase.Getcurrentprocess,Win32.Winnt.Token_Adjust_Privileges or Win32.Winnt.Token_Query, hToken); Text_Io.Put_Line("The function returned = " & Win32.Bool'Image(Returned_OK)); Returned_Ok := Win32.Winbase.Lookupprivilegevalue(null,CP(Win32.Winnt.Se_Shutdown_Name), PLuid); Text_Io.Put_Line("The function returned = " & Win32.Bool'Image(Returned_OK)); --Returned_Ok := Win32.Winbase.Adjusttokenprivileges(Basse,Punk,0,null,Frase'access); --Returned_Ok := Win32.Winreg.Initiatesystemshutdown(null, null, 1, Win32.Bool(1), Win32.Bool(1)); end Shut_Down ; All suggestions would be appreciated. TIA Bj�rn.