On Fri, 19 Mar 2004, [iso-8859-2] Pápai András wrote:
> > Hi! > I recently upgraded fpc on my computer (1.0.4 -> 1.0.10). Now some programs > doen't work correctly. No problems with compilig, no run-time errors, but > the program doesn't work like before. (Win32 platform). > > I attached a source (poweroff.pas). Compiling with 1.0.4, it works as I > want. > With 1.0.10 (and 1.0.6) some API functions return an error. > LookupPrivilegeValue: 203, "ENVVAR_NOT_FOUND" > AdjustTokenPrivileges: 1300, "NOT_ALL_ASSIGNED" > > I couldn't find the reason in the docs. > Can someone help me, please? I don't know what the reason is, but I suspect the large_integer (64 bits). In each case, using 1.9.X, your sources didn't compile at all. I changed them and now the program works correctly as far as I can see (at least, it reports no error). Michael. ----------------------------------------------------------------------- {$mode objfpc} program PowerOff; {.$APPTYPE GUI} uses windows; var hToken: handle; Privileges: TOKEN_PRIVILEGES; Shutdown_LUID: int64; Const ShutDownPriv : Pchar = 'SeShutdownPrivilege'; begin if not OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES,@hToken) then writeln('OPT: ',GetLastError:5); if not LookupPrivilegeValueA(Nil,ShutDownPriv,Shutdown_LUID) then writeln('LPV: ',GetLastError:5); with Privileges do begin PrivilegeCount := 1; Privileges[0].LUID := Shutdown_LUID; Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; end; if not AdjustTokenPrivileges(hToken,false,@Privileges,0,Nil,Nil) then writeln('ATP: ',GetLastError:5); //ExitWindowsEx(EWX_POWEROFF,0); end. _______________________________________________ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal