LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

shut down of windows NT through an application running with LabWindows/Cvi

Can you explain me which instructions I have to use for shut down windows Nt from an LabWindows application.
0 Kudos
Message 1 of 5
(3,284 Views)
According to Windows SDK you should use
ExitWindowsEx(EWX_FORCE, 0);
Look at the reference for this function for a detailed description of the first parameter (for example you could simply log your user off...).
You must #include in your project.
I used it in Win95 and Win98 and it works well. I hadn't tested it in NT, but it's simple to try...

Hope this helps.
Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5
(3,284 Views)
Windows NT is a bit different to Win 98

This code should do the trick for you.

#include "stdafx.h"
#include "WinUtil.h"
#include "WinUtilDlg.h"
#include "WINUSER.H"

void shutdow()
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;

// get the token for this process
if(!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken));

// get the LUID for the shutdown privilegde
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);

tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;


//get the shutdown priviledge
AdjustTokenPrivileges(hToken, FALSE, &tkp,0,(PTOKEN_PRIVILEGES)NULL, 0);

ExitWindowsEx (EWX_SHUTDOWN | EWX_FORCE,0);
}

"Roberto Bozzolo" wrote in message
news:50650
00000050000005A1F0000-984882144000@quiq.com...
> According to Windows SDK you should use
> ExitWindowsEx(EWX_FORCE, 0);
> Look at the reference for this function for a detailed description of
> the first parameter (for example you could simply log your user
> off...).
> You must #include in your project.
> I used it in Win95 and Win98 and it works well. I hadn't tested it in
> NT, but it's simple to try...
>
> Hope this helps.
> Roberto
0 Kudos
Message 3 of 5
(3,284 Views)
>This is a correction to the first posting.

This code should do the trick for you.
>
> #include "stdafx.h"
> #include "WINUSER.H"
>
> void shutdow()
> {
> HANDLE hToken;
> TOKEN_PRIVILEGES tkp;
>
> // get the token for this process
> if(!OpenProcessToken(GetCurrentProcess(),
> TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken));
>
> // get the LUID for the shutdown privilegde
> LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
>
> tkp.PrivilegeCount = 1;
> tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
>
>
> //get the shutdown priviledge
> AdjustTokenPrivileges(hToken, FALSE, &tkp,0,(PTOKEN_PRIVILEGES)NULL, 0);
>
> ExitWindowsEx (EWX_SHUTDOWN | EWX_FORCE,0);
> }
>
> "Roberto Bozzolo" wrote in messa
ge
> news:5065000000050000005A1F0000-984882144000@quiq.com...
> > According to Windows SDK you should use
> > ExitWindowsEx(EWX_FORCE, 0);
> > Look at the reference for this function for a detailed description of
> > the first parameter (for example you could simply log your user
> > off...).
> > You must #include in your project.
> > I used it in Win95 and Win98 and it works well. I hadn't tested it in
> > NT, but it's simple to try...
> >
> > Hope this helps.
> > Roberto
>
>
0 Kudos
Message 4 of 5
(3,284 Views)
Hi Mark,

Do you have a DLL or EXE version of the c code (shutdow)? I am in a similar situation with winnt4, where I want to logof and shutdown from within the program by calling a function. I have labview 6i and I do not have any compilers.

Thanks

Parviz
0 Kudos
Message 5 of 5
(3,284 Views)