|
That should do the trick:
clickedy
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
That's great, i can get the pc to log the user off no problems but im still having problems rebooting it. I know why, i dont know how to set the privileges for the current process.
The calling process must have the SE_SHUTDOWN_NAME privilege
I'm reading through the MSDN docs trying to figure it out but the only one i've found so far is written using C++ code, and the classes are not the same in C#. If you could help me set the privileges that would be great!
Cheers
Kev
|
|
|
|
|
I'd suggest you taking a look at www.pinvoke.net and convert the appropriate API calls by yourself.
This should help you a bit.
I've not done this in C# myself yet.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Got it sorted now, thanks.
Found an article that had already converted the API calls to C# and used them.
Cheers
Kev
|
|
|
|
|
HI,
can you give me the code of Rebooting
regards
sanjeev
email: sanjeevsinghh@gmail.com
|
|
|
|
|
Here's some code for converting the functions you need to reboot with.
[DllImport("user32.dll")]
private static extern bool ExitWindowsEx(uint uFlags, uint dwReason);
[StructLayout(LayoutKind.Sequential, Pack=1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}
[DllImport("kernel32.dll", ExactSpelling=true) ]
internal static extern IntPtr GetCurrentProcess();
[DllImport("advapi32.dll", ExactSpelling=true, SetLastError=true) ]
internal static extern bool OpenProcessToken( IntPtr h, int acc, ref IntPtr phtok );
[DllImport("advapi32.dll", SetLastError=true) ]
internal static extern bool LookupPrivilegeValue( string host, string name, ref long pluid );
[DllImport("advapi32.dll", ExactSpelling=true, SetLastError=true) ]
internal static extern bool AdjustTokenPrivileges( IntPtr htok, bool disall,
ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen );
Then you just need to call ExitWindowsEx, see above for links tyo the MSDN documentation for it.
Kev
|
|
|
|
|
Look at the win API function ExitWindowEx.
/\ |_ E X E GG
|
|
|
|
|
I have a console utility I'd like to interact with and get it's output.
I can send in a list of commands into it via < like this:
myapp < commmands.txt
also I can do:
myapp "command1 asdf" "command2 asdf" "command3 asdf 223"
and so on..
What feature would I use to send commands into it and what would I use to read it's output ?
thanks,
H
|
|
|
|
|
|
Let's say I'm interacting with the utility "dir"
i'd like to do as my command:
"dir " + strMyDir
and then read the output from this command and parse it to my likeing
|
|
|
|
|
|
Yes, thanks.
|
|
|
|
|
Hi,
When I call InternetDial function from WinInet.dll I don’t want from system to show me modal dialog box with values from default internet connection. For example when I uncheck all the option in Dialing options in properties of my default dial-up connection and double click on my default dial-up connection I haven’t seen any modal dialog box. Computer starts to call other site immediately.
From my program I want to produce same behavior as mention before.
Thanks,
|
|
|
|
|
I would to handle Paint windows messages for textbox paint event.
Invact i would to avoid to draw the classic white background with an image myown.
How can i do?
|
|
|
|
|
Hi all.
I'm using MDI Forms in my project. Control boxes of child forms are false. But when i make the window states of child forms Maximized, althoug they are false, control boxes of child forms are shown on the MainMenu. I don't wan't them to be shown. What can I do?
Thanks all...
|
|
|
|
|
hello,please help me by letting me know which algorithm you have used for motion detection using c# which was done by taha zayed.hoping you will mail me fast,its very urgent.thanking you
shamna
shamna_a@rediffmail.com
|
|
|
|
|
is there any API that can help me to do show and hide for desktop icons ?
|
|
|
|
|
What do you mean by "show" and "hide" desktop icons? What are you trying to do.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thx dave for ur interest
i will try explain it to u ,
in windowsXP right click on the "desktop" then "arrange icons by" sub menu then "show desktop icons"
i want to do the same functionality ,using C#
thats all
thx again for ur interest
|
|
|
|
|
OK, I looked at it. Why on earth would you ever want to do this? If you modified my desktop like that, I'd uninstall your app before the last icon disappeared off the desktop. If you were locking down a desktop, you could do thie same thing through policies.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Use the win API function, ShowWindow and pass the handle to the desktop and 0 to the second parameter to hide the icons. 1 to show them again. Here's a sample console app.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace ConsoleApplication14
{
class Program
{
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
static void Main(string[] args)
{
IntPtr handle = new IntPtr(65722);
ShowWindow(handle, 0);
}
}
/\ |_ E X E GG
|
|
|
|
|
thx eggie5
ur code was very helpfull, i tried it , it works good , i got my dektop window handle from spy++ and but it the code
but i want to got the desktop window handle dynamically,
so i used the function "GetDesktopWindow" in "user32.dll"
but it didnt work , so i discovered that i have to get another window handle inside the desktop,
so i tried to use "EnumChildWindows" in "user32.dll" , but till now i still have problems to get the right window handle
|
|
|
|
|
That's a very reasonable request and I don't know why I didn't implement it in the first place. I must be a slacker. Anyways, to implement the "dynamic" desktop handle recovery you speak of, we need to introduce a new Window API function, FindWindow . Consider the following example:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace ConsoleApplication15
{
class Program
{
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
static void Main(string[] args)
{
IntPtr handle = FindWindow(null, "PROGRAM MANAGER");
ShowWindow(handle, 0);
}
}
}
We get the handle to the desktop by using a null parameter and "PROGRAM MANAGER" for the second parameter of the FindWindow function. Don't ask me how I figured it out. Anyways, that should work.
Additionally, if you have a "Show Desktop" button in your taskbar you will notice some cool clashing between your program and windows, because I think that "Show Desktop" button calls ShowWindow somewhere....
Let me know if this works for you...
/\ |_ E X E GG
|
|
|
|
|
thx again
it works but i wonder why these arguments and what if i want to use the same function to open another windows, how can i get the right arguments, i will search for this and till u about the results
some clashs happend with another modules that i use for setting active desktop but any way i will continue use it and try to search more about it and learn more
thx again for ur help and interest
|
|
|
|
|
How an image is rotated at some sapcific angle?
|
|
|
|