473,614 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ 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("user 32.dll", CharSet = CharSet.Auto)]
public static extern bool ExitWindowsEx(s tring 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(ob ject sender, System.EventArg s 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 13416
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$******** ******@TK2MSFTN GP09.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("user 32.dll", CharSet = CharSet.Auto)]
public static extern bool ExitWindowsEx(s tring 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(ob ject sender, System.EventArg s 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.ed u

"Jeremy Horton" <je****@e-business-australia.com> wrote in message news:e$******** ******@TK2MSFTN GP09.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("user 32.dll", CharSet = CharSet.Auto)]
public static extern bool ExitWindowsEx(s tring 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(ob ject sender, System.EventArg s 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
2741
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 /usr/lib/python2.3/hotshot/stones.py Pystone(1.1) time for 50000 passes = 2.344 This machine benchmarks at 21331.1 pystones/second 850004 function calls in 4.371 CPU seconds
5
4171
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 lies. Here's a description... I want a callback-based MIDI input/processing, so PortMidi was not an alternative. I have written a C extension module that links to the mmsys MIDI API. I separated the win32-dependant code from the Python extension...
4
2848
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 be loaded, which function to be called, and what are the parameters to call the function. Thank you very much!
5
1823
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? Is it easy to call any DLL function from .net/C# program? The 2nd question is that on a win32 app, I can use 'UNICODE' to support localization (support different languages). How about on .net? Is it straightforward? On win32 application, I...
15
11757
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 performs the query is contained in a delegate function that I execute via a second thread. On 1 or 2 of the 600+ servers the query hangs. I've tried to use Thread.Join() coupled with a Thread.Abort() but this does not kill the thread. Based on...
14
2128
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 platforms. If Win32 applications and .NET application both will run on windows only, what's the advantages for the migration? Or maybe this type of migration is not common in practice?
5
7906
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 Int32, ByVal dwreserved As Int32) As Int32
0
2437
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 some action. The java call looks like this: Win32::SetChildShowWindow(0); Win32::Process::Create(
3
4083
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 = EBDTools::os_path("${nh_home}/web/aview/modules/svcrsp-ng/saSync.pl"); $success = Win32::Spawn($^X, "${^X} $cmdline ${optfile}", $pid); if (! $success) { my $lasterr = Win32::GetLastError(); return_configerror("Failed to create commit / sync process...
0
8198
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8142
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8642
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8444
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7115
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6093
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5549
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2575
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.