473,490 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Win32 API call from C# - ExitWindowsEx

Hi,

New to C# and trying to build an app that has a logout button.
I just want the user to be able to log out of their Windows session from
within the Windows Form.
I have;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool ExitWindowsEx(string teststring1, int testint1);
// private static extern bool ExitWindows(int testint1, int testint2);
// error: entry point not found in user32.dll (?)

and then when the button is clicked;

public void Logout_Click(object sender, System.EventArgs e)
{
ExitWindowsEx(@"EWX_LOGOFF", 0);
// ExitWindows(0, 0);
// error: entry point not found in user32.dll (?)
}
With ExitWindows the entry point is not found, but with ExitWindowsEx
nothing happens (?)
I also see the memory of the .exe increasing by 4k everytime I press the
logout button,
any help greatly appreciated.
Jeremy.
Nov 16 '05 #1
3 13403
Hi,

The 1st parameter of ExitWindowsEx should be an uint, not string and pass 0
(for log off) for the 1st one.

"Jeremy Horton" <je****@e-business-australia.com> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
Hi,

New to C# and trying to build an app that has a logout button.
I just want the user to be able to log out of their Windows session from
within the Windows Form.
I have;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool ExitWindowsEx(string teststring1, int testint1);
// private static extern bool ExitWindows(int testint1, int testint2);
// error: entry point not found in user32.dll (?)

and then when the button is clicked;

public void Logout_Click(object sender, System.EventArgs e)
{
ExitWindowsEx(@"EWX_LOGOFF", 0);
// ExitWindows(0, 0);
// error: entry point not found in user32.dll (?)
}
With ExitWindows the entry point is not found, but with ExitWindowsEx
nothing happens (?)
I also see the memory of the .exe increasing by 4k everytime I press the
logout button,
any help greatly appreciated.
Jeremy.

Nov 16 '05 #2
Just as a follow up - you should also check out
http://www.pinvoke.net/

Search there for ExitWindowsEx. There is description and sample of how to use it there.

--
Adam Clauss
ca*****@tamu.edu

"Jeremy Horton" <je****@e-business-australia.com> wrote in message news:e$**************@TK2MSFTNGP09.phx.gbl...
Hi,

New to C# and trying to build an app that has a logout button.
I just want the user to be able to log out of their Windows session from
within the Windows Form.
I have;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool ExitWindowsEx(string teststring1, int testint1);
// private static extern bool ExitWindows(int testint1, int testint2);
// error: entry point not found in user32.dll (?)

and then when the button is clicked;

public void Logout_Click(object sender, System.EventArgs e)
{
ExitWindowsEx(@"EWX_LOGOFF", 0);
// ExitWindows(0, 0);
// error: entry point not found in user32.dll (?)
}
With ExitWindows the entry point is not found, but with ExitWindowsEx
nothing happens (?)
I also see the memory of the .exe increasing by 4k everytime I press the
logout button,
any help greatly appreciated.
Jeremy.

Nov 16 '05 #3
Shiva - worked first go.
Adam - pinvoke.net, if only I had know this site existed 12hrs ago !!

thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2739
by: Nicolas Lehuen | last post by:
Hi, Is it me, or does anyone else get significantly better pystone results under Cygwin versus the standard Win32 build ? CYGWIN 1.5.6 + python 2.3.3-1 : $ time python...
5
4155
by: Francois De Serres | last post by:
Hiho, could somebody please enlighten me about the mechanics of C callbacks to Python? My domain is more specifically callbacks from the win32 API, but I'm not sure that's where the problem...
4
2839
by: ZhangZQ | last post by:
Is it possible to dynamicaly to local and call a function in Win32 dll(not a ..net assembly dll) in C# at run time, for example, a C# program popup a dialogbox to let use input which Win32 dll to...
5
1808
by: Chi Tang | last post by:
Hi, I need to implement a stand alone gui application which need to call some other regular DLL functions (unmanaged code). Should I use .net with C# or just use Win32 API to write this exe? ...
15
11725
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
14
2114
by: John | last post by:
My friend told me that his company will migrate the VC++ win32 applications to C++ .NET windows applications. I don't understand why since currently Microsoft only supports .NET on windows...
5
7890
by: cj | last post by:
Using VB2003 on Windows XP Pro Why doesn't this work? Public Class Form1 Inherits System.Windows.Forms.Form Private Declare Auto Function ExitWindowsEx Lib "user32.dll" (ByVal uFlags As...
0
2421
by: jbenezech | last post by:
Hi all , I have a perl/java app running under Win32. The application consists of a perl service (Win32::Daemon) and of java classes. The perl service calls every xx hours java classes to perform...
3
4072
by: somuchh8 | last post by:
Hi, I'm having a lot of trouble with the Win32::Spawn module in perl. Here is my situation, I have a Win32::Spawn call which looks like this: my $success = undef; my $cmdline =...
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7146
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7183
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5448
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4573
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.